Skip to content

Commit 54165a4

Browse files
committed
simplify control node definition and access IP
1 parent c889d19 commit 54165a4

File tree

6 files changed

+9
-12
lines changed

6 files changed

+9
-12
lines changed

environments/skeleton/{{cookiecutter.environment}}/tofu/compute.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ module "compute" {
2626

2727
# computed
2828
k3s_token = local.k3s_token
29-
control_address = [for n in openstack_compute_instance_v2.control["control"].network: n.fixed_ip_v4 if n.access_network][0]
29+
control_address = openstack_compute_instance_v2.control.access_ip_v4
3030
security_group_ids = [for o in data.openstack_networking_secgroup_v2.nonlogin: o.id]
3131
}

environments/skeleton/{{cookiecutter.environment}}/tofu/control.tf

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ resource "openstack_networking_port_v2" "control" {
2424

2525
resource "openstack_compute_instance_v2" "control" {
2626

27-
for_each = toset(["control"])
28-
29-
name = "${var.cluster_name}-${each.key}"
27+
name = "${var.cluster_name}-control"
3028
image_id = var.cluster_image_id
3129
flavor_name = var.control_node_flavor
3230
key_pair = var.key_pair
@@ -62,11 +60,12 @@ resource "openstack_compute_instance_v2" "control" {
6260
metadata = {
6361
environment_root = var.environment_root
6462
k3s_token = local.k3s_token
63+
# TODO: set k3s_subnet from access_network
6564
}
6665

6766
user_data = <<-EOF
6867
#cloud-config
69-
fqdn: ${var.cluster_name}-${each.key}.${var.cluster_name}.${var.cluster_domain_suffix}
68+
fqdn: ${var.cluster_name}-control.${var.cluster_name}.${var.cluster_domain_suffix}
7069
7170
bootcmd:
7271
%{for volume in local.control_volumes}

environments/skeleton/{{cookiecutter.environment}}/tofu/inventory.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ resource "local_file" "hosts" {
33
{
44
"cluster_name": var.cluster_name,
55
"cluster_domain_suffix": var.cluster_domain_suffix,
6-
"control_instances": openstack_compute_instance_v2.control
6+
"control": openstack_compute_instance_v2.control
77
"login_groups": module.login
88
"compute_groups": module.compute
99
"state_dir": var.state_dir

environments/skeleton/{{cookiecutter.environment}}/tofu/inventory.tpl

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,13 @@ all:
55

66
control:
77
hosts:
8-
%{ for control in control_instances ~}
98
${ control.name }:
10-
ansible_host: ${[for n in control.network: n.fixed_ip_v4 if n.access_network][0]}
11-
instance_id: ${ control.id }
9+
ansible_host: ${control.access_ip_v4}
10+
instance_id: ${control.id}
1211
networks: ${jsonencode({for n in control.network: n.name => {"fixed_ip_v4": n.fixed_ip_v4, "fixed_ip_v6": n.fixed_ip_v6}})}
13-
%{ endfor ~}
1412
vars:
1513
appliances_state_dir: ${state_dir} # NB needs to be set on group not host otherwise it is ignored in packer build!
1614

17-
1815
%{ for group_name in keys(login_groups) ~}
1916
${cluster_name}_${group_name}:
2017
hosts:

environments/skeleton/{{cookiecutter.environment}}/tofu/login.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ module "login" {
2525
key_pair = var.key_pair
2626
environment_root = var.environment_root
2727
k3s_token = local.k3s_token
28-
control_address = [for n in openstack_compute_instance_v2.control["control"].network: n.fixed_ip_v4 if n.access_network][0]
28+
control_address = openstack_compute_instance_v2.control.access_ip_v4
2929
security_group_ids = [for o in data.openstack_networking_secgroup_v2.login: o.id]
3030
}

environments/skeleton/{{cookiecutter.environment}}/tofu/node_group/nodes.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ resource "openstack_compute_instance_v2" "compute" {
138138
environment_root = var.environment_root
139139
k3s_token = var.k3s_token
140140
control_address = var.control_address
141+
# TODO: set k3s_subnet from access_network
141142
},
142143
{for e in var.compute_init_enable: e => true}
143144
)

0 commit comments

Comments
 (0)