Skip to content

Commit ca9485b

Browse files
committed
add user guide, update variables.tf with descriptions and add provider.tf
1 parent 2c1c8c2 commit ca9485b

4 files changed

Lines changed: 186 additions & 31 deletions

File tree

docs/guide.rst

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
===============================
2+
OpenTofu Vast Manila User Guide
3+
===============================
4+
5+
OpenTofu Vast Manila allows you to manage your Vast resources using Terraform.
6+
This guide will provide you with example templated for available resources.
7+
A full list of variables available for each resource can be found in `variables.tf`_
8+
with a description and type.
9+
10+
Currently, this module requires `Tofu OpenStack Config`_ support for networks,
11+
subnets and project. See `integration section`_ for more details.
12+
13+
It is recommend for easy readibility to separate your resources in ``main.tf``
14+
as follows:
15+
16+
.. code-block:: console
17+
18+
module "vast" {
19+
source =
20+
21+
# vast credentials need to be accessible to the module
22+
username =
23+
password =
24+
25+
vippools = local.vippool-config
26+
vast_tenants = local.vast-tenant-config
27+
...
28+
}
29+
30+
The config for each resource can then be written into separate files, suggested
31+
format is ``<resource>-config.tf``, for example:
32+
33+
- ``vippool-config.tf``
34+
- ``vast-tenant-config.tf``
35+
36+
Vippools
37+
--------
38+
39+
To create a vippool, add config to ``vippool-config.tf``.
40+
41+
Template:
42+
43+
.. code-block:: console
44+
45+
locals {
46+
vippool-config = {
47+
## start of template
48+
"<your-tofu-vippool-name" = {
49+
name = # optional, if network provided name is templated from given network segmetation_id for format openstack_vlan_<segmentation_id>
50+
subnet_cidr =
51+
network = "<your-tofu-network-name>"
52+
project =
53+
54+
vip_ranges = [
55+
{ subnet =
56+
start =
57+
end =
58+
}, # vip_ranges must be separated by a comma (,)
59+
{ ... }
60+
]
61+
}
62+
## end of template
63+
}
64+
}
65+
66+
Vast Tenants
67+
------------
68+
69+
To create a Vast tenant, add config to ``vast-tenant-config``.
70+
71+
Template:
72+
73+
.. code-block:: console
74+
75+
locals {
76+
vast-tenant-config = {
77+
## start of template
78+
"<your-vast-tenant-name>" = {
79+
allow_locked_users =
80+
allow_disabled_users =
81+
82+
client_ranges = [
83+
{
84+
subnet = "<tofu-subnet-name>"
85+
start =
86+
end =
87+
}, #client_ranges must be separated by a comma (,)
88+
{ ... }
89+
]
90+
# or
91+
client_ip_ranges = [
92+
{ ... }, #client_ip_ranges must be separated by a comma (,)
93+
{ ... }
94+
]
95+
}
96+
## end of template
97+
}
98+
}
99+
100+
101+
.. _integration section:
102+
103+
==================================
104+
Tofu OpenStack Config Integration
105+
==================================
106+
107+
To access the ``projects``, ``networks`` and ``subnets`` resources from `Tofu OpenStack Config`_
108+
module, you need to provide the ``vast`` mpdule with the ``openstack`` resources.
109+
This can be done by including the following in your ``main.tf``:
110+
111+
.. code-block:: console
112+
113+
##main.tf
114+
module "vast" {
115+
source = "github.com/stackhpc/opentofu-vast-manila?ref=main"
116+
# this lines takes the resources from the module "openstack" into the vast module
117+
projects = module.openstack.projects
118+
networks = module.openstack.networks
119+
subnets = module.openstack.subnets
120+
...
121+
}
122+
123+
module "openstack" {
124+
source = "github.com/stackhpc/tofu-openstack-config?ref=main"
125+
126+
projects =
127+
networks =
128+
subnets =
129+
...
130+
}
131+
132+
.. _variables.tf: https://github.com/stackhpc/opentofu-vast-manila/blob/main/variables.tf
133+
.. _Tofu OpenStack Config: https://github.com/stackhpc/tofu-openstack-config

provider.tf

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
terraform {
2+
required_providers {
3+
vastdata = {
4+
source = "vast-data/vastdata"
5+
version = "2.1.1"
6+
}
7+
}
8+
}
9+
10+
provider "vastdata" {
11+
username = var.username
12+
port = 443
13+
password = var.password
14+
host = var.vast_host
15+
skip_ssl_verify = true
16+
}

variables.tf

Lines changed: 37 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,21 @@
11
variable "vippools" {
2+
description = <<-EOT
3+
Map of vippools. Key is tofu resource name. Values are mappings with keys/values:
4+
name: Optional string, if not provided network is used to template name of format "openstack_vlan_<segmentation_id>"
5+
network: Optional string, tofu network resource name, used to template name and vlan if provided (using segmentation_id)
6+
vlan: Optional number
7+
role: Optional string
8+
subnet_cidr: Optional number
9+
tenant_id: Optional string, overridden by project
10+
project: Optional string, openstack project name, overrides tenant_id
11+
vip_ranges: Optional list. Elements are maps with keys/values.
12+
subnet: Required string, tofu subnet resource name
13+
start: Required number
14+
end: Required number
15+
ip_ranges: Optional list. Elements are maps with keys/values.
16+
EOT
217
type = map(
318
object({
4-
519
name = optional(string)
620
network = optional(string)
721
vlan = optional(number)
@@ -22,9 +36,18 @@ variable "vippools" {
2236
}
2337

2438
variable "vast_tenants" {
39+
description = <<-EOT
40+
Map of vast tenants. Key is tofu resource name. Values are mappings with keys/values:
41+
allow_locked_users: Optional bool
42+
allow_disabled_users: Optional bool
43+
client_ranges: Optional list, overridden by client_ip_ranges
44+
subnet: Required string, tofu subnet resource name
45+
start: Required number
46+
end: Required number
47+
client_ip_ranges: Optional list, overrides client_ip_ranges
48+
EOT
2549
type = map(
2650
object({
27-
name = string
2851
allow_locked_users = optional(bool, null)
2952
allow_disabled_users = optional(bool, null)
3053
# may need renaming
@@ -39,6 +62,18 @@ variable "vast_tenants" {
3962
default = {}
4063
}
4164

65+
variable "password" {
66+
sensitive = true
67+
}
68+
69+
variable "vast_host" {
70+
default = "10.3.2.10"
71+
}
72+
73+
variable "username" {
74+
default = "openstack-manila"
75+
}
76+
4277
variable "subnets" {
4378
type = map(object({
4479
id = string

vast.tf

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,3 @@
1-
variable "password" {
2-
sensitive = true
3-
}
4-
5-
variable "vast_host" {
6-
default = "10.3.2.10"
7-
}
8-
9-
variable "username" {
10-
default = "openstack-manila"
11-
}
12-
13-
terraform {
14-
required_providers {
15-
vastdata = {
16-
source = "vast-data/vastdata"
17-
version = "2.1.1"
18-
}
19-
}
20-
}
21-
22-
provider "vastdata" {
23-
username = var.username
24-
port = 443
25-
password = var.password
26-
host = var.vast_host
27-
skip_ssl_verify = true
28-
}
29-
301
resource "vastdata_vip_pool" "vippool" {
312
for_each = var.vippools
323

0 commit comments

Comments
 (0)