terraform-openstack: Added possibility to enable dhcp flag critical on one interface (#10446)
* terraform-openstack: Updated extra partitions to use empty list by default * terraform-openstack: Added possibility to enable dhcp flag critical on one interfacepull/10455/head
parent
a81c6d5448
commit
d669b93c4f
|
@ -318,6 +318,7 @@ k8s_nodes:
|
||||||
mount_path: string # Path to where the partition should be mounted
|
mount_path: string # Path to where the partition should be mounted
|
||||||
partition_start: string # Where the partition should start (e.g. 10GB ). Note, if you set the partition_start to 0 there will be no space left for the root partition
|
partition_start: string # Where the partition should start (e.g. 10GB ). Note, if you set the partition_start to 0 there will be no space left for the root partition
|
||||||
partition_end: string # Where the partition should end (e.g. 10GB or -1 for end of volume)
|
partition_end: string # Where the partition should end (e.g. 10GB or -1 for end of volume)
|
||||||
|
netplan_critical_dhcp_interface: string # Name of interface to set the dhcp flag critical = true, to circumvent [this issue](https://bugs.launchpad.net/ubuntu/+source/systemd/+bug/1776013).
|
||||||
```
|
```
|
||||||
|
|
||||||
For example:
|
For example:
|
||||||
|
|
|
@ -19,8 +19,8 @@ data "cloudinit_config" "cloudinit" {
|
||||||
part {
|
part {
|
||||||
content_type = "text/cloud-config"
|
content_type = "text/cloud-config"
|
||||||
content = templatefile("${path.module}/templates/cloudinit.yaml.tmpl", {
|
content = templatefile("${path.module}/templates/cloudinit.yaml.tmpl", {
|
||||||
# template_file doesn't support lists
|
extra_partitions = [],
|
||||||
extra_partitions = ""
|
netplan_critical_dhcp_interface = ""
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -821,7 +821,8 @@ resource "openstack_compute_instance_v2" "k8s_nodes" {
|
||||||
flavor_id = each.value.flavor
|
flavor_id = each.value.flavor
|
||||||
key_pair = openstack_compute_keypair_v2.k8s.name
|
key_pair = openstack_compute_keypair_v2.k8s.name
|
||||||
user_data = each.value.cloudinit != null ? templatefile("${path.module}/templates/cloudinit.yaml.tmpl", {
|
user_data = each.value.cloudinit != null ? templatefile("${path.module}/templates/cloudinit.yaml.tmpl", {
|
||||||
extra_partitions = each.value.cloudinit.extra_partitions
|
extra_partitions = each.value.cloudinit.extra_partitions,
|
||||||
|
netplan_critical_dhcp_interface = each.value.cloudinit.netplan_critical_dhcp_interface,
|
||||||
}) : data.cloudinit_config.cloudinit.rendered
|
}) : data.cloudinit_config.cloudinit.rendered
|
||||||
|
|
||||||
dynamic "block_device" {
|
dynamic "block_device" {
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
%{~ if length(extra_partitions) > 0 }
|
%{~ if length(extra_partitions) > 0 || netplan_critical_dhcp_interface != "" }
|
||||||
#cloud-config
|
#cloud-config
|
||||||
bootcmd:
|
bootcmd:
|
||||||
%{~ for idx, partition in extra_partitions }
|
%{~ for idx, partition in extra_partitions }
|
||||||
|
@ -8,11 +8,26 @@ bootcmd:
|
||||||
%{~ endfor }
|
%{~ endfor }
|
||||||
|
|
||||||
runcmd:
|
runcmd:
|
||||||
|
%{~ if netplan_critical_dhcp_interface != "" }
|
||||||
|
- netplan apply
|
||||||
|
%{~ endif }
|
||||||
%{~ for idx, partition in extra_partitions }
|
%{~ for idx, partition in extra_partitions }
|
||||||
- mkdir -p ${partition.mount_path}
|
- mkdir -p ${partition.mount_path}
|
||||||
- chown nobody:nogroup ${partition.mount_path}
|
- chown nobody:nogroup ${partition.mount_path}
|
||||||
- mount ${partition.partition_path} ${partition.mount_path}
|
- mount ${partition.partition_path} ${partition.mount_path}
|
||||||
%{~ endfor }
|
%{~ endfor ~}
|
||||||
|
|
||||||
|
%{~ if netplan_critical_dhcp_interface != "" }
|
||||||
|
write_files:
|
||||||
|
- path: /etc/netplan/90-critical-dhcp.yaml
|
||||||
|
content: |
|
||||||
|
network:
|
||||||
|
version: 2
|
||||||
|
ethernets:
|
||||||
|
${ netplan_critical_dhcp_interface }:
|
||||||
|
dhcp4: true
|
||||||
|
critical: true
|
||||||
|
%{~ endif }
|
||||||
|
|
||||||
mounts:
|
mounts:
|
||||||
%{~ for idx, partition in extra_partitions }
|
%{~ for idx, partition in extra_partitions }
|
||||||
|
|
|
@ -142,13 +142,14 @@ variable "k8s_nodes" {
|
||||||
additional_server_groups = optional(list(string))
|
additional_server_groups = optional(list(string))
|
||||||
server_group = optional(string)
|
server_group = optional(string)
|
||||||
cloudinit = optional(object({
|
cloudinit = optional(object({
|
||||||
extra_partitions = list(object({
|
extra_partitions = optional(list(object({
|
||||||
volume_path = string
|
volume_path = string
|
||||||
partition_path = string
|
partition_path = string
|
||||||
partition_start = string
|
partition_start = string
|
||||||
partition_end = string
|
partition_end = string
|
||||||
mount_path = string
|
mount_path = string
|
||||||
}))
|
})), [])
|
||||||
|
netplan_critical_dhcp_interface = optional(string, "")
|
||||||
}))
|
}))
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue