Skip to content
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions environments/site/tofu/additional.tf
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ module "additional" {
availability_zone = lookup(each.value, "availability_zone", null)
ip_addresses = lookup(each.value, "ip_addresses", null)
security_group_ids = lookup(each.value, "security_group_ids", [for o in data.openstack_networking_secgroup_v2.nonlogin: o.id])
additional_cloud_config = lookup(each.value, "additional_cloud_config", var.additional_cloud_config)
additional_cloud_config_vars = lookup(each.value, "additional_cloud_config_vars", var.additional_cloud_config_vars)

# can't be set for additional nodes
compute_init_enable = []
Expand Down Expand Up @@ -64,5 +66,7 @@ module "additional" {
"gateway_ip",
"nodename_template",
"security_group_ids",
"additional_cloud_config",
"additional_cloud_config_vars"
]
}
7 changes: 7 additions & 0 deletions environments/site/tofu/compute.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module "compute" {
root_volume_type = lookup(each.value, "root_volume_type", var.root_volume_type)
gateway_ip = lookup(each.value, "gateway_ip", var.gateway_ip)
nodename_template = lookup(each.value, "nodename_template", var.cluster_nodename_template)
additional_cloud_config = lookup(each.value, "additional_cloud_config", var.additional_cloud_config)
additional_cloud_config_vars = lookup(each.value, "additional_cloud_config_vars", var.additional_cloud_config_vars)

# optionally set for group:
networks = concat(var.cluster_networks, lookup(each.value, "extra_networks", []))
Expand Down Expand Up @@ -59,5 +61,10 @@ module "compute" {
"ip_addresses",
"gateway_ip",
"nodename_template",
"additional_cloud_config",
"additional_cloud_config_vars"
]

config_drive = var.config_drive

}
6 changes: 6 additions & 0 deletions environments/site/tofu/control.tf
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,12 @@ resource "openstack_compute_instance_v2" "control" {
%{if var.home_volume_provisioning != "none"}
- [LABEL=home, /exports/home]
%{endif}

%{if var.additional_cloud_config != ""}
${templatestring(var.additional_cloud_config, var.additional_cloud_config_vars)}
%{endif}
EOF

config_drive = var.config_drive

}
6 changes: 6 additions & 0 deletions environments/site/tofu/login.tf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ module "login" {
root_volume_type = lookup(each.value, "root_volume_type", var.root_volume_type)
gateway_ip = lookup(each.value, "gateway_ip", var.gateway_ip)
nodename_template = lookup(each.value, "nodename_template", var.cluster_nodename_template)
additional_cloud_config = lookup(each.value, "additional_cloud_config", var.additional_cloud_config)
additional_cloud_config_vars = lookup(each.value, "additional_cloud_config_vars", var.additional_cloud_config_vars)

# optionally set for group:
networks = concat(var.cluster_networks, lookup(each.value, "extra_networks", []))
Expand Down Expand Up @@ -63,5 +65,9 @@ module "login" {
"ip_addresses",
"gateway_ip",
"nodename_template",
"additional_cloud_config",
"additional_cloud_config_vars"
]

config_drive = var.config_drive
}
13 changes: 13 additions & 0 deletions environments/site/tofu/node_group/nodes.tf
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ resource "openstack_blockstorage_volume_v3" "compute" {
name = "${var.cluster_name}-${each.key}"
description = "Compute node ${each.value.node} volume ${each.value.volume}"
size = var.extra_volumes[each.value.volume].size
volume_type = var.extra_volumes[each.value.volume].volume_type
}

resource "openstack_compute_volume_attach_v2" "compute" {
Expand Down Expand Up @@ -115,10 +116,16 @@ resource "openstack_compute_instance_v2" "compute_fixed_image" {
user_data = <<-EOF
#cloud-config
fqdn: ${local.fqdns[each.key]}

%{if var.additional_cloud_config != ""}
${templatestring(var.additional_cloud_config, var.additional_cloud_config_vars)}
%{endif}
EOF

availability_zone = var.match_ironic_node ? "${local.baremetal_az}::${var.baremetal_nodes[each.key]}" : var.availability_zone

config_drive = var.config_drive

lifecycle {
ignore_changes = [
image_id,
Expand Down Expand Up @@ -170,10 +177,16 @@ resource "openstack_compute_instance_v2" "compute" {
user_data = <<-EOF
#cloud-config
fqdn: ${local.fqdns[each.key]}

%{if var.additional_cloud_config != ""}
${templatestring(var.additional_cloud_config, var.additional_cloud_config_vars)}
%{endif}
EOF

availability_zone = var.match_ironic_node ? "${local.baremetal_az}::${var.baremetal_nodes[each.key]}" : var.availability_zone

config_drive = var.config_drive

}

resource "openstack_networking_floatingip_associate_v2" "fip" {
Expand Down
28 changes: 28 additions & 0 deletions environments/site/tofu/node_group/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ variable "extra_volumes" {
Keys are unique volume name.
Values are a mapping with:
size: Size of volume in GB
volume_type: Optional. Type of volume, or cloud default
**NB**: The order in /dev is not guaranteed to match the mapping
EOF
type = map(
object({
size = number
volume_type = optional(string)
})
)
default = {}
Expand Down Expand Up @@ -190,3 +192,29 @@ variable "allowed_keys" {
type = list
# don't provide a default here as allowed keys may depend on module use
}

variable "config_drive" {
description = <<-EOT
Whether to enable Nova config drives on all nodes, which will mount a drive containing
information that would usually be available through the metadata service.
EOT
type = bool
default = false
}

variable "additional_cloud_config" {
description = <<-EOT
Multiline string to be appended to the node's cloud-init cloud-config user-data.
Must be in yaml format and not include the #cloud-config or any other user-data headers.
See https://cloudinit.readthedocs.io/en/latest/explanation/format.html#cloud-config-data.
Can be a templatestring parameterised by `additional_cloud_config_vars`
EOT
type = string
default = ""
}

variable "additional_cloud_config_vars" {
description = "Map of values passed to the `additional_cloud_config` templatestring"
type = map(any)
default = {}
}
36 changes: 33 additions & 3 deletions environments/site/tofu/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,11 @@ variable "login" {
volume_backed_instances: Overrides variable volume_backed_instances
root_volume_size: Overrides variable root_volume_size
extra_volumes: Mapping defining additional volumes to create and attach
Keys are unique volume name.
Values are a mapping with:
Keys are unique volume name.
Values are a mapping with:
size: Size of volume in GB
**NB**: The order in /dev is not guaranteed to match the mapping
volume_type: Optional. Type of volume, or cloud default
**NB**: The order in /dev is not guaranteed to match the mapping
fip_addresses: List of addresses of floating IPs to associate with
nodes, in the same order as nodes parameter. The
floating IPs must already be allocated to the project.
Expand Down Expand Up @@ -117,6 +118,7 @@ variable "compute" {
Keys are unique volume name.
Values are a mapping with:
size: Size of volume in GB
volume_type: Optional. Type of volume, or cloud default
**NB**: The order in /dev is not guaranteed to match the mapping
ip_addresses: Mapping of list of fixed IP addresses for nodes, keyed
by network name, in same order as nodes parameter.
Expand Down Expand Up @@ -311,3 +313,31 @@ variable "cluster_nodename_template" {
type = string
default = "$${cluster_name}-$${node}.$${cluster_name}.$${cluster_domain_suffix}"
}

variable "config_drive" {
description = <<-EOT
Whether to enable Nova config drives on all nodes, which will mount a drive containing
information that would usually be available through the metadata service.
EOT
type = bool
default = false
}

variable "additional_cloud_config" {
description = <<-EOT
Multiline string to be appended to the node's cloud-init cloud-config user-data.
Must be in yaml format and not include the #cloud-config or any other user-data headers.
See https://cloudinit.readthedocs.io/en/latest/explanation/format.html#cloud-config-data.
Can be a templatestring parameterised by `additional_cloud_config_vars`
Can't set the `boot-cmd`, `fqdn` or `mounts` variables here
EOT
type = string
default = ""
}

variable "additional_cloud_config_vars" {
description = "Map of values passed to the `additional_cloud_config` templatestring"
type = map(any)
default = {}
}

Loading