@@ -7,6 +7,19 @@ data "openstack_identity_auth_scope_v3" "scope" {
7
7
name = "{{ cluster_name }}"
8
8
}
9
9
10
+ ####
11
+ #### Data resources
12
+ ####
13
+
14
+ resource "terraform_data" "k3s_token" {
15
+ input = "{{ k3s_token }}"
16
+ lifecycle {
17
+ ignore_changes = [
18
+ input,
19
+ ]
20
+ }
21
+ }
22
+
10
23
#####
11
24
##### Security groups for the cluster
12
25
#####
@@ -386,6 +399,8 @@ resource "openstack_compute_instance_v2" "login" {
386
399
ansible_init_coll_{{ loop.index0 }}_source = " {{ collection.source }}"
387
400
{% endif %}
388
401
{% endfor %}
402
+ k3s_server = [for n in openstack_compute_instance_v2.control[ " control" ].network: n.fixed_ip_v4 if n.access_network][0]
403
+ k3s_token = " {{ k3s_token }}"
389
404
}
390
405
}
391
406
@@ -397,9 +412,11 @@ resource "openstack_compute_instance_v2" "control" {
397
412
{% else %}
398
413
flavor_id = " {{ control_flavor }}"
399
414
{% endif %}
415
+ for_each = toset([ " control" ])
400
416
401
417
network {
402
418
port = openstack_networking_port_v2.control.id
419
+ access_network = true
403
420
}
404
421
405
422
{% if cluster_storage_network is defined %}
@@ -479,6 +496,7 @@ resource "openstack_compute_instance_v2" "control" {
479
496
ansible_init_coll_{{ loop.index0 }}_source = " {{ collection.source }}"
480
497
{% endif %}
481
498
{% endfor %}
499
+ k3s_token = " {{ k3s_token }}"
482
500
}
483
501
}
484
502
@@ -548,6 +566,8 @@ resource "openstack_compute_instance_v2" "{{ partition.name }}" {
548
566
ansible_init_coll_{{ loop.index0 }}_source = " {{ collection.source }}"
549
567
{% endif %}
550
568
{% endfor %}
569
+ k3s_server = [for n in openstack_compute_instance_v2.control[ " control" ].network: n.fixed_ip_v4 if n.access_network][0]
570
+ k3s_token = " {{ k3s_token }}"
551
571
}
552
572
}
553
573
0 commit comments