Skip to content

Commit 7437639

Browse files
mttjohnsonstgraber
authored andcommitted
terraform: Define some new variables
This allows setting tfvars for: - Incus server address (scheme, address, port) - Name of storage pool - Name of network - OVN uplink configuration Signed-off-by: Matt Johnson <[email protected]>
1 parent 524e558 commit 7437639

File tree

10 files changed

+101
-9
lines changed

10 files changed

+101
-9
lines changed

Diff for: README.md

+4
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ tofu init
2525
```
2626

2727
Create 5 VMs and associated networks and storage volumes for testing an Incus cluster:
28+
If your Incus host needs different values from the default, you may need
29+
to copy `terraform.tfvars.example` to `terraform.tfvars` and update the
30+
variables.
31+
2832
```
2933
tofu apply -target=module.baremetal
3034
```

Diff for: terraform/baremetal-incus/main.tf

+3-3
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ resource "incus_network" "this" {
1717
description = "Network used to test incus-deploy (OVN uplink)"
1818

1919
config = {
20-
"ipv4.address" = "172.31.254.1/24"
20+
"ipv4.address" = var.ovn_uplink_ipv4_address
2121
"ipv4.nat" = "true"
22-
"ipv6.address" = "fd00:1e4d:637d:1234::1/64"
22+
"ipv6.address" = var.ovn_uplink_ipv6_address
2323
"ipv6.nat" = "true"
2424
}
2525
}
@@ -49,7 +49,7 @@ resource "incus_profile" "this" {
4949
name = "eth0"
5050

5151
properties = {
52-
"network" = "incusbr0"
52+
"network" = var.network
5353
"name" = "eth0"
5454
}
5555
}

Diff for: terraform/baremetal-incus/variables.tf

+14
Original file line numberDiff line numberDiff line change
@@ -17,3 +17,17 @@ variable "memory" {
1717
variable "storage_pool" {
1818
type = string
1919
}
20+
21+
variable "network" {
22+
type = string
23+
}
24+
25+
variable "ovn_uplink_ipv4_address" {
26+
type = string
27+
default = ""
28+
}
29+
30+
variable "ovn_uplink_ipv6_address" {
31+
type = string
32+
default = ""
33+
}

Diff for: terraform/main.tf

+9-2
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,12 @@ module "baremetal" {
55
instance_names = ["server01", "server02", "server03", "server04", "server05"]
66
image = "images:ubuntu/22.04"
77
memory = "4GiB"
8-
storage_pool = "default"
8+
9+
storage_pool = var.incus_storage_pool
10+
network = var.incus_network
11+
12+
ovn_uplink_ipv4_address = var.ovn_uplink_ipv4_address
13+
ovn_uplink_ipv6_address = var.ovn_uplink_ipv6_address
914
}
1015

1116
module "services" {
@@ -14,5 +19,7 @@ module "services" {
1419
project_name = "dev-incus-deploy-services"
1520
instance_names = ["ceph-mds01", "ceph-mds02", "ceph-mds03", "ceph-mgr01", "ceph-mgr02", "ceph-mgr03", "ceph-rgw01", "ceph-rgw02", "ceph-rgw03"]
1621
image = "images:ubuntu/24.04"
17-
storage_pool = "default"
22+
23+
storage_pool = var.incus_storage_pool
24+
network = var.incus_network
1825
}

Diff for: terraform/provider_incus.tf

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
provider "incus" {
2+
remote {
3+
name = "incus-deploy"
4+
scheme = var.incus_host_scheme
5+
address = var.incus_host_address
6+
port = var.incus_host_port
7+
default = True
8+
}
9+
}

Diff for: terraform/services/main.tf

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ resource "incus_profile" "this" {
3737
name = "eth0"
3838

3939
properties = {
40-
"network" = "incusbr0"
40+
"network" = var.network
4141
"name" = "eth0"
4242
}
4343
}

Diff for: terraform/services/variables.tf

+5
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,8 @@ variable "image" {
1313
variable "storage_pool" {
1414
type = string
1515
}
16+
17+
variable "network" {
18+
type = string
19+
default = ""
20+
}

Diff for: terraform/terraform.tfvars.example

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Example of terraform.tfvars
2+
#
3+
# You can copy the contents of this file to terraform.tfvars and modify
4+
# values for your own setup to operate with values different from the defaults
5+
#
6+
# A terraform.tfvars will override any other defined variables such as the ones
7+
# in *.auto.tfvars or defaults in variables.tf
8+
# https://opentofu.org/docs/language/values/variables/#variable-definitions-tfvars-files
9+
# https://opentofu.org/docs/language/values/variables/#variable-definition-precedence
10+
11+
# Provider variables
12+
incus_host_scheme = "unix" # Protocol to access Incus (unix or https)
13+
incus_host_address = "" # Address to reach Incus (IP address or FQDN if scheme is https)
14+
incus_host_port = 8443 # Port to reach Incus (used when scheme is https)
15+
16+
# Incus variables
17+
incus_storage_pool = "default" # Name of the storage pool to use for the VMs and volumes
18+
incus_network = "incusbr0" # Name of the network to use for the VMs
19+
20+
# OVN uplink configuration
21+
ovn_uplink_ipv4_address = "172.31.254.1/24"
22+
ovn_uplink_ipv6_address = "fd00:1e4d:637d:1234::1/64"

Diff for: terraform/variables.tf

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
variable "incus_host_scheme" {
2+
type = string
3+
default = "unix"
4+
}
5+
6+
variable "incus_host_address" {
7+
type = string
8+
default = ""
9+
}
10+
11+
variable "incus_host_port" {
12+
type = number
13+
default = 8443
14+
}
15+
16+
variable "incus_storage_pool" {
17+
type = string
18+
default = "default"
19+
}
20+
21+
variable "incus_network" {
22+
type = string
23+
default = "incusbr0"
24+
}
25+
26+
variable "ovn_uplink_ipv4_address" {
27+
type = string
28+
default = "172.31.254.1/24"
29+
}
30+
31+
variable "ovn_uplink_ipv6_address" {
32+
type = string
33+
default = "fd00:1e4d:637d:1234::1/64"
34+
}

Diff for: terraform/versions.tf

-3
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,3 @@ terraform {
77
}
88
}
99
}
10-
11-
provider "incus" {
12-
}

0 commit comments

Comments
 (0)