File tree Expand file tree Collapse file tree 4 files changed +8
-11
lines changed
environments/skeleton/{{cookiecutter.environment}}/terraform Expand file tree Collapse file tree 4 files changed +8
-11
lines changed Original file line number Diff line number Diff line change @@ -18,4 +18,5 @@ module "compute" {
18
18
k3s_token = var. k3s_token
19
19
k3s_server = [for n in openstack_compute_instance_v2 . control [" control" ]. network : n . fixed_ip_v4 if n . access_network ][0 ]
20
20
security_group_ids = [for o in data . openstack_networking_secgroup_v2 . nonlogin : o . id ]
21
+ baremetal_nodes = data. external . baremetal_nodes . result
21
22
}
Original file line number Diff line number Diff line change 1
- data "external" "nodes" {
2
- program = [" bash" , " -c" , <<- EOT
3
- openstack baremetal node list --limit 0 -f json 2>/dev/null | \
4
- jq -r 'try map( { (.Name|tostring): .UUID } ) | add catch {}' || echo '{}'
5
- EOT
6
- ]
7
- }
8
-
9
1
resource "openstack_networking_port_v2" "compute" {
10
2
11
3
for_each = toset (var. nodes )
@@ -58,7 +50,7 @@ resource "openstack_compute_instance_v2" "compute" {
58
50
k3s_server = var.k3s_server
59
51
}
60
52
61
- availability_zone = var. match_ironic_node ? " ${ var . availability_zone } ::${ data . external . nodes . result [each . key ]} " : var. availability_zone
53
+ availability_zone = var. match_ironic_node ? " ${ var . availability_zone } ::${ var . baremetal_nodes [each . key ]} " : var. availability_zone
62
54
63
55
user_data = <<- EOF
64
56
#cloud-config
Original file line number Diff line number Diff line change @@ -89,3 +89,7 @@ variable availability_zone {
89
89
type = string
90
90
default = " nova"
91
91
}
92
+
93
+ variable "baremetal_nodes" {
94
+ type = map (string )
95
+ }
Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ locals {
12
12
}
13
13
}
14
14
15
- data "external" "nodes " {
15
+ data "external" "baremetal_nodes " {
16
16
# returns an empty map if cannot list baremetal nodes
17
17
program = [" bash" , " -c" , <<- EOT
18
18
openstack baremetal node list --limit 0 -f json 2>/dev/null | \
@@ -148,7 +148,7 @@ resource "openstack_compute_instance_v2" "login" {
148
148
k3s_server = [for n in openstack_compute_instance_v2 . control [" control" ]. network : n . fixed_ip_v4 if n . access_network ][0 ]
149
149
}
150
150
151
- availability_zone = each. value . match_ironic_node ? " ${ each . value . availability_zone } ::${ data . external . nodes . result [each . key ]} " : each. value . availability_zone
151
+ availability_zone = each. value . match_ironic_node ? " ${ each . value . availability_zone } ::${ data . external . baremetal_nodes . result [each . key ]} " : each. value . availability_zone
152
152
153
153
user_data = <<- EOF
154
154
#cloud-config
You can’t perform that action at this time.
0 commit comments