Browse Source

Skip templating disabled networks

Ignore disabled networks when rendering templates.

Add's the ctlplane network to maps to ensure we don't
end up with no keys/values in map_replace functions.

Also some Jinja cleanup:
 - Reduce the number of times we iterate over networks
   where we can.
 - Add's indentation to make the code easier to read.

Related-Bug: #1809313
Depends-On: I2e8135bc9389d3bf1a6ef01e273515af5c488a9a
Change-Id: Ifeb2d2d1acb43c16a5bf29e95965776494d61fef
Harald Jensås 3 months ago
parent
commit
53027484ae

+ 2
- 2
network/networks.j2.yaml View File

@@ -8,7 +8,7 @@ parameters:
8 8
     description: Cidrs for the ctlplane network.
9 9
 
10 10
 resources:
11
-  {%- for network in networks %}
11
+  {%- for network in networks if network.enabled|default(true) %}
12 12
   {%- set network_name = network.compat_name|default(network.name) %}
13 13
   {{network_name}}Network:
14 14
     type: OS::TripleO::Network::{{network.name}}
@@ -23,7 +23,7 @@ outputs:
23 23
     value:
24 24
       # NOTE(hjensas): If a network does not have any network_cidrs, fall back
25 25
       # to the ctlplane (provisioning) network.
26
-      {%- for network in networks %}
26
+      {%- for network in networks if network.enabled|default(true) %}
27 27
       {%- set network_name = network.compat_name|default(network.name) %}
28 28
       {{network.name_lower}}:
29 29
         yaql:

+ 8
- 9
network/ports/net_ip_list_map.j2.yaml View File

@@ -4,10 +4,14 @@ parameters:
4 4
   ControlPlaneIpList:
5 5
     default: []
6 6
     type: comma_delimited_list
7
-{%- for network in networks %}
7
+{%- for network in networks if network.enabled|default(true) %}
8 8
   {{network.name}}IpList:
9 9
     default: []
10 10
     type: comma_delimited_list
11
+  {{network.name}}NetName:
12
+    default: {{network.name_lower}}
13
+    description: The name of the {{network.name_lower}} network.
14
+    type: string
11 15
 {%- endfor %}
12 16
   EnabledServices:
13 17
     default: []
@@ -21,12 +25,6 @@ parameters:
21 25
   NetworkHostnameMap:
22 26
     default: []
23 27
     type: json
24
-{%- for network in networks %}
25
-  {{network.name}}NetName:
26
-    default: {{network.name_lower}}
27
-    description: The name of the {{network.name_lower}} network.
28
-    type: string
29
-{%- endfor %}
30 28
 
31 29
 
32 30
 resources:
@@ -59,11 +57,12 @@ resources:
59 57
       value:
60 58
         map_replace:
61 59
           - ctlplane: {get_param: ControlPlaneIpList}
62
-{%- for network in networks %}
60
+{%- for network in networks if network.enabled|default(true) %}
63 61
             {{network.name_lower}}: {get_param: {{network.name}}IpList}
64 62
 {%- endfor %}
65 63
           - keys:
66
-{%- for network in networks %}
64
+              ctlplane: ctlplane  # Ensure one key is present, in case no enabled networks
65
+{%- for network in networks if network.enabled|default(true) %}
67 66
               {{network.name_lower}}: {get_param: {{network.name}}NetName}
68 67
 {%- endfor %}
69 68
 

+ 6
- 16
network/ports/net_ip_map.j2.yaml View File

@@ -10,7 +10,7 @@ parameters:
10 10
       The subnet CIDR of the control plane network. (The parameter is
11 11
       automatically resolved from the ctlplane subnet's cidr attribute.)
12 12
     type: string
13
-{%- for network in networks %}
13
+{%- for network in networks if network.enabled|default(true) %}
14 14
   {{network.name}}Ip:
15 15
     default: ''
16 16
     type: string
@@ -22,9 +22,6 @@ parameters:
22 22
     default: ''
23 23
     type: string
24 24
     description: IP address with brackets in case of IPv6
25
-{%- endfor %}
26
-
27
-{%- for network in networks %}
28 25
   {{network.name}}NetName:
29 26
     default: {{network.name_lower}}
30 27
     description: The name of the {{network.name_lower}} network.
@@ -40,34 +37,27 @@ resources:
40 37
       value:
41 38
         map_replace:
42 39
           - ctlplane: {get_param: ControlPlaneIp}
43
-{%- for network in networks %}
44
-            {{network.name_lower}}: {get_param: {{network.name}}Ip}
45
-{%- endfor %}
46 40
             ctlplane_subnet:
47 41
               list_join:
48 42
                 - ''
49 43
                 - - {get_param: ControlPlaneIp}
50 44
                   - '/'
51 45
                   - {get_param: ControlPlaneSubnetCidr}
52
-{%- for network in networks %}
53
-            {{network.name_lower}}_subnet: {get_param: {{network.name}}IpSubnet}
54
-{%- endfor %}
55 46
             ctlplane_uri: {get_param: ControlPlaneIp}
56
-{%- for network in networks %}
47
+{%- for network in networks if network.enabled|default(true) %}
48
+            {{network.name_lower}}: {get_param: {{network.name}}Ip}
49
+            {{network.name_lower}}_subnet: {get_param: {{network.name}}IpSubnet}
57 50
             {{network.name_lower}}_uri: {get_param: {{network.name}}IpUri}
58 51
 {%- endfor %}
59 52
           - keys:
60
-{%- for network in networks %}
53
+              ctlplane: ctlplane  # Ensure one key is present, in case no enabled networks
54
+{%- for network in networks if network.enabled|default(true) %}
61 55
               {{network.name_lower}}: {get_param: {{network.name}}NetName}
62
-{%- endfor %}
63
-{%- for network in networks %}
64 56
               {{network.name_lower}}_subnet:
65 57
                 str_replace:
66 58
                   template: NAME_subnet
67 59
                   params:
68 60
                     NAME: {get_param: {{network.name}}NetName}
69
-{%- endfor %}
70
-{%- for network in networks %}
71 61
               {{network.name_lower}}_uri:
72 62
                 str_replace:
73 63
                   template: NAME_uri

+ 4
- 6
network/ports/net_vip_map_external.j2.yaml View File

@@ -5,7 +5,7 @@ parameters:
5 5
   ControlPlaneIP:
6 6
     default: ''
7 7
     type: string
8
-{%- for network in networks if network.vip|default(false) %}
8
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
9 9
   {{network.name}}NetworkVip:
10 10
     default: ''
11 11
     type: string
@@ -14,7 +14,7 @@ parameters:
14 14
   ControlPlaneIp:
15 15
     default: ''
16 16
     type: string
17
-{%- for network in networks if network.vip|default(false) %}
17
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
18 18
   {{network.name}}Ip:
19 19
     default: ''
20 20
     type: string
@@ -31,10 +31,8 @@ outputs:
31 31
       for a specific machine.
32 32
     value:
33 33
       ctlplane: {get_param: ControlPlaneIP}
34
-{%- for network in networks if network.vip|default(false) %}
35
-      {{network.name_lower}}: {get_param: {{network.name}}NetworkVip}
36
-{%- endfor %}
37 34
       ctlplane_uri: {get_param: ControlPlaneIP}
38
-{%- for network in networks if network.vip|default(false) %}
35
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
36
+      {{network.name_lower}}: {get_param: {{network.name}}NetworkVip}
39 37
       {{network.name_lower}}_uri: {get_param: {{network.name}}NetworkVip}
40 38
 {%- endfor %}

+ 4
- 6
network/ports/net_vip_map_external_v6.j2.yaml View File

@@ -5,7 +5,7 @@ parameters:
5 5
   ControlPlaneIP:
6 6
     default: ''
7 7
     type: string
8
-{%- for network in networks if network.vip|default(false) %}
8
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
9 9
   {{network.name}}NetworkVip:
10 10
     default: ''
11 11
     type: string
@@ -14,7 +14,7 @@ parameters:
14 14
   ControlPlaneIp:
15 15
     default: ''
16 16
     type: string
17
-{%- for network in networks if network.vip|default(false) %}
17
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
18 18
   {{network.name}}Ip:
19 19
     default: ''
20 20
     type: string
@@ -31,11 +31,9 @@ outputs:
31 31
       for a specific machine.
32 32
     value:
33 33
       ctlplane: {get_param: ControlPlaneIP}
34
-{%- for network in networks if network.vip|default(false) %}
35
-      {{network.name_lower}}: {get_param: {{network.name}}NetworkVip}
36
-{%- endfor %}
37 34
       ctlplane_uri: {get_param: ControlPlaneIP}
38
-{%- for network in networks if network.vip|default(false) %}
35
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
36
+      {{network.name_lower}}: {get_param: {{network.name}}NetworkVip}
39 37
       {{network.name_lower}}_uri:
40 38
         list_join:
41 39
           - ''

+ 2
- 2
network/service_net_map.j2.yaml View File

@@ -149,7 +149,7 @@ parameters:
149 149
                  internal use only, this will be removed in future.
150 150
     type: json
151 151
 
152
-{%- for network in networks %}
152
+{%- for network in networks if network.enabled|default(true) %}
153 153
   {{network.name}}NetName:
154 154
     default: {{network.name_lower}}
155 155
     description: The name of the {{network.name_lower}} network.
@@ -172,7 +172,7 @@ resources:
172 172
           - map_replace:
173 173
              - {get_param: ServiceNetMapDefaults}
174 174
              - values:
175
-{%- for network in networks %}
175
+{%- for network in networks if network.enabled|default(true) %}
176 176
 {%- if network.service_net_map_replace is defined %}
177 177
                  {{network.service_net_map_replace}}: {{network.name_lower}}
178 178
 {%- else %}

+ 3
- 3
overcloud-resource-registry-puppet.j2.yaml View File

@@ -23,7 +23,7 @@ resource_registry:
23 23
   OS::TripleO::Tasks::{{role.name}}PostConfig: OS::Heat::None
24 24
   OS::TripleO::{{role.name}}ExtraConfigPre: puppet/extraconfig/pre_deploy/default.yaml
25 25
   # Port assignments for the {{role.name}} role
26
-  {%- for network in networks %}
26
+  {%- for network in networks if network.enabled|default(true) and network.name in role.networks|default([]) %}
27 27
   OS::TripleO::{{role.name}}::Ports::{{network.name}}Port: network/ports/noop.yaml
28 28
   {%- endfor %}
29 29
   OS::TripleO::{{role.name}}::Net::SoftwareConfig: net-config-noop.yaml
@@ -69,7 +69,7 @@ resource_registry:
69 69
   # TripleO overcloud networks
70 70
   OS::TripleO::Network: network/networks.yaml
71 71
 
72
-  {%- for network in networks %}
72
+  {%- for network in networks if network.enabled|default(true) %}
73 73
   OS::TripleO::Network::{{network.name}}: OS::Heat::None
74 74
   {%- endfor %}
75 75
 
@@ -80,7 +80,7 @@ resource_registry:
80 80
   OS::TripleO::Network::Ports::NetIpListMap: network/ports/net_ip_list_map.yaml
81 81
 
82 82
   # Port assignments for the VIPs
83
-  {%- for network in networks if network.vip|default(false) %}
83
+  {%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
84 84
   OS::TripleO::Network::Ports::{{network.name}}VipPort: network/ports/noop.yaml
85 85
   {%- endfor %}
86 86
 

+ 132
- 134
overcloud.j2.yaml View File

@@ -20,15 +20,22 @@ description: >
20 20
 # some order in here.
21 21
 parameters:
22 22
 
23
-  # Common parameters (not specific to a role)
24
-{%- for network in networks if network.vip|default(false) %}
25
-{%- if network.name == 'External' %}
23
+  # Common parameters (not specific to
24
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
25
+  {%- if network.name == 'External' %}
26 26
   # Special case the External hostname param, which is CloudName
27 27
   CloudName:
28 28
     default: overcloud.localdomain
29 29
     description: The DNS name of this cloud. E.g. ci-overcloud.tripleo.org
30 30
     type: string
31
-{%- elif network.name == 'InternalApi' %}
31
+  # TODO (dsneddon) Legacy name, eventually refactor to match network name
32
+  PublicVirtualFixedIPs:
33
+    default: []
34
+    description: >
35
+        Control the IP allocation for the PublicVirtualInterface port. E.g.
36
+        [{'ip_address':'1.2.3.4'}]
37
+    type: json
38
+  {%- elif network.name == 'InternalApi' %}
32 39
   # Special case the Internal API hostname param, which is CloudNameInternal
33 40
   CloudNameInternal:
34 41
     default: overcloud.{{network.name.lower()}}.localdomain
@@ -36,7 +43,7 @@ parameters:
36 43
       The DNS name of this cloud's {{network.name_lower}} endpoint. E.g.
37 44
       'ci-overcloud.{{network.name.lower()}}.tripleo.org'.
38 45
     type: string
39
-{%- elif network.name == 'StorageMgmt' %}
46
+  {%- elif network.name == 'StorageMgmt' %}
40 47
   # Special case StorageMgmt hostname param, which is CloudNameStorageManagement
41 48
   CloudNameStorageManagement:
42 49
     default: overcloud.{{network.name.lower()}}.localdomain
@@ -44,14 +51,20 @@ parameters:
44 51
       The DNS name of this cloud's {{network.name_lower}} endpoint. E.g.
45 52
       'ci-overcloud.{{network.name.lower()}}.tripleo.org'.
46 53
     type: string
47
-{%- else %}
54
+  {%- else %}
48 55
   CloudName{{network.name}}:
49 56
     default: overcloud.{{network.name.lower()}}.localdomain
50 57
     description: >
51 58
       The DNS name of this cloud's {{network.name_lower}} endpoint. E.g.
52 59
       'ci-overcloud.{{network.name.lower()}}.tripleo.org'.
53 60
     type: string
54
-{%- endif %}
61
+  {%- endif %}
62
+  {{network.name}}VirtualFixedIPs:
63
+    default: []
64
+    description: >
65
+        Control the IP allocation for the {{network.name}}VirtualInterface port. E.g.
66
+        [{'ip_address':'1.2.3.4'}]
67
+    type: json
55 68
 {%- endfor %}
56 69
   CloudNameCtlplane:
57 70
     default: overcloud.ctlplane.localdomain
@@ -72,20 +85,6 @@ parameters:
72 85
     description: |
73 86
       Additional hiera configuration to inject into the cluster.
74 87
     type: json
75
-{%- for role in roles %}
76
-  {{role.name}}ExtraConfig:
77
-    default: {}
78
-    description: |
79
-      Role specific additional hiera configuration to inject into the cluster.
80
-    type: json
81
-{%- if role.deprecated_param_extraconfig is defined %}
82
-  {{role.deprecated_param_extraconfig}}:
83
-    default: {}
84
-    description: |
85
-      DEPRECATED use {{role.name}}ExtraConfig instead
86
-    type: json
87
-{%- endif %}
88
-{%- endfor %}
89 88
   NeutronControlPlaneID:
90 89
     default: 'ctlplane'
91 90
     type: string
@@ -110,21 +109,6 @@ parameters:
110 109
         Control the IP allocation for the ControlVirtualIP port. E.g.
111 110
         [{'ip_address':'1.2.3.4'}]
112 111
     type: json
113
-  # TODO (dsneddon) Legacy name, eventually refactor to match network name
114
-  PublicVirtualFixedIPs:
115
-    default: []
116
-    description: >
117
-        Control the IP allocation for the PublicVirtualInterface port. E.g.
118
-        [{'ip_address':'1.2.3.4'}]
119
-    type: json
120
-{%- for network in networks if network.vip|default(false) and network.name != 'External' %}
121
-  {{network.name}}VirtualFixedIPs:
122
-    default: []
123
-    description: >
124
-        Control the IP allocation for the {{network.name}}VirtualInterface port. E.g.
125
-        [{'ip_address':'1.2.3.4'}]
126
-    type: json
127
-{%- endfor %}
128 112
   RabbitCookieSalt:
129 113
     type: string
130 114
     default: unset
@@ -169,6 +153,18 @@ parameters:
169 153
 
170 154
   # Jinja loop for Role in role_data.yaml
171 155
 {% for role in roles %}
156
+  {{role.name}}ExtraConfig:
157
+    default: {}
158
+    description: |
159
+      Role specific additional hiera configuration to inject into the cluster.
160
+    type: json
161
+  {%- if role.deprecated_param_extraconfig is defined %}
162
+  {{role.deprecated_param_extraconfig}}:
163
+    default: {}
164
+    description: |
165
+      DEPRECATED use {{role.name}}ExtraConfig instead
166
+    type: json
167
+  {%- endif %}
172 168
   # Parameters generated for {{role.name}} Role
173 169
   {{role.name}}Services:
174 170
     description: A list of service resources (configured in the Heat
@@ -298,35 +294,35 @@ resources:
298 294
               params:
299 295
                 IP: {get_attr: [VipMap, net_ip_map, ctlplane]}
300 296
                 HOST: {get_param: CloudNameCtlplane}
301
-{%- for network in networks if network.vip|default(false) %}
302
-{%- if network.name == 'External' %}
297
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
298
+  {%- if network.name == 'External' %}
303 299
   # Special case the External hostname param, which is CloudName
304 300
           - str_replace:
305 301
               template: IP  HOST
306 302
               params:
307 303
                 IP: {get_attr: [VipMap, net_ip_map, {{network.name_lower}}]}
308 304
                 HOST: {get_param: CloudName}
309
-{%- elif network.name == 'InternalApi' %}
305
+  {%- elif network.name == 'InternalApi' %}
310 306
   # Special case the Internal API hostname param, which is CloudNameInternal
311 307
           - str_replace:
312 308
               template: IP  HOST
313 309
               params:
314 310
                 IP: {get_attr: [VipMap, net_ip_map, {{network.name_lower}}]}
315 311
                 HOST: {get_param: CloudNameInternal}
316
-{%- elif network.name == 'StorageMgmt' %}
312
+  {%- elif network.name == 'StorageMgmt' %}
317 313
   # Special case StorageMgmt hostname param, which is CloudNameStorageManagement
318 314
           - str_replace:
319 315
               template: IP  HOST
320 316
               params:
321 317
                 IP: {get_attr: [VipMap, net_ip_map, {{network.name_lower}}]}
322 318
                 HOST: {get_param: CloudNameStorageManagement}
323
-{%- else %}
319
+  {%- else %}
324 320
           - str_replace:
325 321
               template: IP  HOST
326 322
               params:
327 323
                 IP: {get_attr: [VipMap, net_ip_map, {{network.name_lower}}]}
328 324
                 HOST: {get_param: CloudName{{network.name}}}
329
-{%- endif %}
325
+  {%- endif %}
330 326
 {%- endfor %}
331 327
 
332 328
   HeatAuthEncryptionKey:
@@ -364,19 +360,19 @@ resources:
364 360
     properties:
365 361
       CloudEndpoints:
366 362
         ctlplane: {get_param: CloudNameCtlplane}
367
-{%- for network in networks if network.vip|default(false) %}
368
-{%- if network.name == 'External' %}
363
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
364
+  {%- if network.name == 'External' %}
369 365
   # Special case the External hostname param, which is CloudName
370 366
         {{network.name_lower}}: {get_param: CloudName}
371
-{%- elif network.name == 'InternalApi' %}
367
+  {%- elif network.name == 'InternalApi' %}
372 368
   # Special case the Internal API hostname param, which is CloudNameInternal
373 369
         {{network.name_lower}}: {get_param: CloudNameInternal}
374
-{%- elif network.name == 'StorageMgmt' %}
370
+  {%- elif network.name == 'StorageMgmt' %}
375 371
   # Special case StorageMgmt hostname param, which is CloudNameStorageManagement
376 372
         {{network.name_lower}}: {get_param: CloudNameStorageManagement}
377
-{%- else %}
373
+  {%- else %}
378 374
         {{network.name_lower}}: {get_param: CloudName{{network.name}}}
379
-{%- endif %}
375
+  {%- endif %}
380 376
 {%- endfor %}
381 377
       NetIpMap: {get_attr: [VipMap, net_ip_map]}
382 378
       ServiceNetMap: {get_attr: [ServiceNetMap, service_net_map]}
@@ -485,9 +481,9 @@ resources:
485 481
           map_merge:
486 482
           - get_attr: [{{role.name}}ServiceConfigSettings, value]
487 483
           - get_param: ExtraConfig
488
-{%- if role.deprecated_param_extraconfig is defined %}
484
+  {%- if role.deprecated_param_extraconfig is defined %}
489 485
           - get_param: {{role.deprecated_param_extraconfig}}
490
-{%- endif %}
486
+  {%- endif %}
491 487
           - get_param: {{role.name}}ExtraConfig
492 488
 
493 489
   # Filter any null/None service_names which may be present due to mapping
@@ -519,10 +515,10 @@ resources:
519 515
   {{role.name}}AllNodesDeployment:
520 516
     type: OS::TripleO::AllNodesDeployment
521 517
     depends_on:
522
-{% for role_inner in roles %}
518
+{%- for role_inner in roles %}
523 519
       - {{role_inner.name}}HostsDeployment
524 520
       - {{role_inner.name}}SshKnownHostsDeployment
525
-{% endfor %}
521
+{%- endfor %}
526 522
     properties:
527 523
       name: {{role.name}}AllNodesDeployment
528 524
       config: {get_attr: [allNodesConfig, config_id]}
@@ -550,13 +546,13 @@ resources:
550 546
     type: OS::TripleO::Network::Ports::NetIpListMap
551 547
     properties:
552 548
       ControlPlaneIpList: {get_attr: [{{role.name}}, ip_address]}
553
-{%- for network in networks %}
554
-  {%- if network.enabled|default(true) and network.name in role.networks|default([]) %}
549
+  {%- for network in networks %}
550
+    {%- if network.enabled|default(true) and network.name in role.networks|default([]) %}
555 551
       {{network.name}}IpList: {get_attr: [{{role.name}}, {{network.name_lower}}_ip_address]}
556
-  {%- else %}
552
+    {%- else %}
557 553
       {{network.name}}IpList: {get_attr: [{{role.name}}, ip_address]}
558
-  {%- endif %}
559
-{%- endfor %}
554
+    {%- endif %}
555
+  {%- endfor %}
560 556
       EnabledServices: {get_attr: [{{role.name}}ServiceNames, value]}
561 557
       ServiceNetMap: {get_attr: [ServiceNetMap, service_net_map_lower]}
562 558
       ServiceHostnameList: {get_attr: [{{role.name}}, hostname]}
@@ -618,9 +614,9 @@ resources:
618 614
           # nested template, as it can contain %index%
619 615
           {{role.name}}SchedulerHints:
620 616
             map_merge:
621
-{%- if role.deprecated_param_scheduler_hints is defined %}
617
+  {%- if role.deprecated_param_scheduler_hints is defined %}
622 618
               - {get_param: {{role.deprecated_param_scheduler_hints}}}
623
-{%- endif %}
619
+  {%- endif %}
624 620
               - {get_param: {{role.name}}SchedulerHints}
625 621
           ServiceConfigSettings: {get_attr: [{{role.name}}ServiceConfigSettings, value]}
626 622
           ServiceNames: {get_attr: [{{role.name}}ServiceNames, value]}
@@ -632,9 +628,9 @@ resources:
632 628
               - {{role.RoleParametersDefault|default({})}}
633 629
               - get_param: {{role.name}}Parameters
634 630
           UserData: {get_resource: {{role.name}}UserData}
635
-{% endfor %}
631
+{%- endfor %}
636 632
 
637
-{% for role in roles %}
633
+{%- for role in roles %}
638 634
   {{role.name}}Servers:
639 635
     type: OS::Heat::Value
640 636
     depends_on: {{role.name}}
@@ -645,7 +641,7 @@ resources:
645 641
           expression: let(servers=>switch(isDict($.data.servers) => $.data.servers, true => {})) -> $servers.deleteAll($servers.keys().where($servers[$] = null))
646 642
           data:
647 643
             servers: {get_attr: [{{role.name}}, attributes, nova_server_resource]}
648
-{% endfor %}
644
+{%- endfor %}
649 645
 
650 646
   # This is a different format to *Servers, as it creates a map of lists
651 647
   # whereas *Servers creates a map of maps with keys of the nested resource names
@@ -654,9 +650,9 @@ resources:
654 650
     properties:
655 651
       value:
656 652
         server_ids:
657
-{% for role in roles %}
653
+{%- for role in roles %}
658 654
           {{role.name}}: {get_attr: [{{role.name}}, nova_server_resource]}
659
-{% endfor %}
655
+{%- endfor %}
660 656
         bootstrap_server_id:
661 657
           yaql:
662 658
             expression: coalesce($.data, []).first(null)
@@ -690,37 +686,37 @@ resources:
690 686
             - {get_attr: [VipHosts, value]}
691 687
             - ''
692 688
         -
693
-{% for role in roles %}
689
+{%- for role in roles %}
694 690
           - list_join:
695 691
             - ""
696 692
             - {get_attr: [{{role.name}}, hosts_entry]}
697
-{% endfor %}
693
+{%- endfor %}
698 694
         - {get_param: ExtraHostFileEntries}
699 695
 
700 696
   allNodesConfig:
701 697
     type: OS::TripleO::AllNodes::SoftwareConfig
702 698
     properties:
703
-{%- for network in networks if network.vip|default(false) %}
704
-{%- if network.name == 'External' %}
699
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
700
+  {%- if network.name == 'External' %}
705 701
   # Special case the External hostname param, which is CloudName
706 702
       cloud_name_{{network.name_lower}}: {get_param: CloudName}
707
-{%- elif network.name == 'InternalApi' %}
703
+  {%- elif network.name == 'InternalApi' %}
708 704
   # Special case the Internal API hostname param, which is CloudNameInternal
709 705
       cloud_name_{{network.name_lower}}: {get_param: CloudNameInternal}
710
-{%- elif network.name == 'StorageMgmt' %}
706
+  {%- elif network.name == 'StorageMgmt' %}
711 707
   # Special case StorageMgmt hostname param, which is CloudNameStorageManagement
712 708
       cloud_name_{{network.name_lower}}: {get_param: CloudNameStorageManagement}
713
-{%- else %}
709
+  {%- else %}
714 710
       cloud_name_{{network.name_lower}}: {get_param: CloudName{{network.name}}}
715
-{%- endif %}
711
+  {%- endif %}
716 712
 {%- endfor %}
717 713
       cloud_name_ctlplane: {get_param: CloudNameCtlplane}
718 714
       enabled_services:
719 715
         list_join:
720 716
           - ','
721
-{% for role in roles %}
717
+{%- for role in roles %}
722 718
           - {get_attr: [{{role.name}}ServiceNames, value]}
723
-{% endfor %}
719
+{%- endfor %}
724 720
       controller_ips: {get_attr: [{{primary_role_name}}, ip_address]}
725 721
       controller_names: {get_attr: [{{primary_role_name}}, hostname]}
726 722
       service_ips:
@@ -732,41 +728,41 @@ resources:
732 728
           expression: dict($.data.l.where($ != null).selectMany($.items()).groupBy($[0], $[1]).select([$[0], $[1].flatten()]))
733 729
           data:
734 730
             l:
735
-{% for role in roles %}
731
+{%- for role in roles %}
736 732
               - {get_attr: [{{role.name}}IpListMap, service_ips]}
737
-{% endfor %}
733
+{%- endfor %}
738 734
       service_node_names:
739 735
         yaql:
740 736
           expression: dict($.data.l.where($ != null).selectMany($.items()).groupBy($[0], $[1]).select([$[0], $[1].flatten()]))
741 737
           data:
742 738
             l:
743
-{% for role in roles %}
739
+{%- for role in roles %}
744 740
               - {get_attr: [{{role.name}}IpListMap, service_hostnames]}
745
-{% endfor %}
741
+{%- endfor %}
746 742
       short_service_node_names:
747 743
         yaql:
748 744
           expression: dict($.data.l.where($ != null).selectMany($.items()).groupBy($[0], $[1]).select([$[0], $[1].flatten()]))
749 745
           data:
750 746
             l:
751
-{% for role in roles %}
747
+{%- for role in roles %}
752 748
               - {get_attr: [{{role.name}}IpListMap, short_service_hostnames]}
753
-{% endfor %}
749
+{%- endfor %}
754 750
       short_service_bootstrap_node:
755 751
         yaql:
756 752
           expression: dict($.data.l.where($ != null).selectMany($.items()).groupBy($[0], $[1]).select([$[0], $[1].flatten().first()]))
757 753
           data:
758 754
             l:
759
-{% for role in roles %}
755
+{%- for role in roles %}
760 756
               - {get_attr: [{{role.name}}IpListMap, short_service_bootstrap_hostnames]}
761
-{% endfor %}
757
+{%- endfor %}
762 758
       service_bootstrap_node_ip:
763 759
         yaql:
764 760
           expression: dict($.data.l.where($ != null).selectMany($.items()).groupBy($[0], $[1]).select([$[0], $[1].flatten().first(null)]))
765 761
           data:
766 762
             l:
767
-{% for role in roles %}
763
+{%- for role in roles %}
768 764
               - {get_attr: [{{role.name}}IpListMap, service_bootstrap_ips]}
769
-{% endfor %}
765
+{%- endfor %}
770 766
       NetVipMap: {get_attr: [VipMap, net_ip_map]}
771 767
       RedisVirtualIP: {get_attr: [RedisVirtualIP, ip_address]}
772 768
       ServiceNetMap: {get_attr: [ServiceNetMap, service_net_map_lower]}
@@ -832,8 +828,8 @@ resources:
832 828
         - {get_param: RedisVirtualFixedIPs}
833 829
         - [{subnet: {get_attr: [ServiceNetMap, vip_subnet_map, redis]}}]
834 830
 
835
-{%- for network in networks if network.vip|default(false) %}
836
-{%- if network.name == 'External' %}
831
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
832
+  {%- if network.name == 'External' %}
837 833
   # The public VIP is on the External net, falls back to ctlplane
838 834
   PublicVirtualIP:
839 835
     depends_on: [Networks, ServiceNetMap]
@@ -852,7 +848,7 @@ resources:
852 848
         - public_virtual_fixed_ip_set
853 849
         - {get_param: PublicVirtualFixedIPs}
854 850
         - [{subnet: {get_attr: [ServiceNetMap, vip_subnet_map, {{network.name}}]}}]
855
-{%- else %}
851
+  {%- else %}
856 852
   {{network.name}}VirtualIP:
857 853
     depends_on: [Networks, ServiceNetMap]
858 854
     type: OS::TripleO::Network::Ports::{{network.name}}VipPort
@@ -869,7 +865,7 @@ resources:
869 865
         - {{network.name_lower}}_virtual_fixed_ip_set
870 866
         - {get_param: {{network.name}}VirtualFixedIPs}
871 867
         - [{subnet: {get_attr: [ServiceNetMap, vip_subnet_map, {{network.name}}]}}]
872
-{%- endif %}
868
+  {% endif %}
873 869
 {%- endfor %}
874 870
 
875 871
   VipMap:
@@ -881,14 +877,14 @@ resources:
881 877
           - ctlplane_subnet_cidr_set
882 878
           - {get_param: ControlPlaneSubnetCidr}
883 879
           - {str_split: ['/', {get_attr: [ControlVirtualIP, subnets, 0, cidr]}, 1]}
884
-{%- for network in networks if network.vip|default(false) %}
885
-{%- if network.name == 'External' %}
880
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
881
+  {%- if network.name == 'External' %}
886 882
       ExternalIp: {get_attr: [PublicVirtualIP, ip_address]}
887 883
       ExternalIpUri: {get_attr: [PublicVirtualIP, ip_address_uri]}
888
-{%- else %}
884
+  {%- else %}
889 885
       {{network.name}}Ip: {get_attr: [{{network.name}}VirtualIP, ip_address]}
890 886
       {{network.name}}IpUri: {get_attr: [{{network.name}}VirtualIP, ip_address_uri]}
891
-{%- endif %}
887
+  {%- endif %}
892 888
 {%- endfor %}
893 889
       # No tenant or management VIP required
894 890
     # Because of nested get_attr functions in the KeystoneAdminVip output, we
@@ -896,22 +892,24 @@ resources:
896 892
     # ServiceNetMap's attribute values are available.
897 893
     depends_on: ServiceNetMap
898 894
 
899
-{%- for role in roles %}
900 895
   # All Nodes Validations
896
+{%- for role in roles %}
901 897
   {{role.name}}AllNodesValidationConfig:
902 898
     type: OS::TripleO::AllNodes::Validation
903 899
     properties:
904 900
       PingTestIps:
905 901
         list_join:
906 902
         - ' '
907
-        -
908
-{%- for network in networks %}
909
-  {%- if network.enabled|default(true) and network.name in role.networks|default([]) %}
903
+        - - yaql:
904
+              expression: coalesce($.data, []).first(null)
905
+              data: {get_attr: [{{primary_role_name}}, ip_address]}
906
+  {%- for network in networks %}
907
+    {%- if network.enabled|default(true) and network.name in role.networks|default([]) %}
910 908
           - yaql:
911 909
               expression: coalesce($.data, []).first(null)
912 910
               data: {get_attr: [{{primary_role_name}}, {{network.name_lower}}_ip_address]}
913
-  {%- endif %}
914
-{%- endfor %}
911
+    {%- endif %}
912
+  {%- endfor %}
915 913
 {%- endfor %}
916 914
 
917 915
   # Optional ExtraConfig for all nodes - all roles are passed in here, but
@@ -919,46 +917,46 @@ resources:
919 917
   AllNodesExtraConfig:
920 918
     type: OS::TripleO::AllNodesExtraConfig
921 919
     depends_on:
922
-{% for role in roles %}
920
+{%- for role in roles %}
923 921
       - {{role.name}}AllNodesValidationDeployment
924
-{% endfor %}
922
+{%- endfor %}
925 923
     properties:
926 924
       servers:
927
-{% for role in roles %}
925
+{%- for role in roles %}
928 926
         {{role.name}}: {get_attr: [{{role.name}}Servers, value]}
929
-{% endfor %}
927
+{%- endfor %}
930 928
 
931 929
   BlacklistedIpAddresses:
932 930
     type: OS::Heat::Value
933 931
     properties:
934 932
       value:
935 933
         list_concat:
936
-{% for role in roles %}
934
+{%- for role in roles %}
937 935
           - {get_attr: [{{role.name}}, blacklist_ip_address]}
938
-{% endfor %}
936
+{%- endfor %}
939 937
 
940 938
   BlacklistedHostnames:
941 939
     type: OS::Heat::Value
942 940
     properties:
943 941
       value:
944 942
         list_concat:
945
-{% for role in roles %}
943
+{%- for role in roles %}
946 944
           - {get_attr: [{{role.name}}, blacklist_hostname]}
947
-{% endfor %}
945
+{%- endfor %}
948 946
 
949 947
   # Post deployment steps for all roles
950 948
   AllNodesDeploySteps:
951 949
     type: OS::TripleO::PostDeploySteps
952 950
     depends_on:
953 951
       - AllNodesExtraConfig
954
-{% for role in roles %}
952
+{%- for role in roles %}
955 953
       - {{role.name}}AllNodesDeployment
956
-{% endfor %}
954
+{%- endfor %}
957 955
     properties:
958 956
       servers:
959
-{% for role in roles %}
957
+{%- for role in roles %}
960 958
         {{role.name}}: {get_attr: [{{role.name}}Servers, value]}
961
-{% endfor %}
959
+{%- endfor %}
962 960
       stack_name: {get_param: 'OS::stack_name'}
963 961
       EndpointMap: {get_attr: [EndpointMapData, value]}
964 962
       ctlplane_service_ips:
@@ -970,39 +968,39 @@ resources:
970 968
           expression: dict($.data.l.where($ != null).selectMany($.items()).groupBy($[0], $[1]).select([$[0], $[1].flatten()]))
971 969
           data:
972 970
             l:
973
-{% for role in roles %}
971
+{%- for role in roles %}
974 972
               - {get_attr: [{{role.name}}IpListMap, ctlplane_service_ips]}
975
-{% endfor %}
973
+{%- endfor %}
976 974
       role_data:
977
-{% for role in roles %}
975
+{%- for role in roles %}
978 976
         {{role.name}}:
979 977
           map_merge:
980 978
           - {get_attr: [{{role.name}}ServiceChainRoleData, value]}
981 979
           - {get_attr: [{{role.name}}MergedConfigSettings, value]}
982
-{% endfor %}
980
+{%- endfor %}
983 981
       blacklisted_ip_addresses: {get_attr: [BlacklistedIpAddresses, value]}
984 982
       blacklisted_hostnames: {get_attr: [BlacklistedHostnames, value]}
985 983
       ssh_known_hosts_hostnames: {get_attr: [SshKnownHostsHostnames, value]}
986
-{% for role in roles %}
984
+{%- for role in roles %}
987 985
       {{role.name}}Count: {get_param: {{role.name}}Count}
988
-{% endfor %}
986
+{%- endfor %}
989 987
 
990 988
   ServerOsCollectConfigData:
991 989
     type: OS::Heat::Value
992 990
     properties:
993 991
       type: json
994 992
       value:
995
-{% for role in roles %}
993
+{%- for role in roles %}
996 994
         {{role.name}}: {get_attr: [{{role.name}}, attributes, os_collect_config]}
997
-{% endfor %}
995
+{%- endfor %}
998 996
 
999 997
   DeployedServerEnvironment:
1000 998
     type: OS::TripleO::DeployedServerEnvironment
1001 999
     properties:
1002 1000
       RoleCounts:
1003
-{% for role in roles %}
1001
+{%- for role in roles %}
1004 1002
         {{role.name}}DeployedServerCount: {get_param: {{role.name}}Count}
1005
-{% endfor %}
1003
+{%- endfor %}
1006 1004
       VipMap:
1007 1005
         map_merge:
1008 1006
           - {get_attr: [VipMap, net_ip_map]}
@@ -1010,15 +1008,15 @@ resources:
1010 1008
       DeployedServerPortMap:
1011 1009
         map_merge:
1012 1010
           list_concat:
1013
-{% for role in roles %}
1011
+{%- for role in roles %}
1014 1012
               - {get_attr: [{{role.name}}, deployed_server_port_map]}
1015
-{% endfor %}
1013
+{%- endfor %}
1016 1014
       DeployedServerDeploymentSwiftDataMap:
1017 1015
         map_merge:
1018 1016
           list_concat:
1019
-{% for role in roles %}
1017
+{%- for role in roles %}
1020 1018
               - {get_attr: [{{role.name}}, deployed_server_deployment_swift_data_map]}
1021
-{% endfor %}
1019
+{%- endfor %}
1022 1020
       DefaultRouteIp:
1023 1021
         str_split:
1024 1022
           - ':'
@@ -1062,40 +1060,40 @@ outputs:
1062 1060
   EnabledServices:
1063 1061
     description: The services enabled on each role
1064 1062
     value:
1065
-{% for role in roles %}
1063
+{%- for role in roles %}
1066 1064
       {{role.name}}: {get_attr: [{{role.name}}ServiceNames, value]}
1067
-{% endfor %}
1065
+{%- endfor %}
1068 1066
   RoleData:
1069 1067
     description: The configuration data associated with each role
1070 1068
     value:
1071
-{% for role in roles %}
1069
+{%- for role in roles %}
1072 1070
       {{role.name}}:
1073 1071
         map_merge:
1074 1072
         - {get_attr: [{{role.name}}ServiceChainRoleData, value]}
1075 1073
         - {get_attr: [{{role.name}}MergedConfigSettings, value]}
1076
-{% endfor %}
1074
+{%- endfor %}
1077 1075
   RoleConfig:
1078 1076
     description: The configuration workflows associated with each role
1079 1077
     value: {get_attr: [AllNodesDeploySteps, RoleConfig]}
1080 1078
   RoleNetIpMap:
1081 1079
     description: Mapping of each network to a list of IPs for each role
1082 1080
     value:
1083
-{% for role in roles %}
1081
+{%- for role in roles %}
1084 1082
       {{role.name}}: {get_attr: [{{role.name}}IpListMap, net_ip_map]}
1085
-{% endfor %}
1083
+{%- endfor %}
1086 1084
   RoleGroupVars:
1087 1085
     description: Mapping of roles to ansible group_vars to be applied config in those roles
1088 1086
     value:
1089
-{% for role in roles %}
1087
+{%- for role in roles %}
1090 1088
       {{role.name}}:
1091 1089
         map_merge: {get_attr: [{{role.name}}, role_group_vars]}
1092
-{% endfor %}
1090
+{%- endfor %}
1093 1091
   RoleNetHostnameMap:
1094 1092
     description: Mapping of each network to a list of hostnames for each role
1095 1093
     value:
1096
-{% for role in roles %}
1094
+{%- for role in roles %}
1097 1095
       {{role.name}}: {get_attr: [{{role.name}}NetworkHostnameMap, value]}
1098
-{% endfor %}
1096
+{%- endfor %}
1099 1097
   RoleTags:
1100 1098
     description: Tags for each role, as defined in roles_data.yaml
1101 1099
     value:

+ 9
- 6
puppet/all-nodes-config.j2.yaml View File

@@ -1,5 +1,5 @@
1 1
 {%- set _networks = [] -%}
2
-{%- for network in networks -%}
2
+{%- for network in networks if network.enabled|default(true) -%}
3 3
   {%- set _networks = _networks.append(network.name) -%}
4 4
 {%- endfor -%}
5 5
 heat_template_version: rocky
@@ -70,7 +70,7 @@ parameters:
70 70
     default: {}
71 71
     description: Map of extra data (hieradata) to set on each node.
72 72
 
73
-{%- for network in networks %}
73
+{%- for network in networks if network.enabled|default(true) %}
74 74
   {{network.name}}NetName:
75 75
     default: {{network.name_lower}}
76 76
     description: The name of the {{network.name_lower}} network.
@@ -205,17 +205,20 @@ resources:
205 205
                 internal_api_virtual_ip: {get_param: [NetVipMap, {get_param: InternalApiNetName}]}
206 206
 {%- endif %}
207 207
                 network_virtual_ips:
208
-{%- for network in networks if network.vip|default(false) %}
208
+                  ctlplane:
209
+                    ip_address: {get_param: [NetVipMap, ctlplane]}
210
+                    index: 1
211
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
209 212
 # External virtual ip is currently being handled separately as public_virtual_ip.
210 213
 # Likewise, optional StorageNFS virtual ip is handled separately as ganesha_vip.
211 214
 {%- if network.name != 'External' and network.name != 'StorageNFS' %}
212 215
                   {{network.name_lower}}:
213 216
                     ip_address: {get_param: [NetVipMap, {get_param: {{network.name}}NetName}]}
214
-                    index: {{loop.index}}
217
+                    index: {{loop.index + 1}}
215 218
 {%- endif %}
216 219
 {%- endfor %}
217 220
                 redis_vip: {get_param: RedisVirtualIP}
218
-{%- for network in networks if network.name == 'StorageNFS' %}
221
+{%- for network in networks if network.name == 'StorageNFS' and network.enabled|default(true) %}
219 222
                 ganesha_vip: {get_param: [NetVipMap, {get_param: StorageNFSNetName}]}
220 223
 {%- endfor %}
221 224
                 # public_virtual_ip and controller_virtual_ip are needed in
@@ -231,7 +234,7 @@ resources:
231 234
                 tripleo::keepalived::controller_virtual_ip: {get_param: [NetVipMap, ctlplane]}
232 235
                 tripleo::keepalived::redis_virtual_ip: {get_param: RedisVirtualIP}
233 236
                 tripleo::redis_notification::haproxy_monitor_ip: {get_param: [NetVipMap, ctlplane]}
234
-{%- for network in networks if network.vip|default(false) %}
237
+{%- for network in networks if network.vip|default(false) and network.enabled|default(true) %}
235 238
                 cloud_name_{{network.name_lower}}: {get_param: cloud_name_{{network.name_lower}}}
236 239
 {%- endfor %}
237 240
                 cloud_name_ctlplane: {get_param: cloud_name_ctlplane}

+ 1
- 1
puppet/services/apache.j2.yaml View File

@@ -62,7 +62,7 @@ resources:
62 62
         # certificates for those. We skip the tenant network since
63 63
         # we don't need a certificate for that.
64 64
         - ctlplane
65
-{%- for network in networks %}
65
+{%- for network in networks if network.enabled|default(true) %}
66 66
   {%- if network.name_lower != 'tenant' %}
67 67
         - {{network.name_lower}}
68 68
   {%- endif %}

+ 2
- 0
tools/process-templates.py View File

@@ -110,6 +110,8 @@ def process_templates(template_path, role_data_path, output_dir,
110 110
 
111 111
     with open(network_data_path) as network_data_file:
112 112
         network_data = yaml.safe_load(network_data_file)
113
+        if network_data is None:
114
+            network_data = []
113 115
 
114 116
     j2_excludes = {}
115 117
     j2_excludes_path = os.path.join(template_path, 'j2_excludes.yaml')

Loading…
Cancel
Save