Merge "Fix ironic-pxe startup issues"
[apex-tripleo-heat-templates.git] / puppet / role.role.j2.yaml
1 heat_template_version: pike
2 description: 'OpenStack {{role.name}} node configured by Puppet'
3 parameters:
4   Overcloud{{role.name}}Flavor:
5     description: Flavor for the {{role.name}} node.
6     default: baremetal
7     type: string
8 {% if role.disable_constraints is not defined %}
9     constraints:
10       - custom_constraint: nova.flavor
11 {% endif %}
12   {{role.name}}Image:
13     type: string
14     default: overcloud-full
15 {% if role.disable_constraints is not defined %}
16     constraints:
17       - custom_constraint: glance.image
18 {% endif %}
19   ImageUpdatePolicy:
20     default: 'REBUILD_PRESERVE_EPHEMERAL'
21     description: What policy to use when reconstructing instances. REBUILD for rebuilds, REBUILD_PRESERVE_EPHEMERAL to preserve /mnt.
22     type: string
23   KeyName:
24     description: Name of an existing Nova key pair to enable SSH access to the instances
25     type: string
26     default: default
27 {% if role.disable_constraints is not defined %}
28     constraints:
29       - custom_constraint: nova.keypair
30 {% endif %}
31   NeutronPhysicalBridge:
32     default: 'br-ex'
33     description: An OVS bridge to create for accessing tenant networks.
34     type: string
35   NeutronPublicInterface:
36     default: nic1
37     description: Which interface to add to the NeutronPhysicalBridge.
38     type: string
39   ServiceNetMap:
40     default: {}
41     description: Mapping of service_name -> network name. Typically set
42                  via parameter_defaults in the resource registry.
43     type: json
44   EndpointMap:
45     default: {}
46     description: Mapping of service endpoint -> protocol. Typically set
47                  via parameter_defaults in the resource registry.
48     type: json
49   UpdateIdentifier:
50     default: ''
51     type: string
52     description: >
53       Setting to a previously unused value during stack-update will trigger
54       package update on all nodes
55   Hostname:
56     type: string
57     default: '' # Defaults to Heat created hostname
58   HostnameMap:
59     type: json
60     default: {}
61     description: Optional mapping to override hostnames
62   ExtraConfig:
63     default: {}
64     description: |
65       Additional hiera configuration to inject into the cluster. Note
66       that {{role.name}}ExtraConfig takes precedence over ExtraConfig.
67     type: json
68   {{role.name}}ExtraConfig:
69     default: {}
70     description: |
71       Role specific additional hiera configuration to inject into the cluster.
72     type: json
73   {{role.name}}IPs:
74     default: {}
75     type: json
76   NetworkDeploymentActions:
77     type: comma_delimited_list
78     description: >
79       Heat action when to apply network configuration changes
80     default: ['CREATE']
81   SoftwareConfigTransport:
82     default: POLL_SERVER_CFN
83     description: |
84       How the server should receive the metadata required for software configuration.
85     type: string
86     constraints:
87     - allowed_values: [POLL_SERVER_CFN, POLL_SERVER_HEAT, POLL_TEMP_URL, ZAQAR_MESSAGE]
88   CloudDomain:
89     default: 'localdomain'
90     type: string
91     description: >
92       The DNS domain used for the hosts. This must match the
93       overcloud_domain_name configured on the undercloud.
94   {{role.name}}ServerMetadata:
95     default: {}
96     description: >
97       Extra properties or metadata passed to Nova for the created nodes in
98       the overcloud. It's accessible via the Nova metadata API. This option is
99       role-specific and is merged with the values given to the ServerMetadata
100       parameter.
101     type: json
102   ServerMetadata:
103     default: {}
104     description: >
105       Extra properties or metadata passed to Nova for the created nodes in
106       the overcloud. It's accessible via the Nova metadata API. This applies to
107       all roles and is merged with a role-specific metadata parameter.
108     type: json
109   {{role.name}}SchedulerHints:
110     type: json
111     description: Optional scheduler hints to pass to nova
112     default: {}
113   NodeIndex:
114     type: number
115     default: 0
116   ServiceConfigSettings:
117     type: json
118     default: {}
119   ServiceNames:
120     type: comma_delimited_list
121     default: []
122   MonitoringSubscriptions:
123     type: comma_delimited_list
124     default: []
125   ServiceMetadataSettings:
126     type: json
127     default: {}
128   ConfigCommand:
129     type: string
130     description: Command which will be run whenever configuration data changes
131     default: os-refresh-config --timeout 14400
132   ConfigCollectSplay:
133     type: number
134     default: 30
135     description: |
136       Maximum amount of time to possibly to delay configuation collection
137       polling. Defaults to 30 seconds. Set to 0 to disable it which will cause
138       the configuration collection to occur as soon as the collection process
139       starts.  This setting is used to prevent the configuration collection
140       processes from polling all at the exact same time.
141   LoggingSources:
142     type: json
143     default: []
144   LoggingGroups:
145     type: comma_delimited_list
146     default: []
147   UpgradeInitCommand:
148     type: string
149     description: |
150       Command or script snippet to run on all overcloud nodes to
151       initialize the upgrade process. E.g. a repository switch.
152     default: ''
153   UpgradeInitCommonCommand:
154     type: string
155     description: |
156       Common commands required by the upgrades process. This should not
157       normally be modified by the operator and is set and unset in the
158       major-upgrade-composable-steps.yaml and major-upgrade-converge.yaml
159       environment files.
160     default: ''
161   DeploymentServerBlacklistDict:
162     default: {}
163     type: json
164     description: >
165       Map of server hostnames to blacklist from any triggered
166       deployments. If the value is 1, the server will be blacklisted. This
167       parameter is generated from the parent template.
168   RoleParameters:
169     type: json
170     description: Role Specific Parameters
171     default: {}
172   DeploymentSwiftDataMap:
173     type: json
174     description: |
175       Map of servers to Swift container and object for storing deployment data.
176       The keys are the Heat assigned hostnames, and the value is a map of the
177       container/object name in Swift. Example value:
178         overcloud-controller-0:
179           container: overcloud-controller
180           object: 0
181         overcloud-controller-1:
182           container: overcloud-controller
183           object: 1
184         overcloud-controller-2:
185           container: overcloud-controller
186           object: 2
187         overcloud-novacompute-0:
188           container: overcloud-compute
189           object: 0
190     default: {}
191
192 conditions:
193   server_not_blacklisted:
194     not:
195       equals:
196         - {get_param: [DeploymentServerBlacklistDict, {get_param: Hostname}]}
197         - 1
198   deployment_swift_data_map_unset:
199     equals:
200       - get_param:
201           - DeploymentSwiftDataMap
202           - {get_param: Hostname}
203       - ""
204
205 resources:
206   {{role.name}}:
207     type: OS::TripleO::{{role.name}}Server
208     metadata:
209       os-collect-config:
210         command: {get_param: ConfigCommand}
211         splay: {get_param: ConfigCollectSplay}
212     properties:
213       image: {get_param: {{role.name}}Image}
214       image_update_policy: {get_param: ImageUpdatePolicy}
215       flavor: {get_param: Overcloud{{role.name}}Flavor}
216       key_name: {get_param: KeyName}
217       networks:
218         - network: ctlplane
219       user_data_format: SOFTWARE_CONFIG
220       user_data: {get_resource: UserData}
221       name:
222         str_replace:
223             template: {get_param: Hostname}
224             params: {get_param: HostnameMap}
225       software_config_transport: {get_param: SoftwareConfigTransport}
226       metadata:
227         map_merge:
228           - {get_param: ServerMetadata}
229           - {get_param: {{role.name}}ServerMetadata}
230           - {get_param: ServiceMetadataSettings}
231       scheduler_hints: {get_param: {{role.name}}SchedulerHints}
232       deployment_swift_data:
233         if:
234           - deployment_swift_data_map_unset
235           - {}
236           - {get_param: [DeploymentSwiftDataMap,
237                          {get_param: Hostname}]}
238
239   # Combine the NodeAdminUserData and NodeUserData mime archives
240   UserData:
241     type: OS::Heat::MultipartMime
242     properties:
243       parts:
244       - config: {get_resource: NodeAdminUserData}
245         type: multipart
246       - config: {get_resource: NodeUserData}
247         type: multipart
248       - config: {get_resource: RoleUserData}
249         type: multipart
250
251   # Creates the "heat-admin" user if configured via the environment
252   # Should return a OS::Heat::MultipartMime reference via OS::stack_id
253   NodeAdminUserData:
254     type: OS::TripleO::NodeAdminUserData
255
256   # For optional operator additional userdata
257   # Should return a OS::Heat::MultipartMime reference via OS::stack_id
258   NodeUserData:
259     type: OS::TripleO::NodeUserData
260
261   # For optional operator role-specific userdata
262   # Should return a OS::Heat::MultipartMime reference via OS::stack_id
263   RoleUserData:
264     type: OS::TripleO::{{role.name}}::NodeUserData
265
266   {%- for network in networks %}
267   {{network.name}}Port:
268     type: OS::TripleO::{{role.name}}::Ports::{{network.name}}Port
269     properties:
270       ControlPlaneIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
271       IPPool: {get_param: {{role.name}}IPs}
272       NodeIndex: {get_param: NodeIndex}
273   {%- endfor %}
274
275   NetworkConfig:
276     type: OS::TripleO::{{role.name}}::Net::SoftwareConfig
277     properties:
278       ControlPlaneIp: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
279   {%- for network in networks %}
280       {{network.name}}IpSubnet: {get_attr: [{{network.name}}Port, ip_subnet]}
281   {%- endfor %}
282
283   NetIpMap:
284     type: OS::TripleO::Network::Ports::NetIpMap
285     properties:
286       ControlPlaneIp: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
287   {%- for network in networks %}
288       {{network.name}}Ip: {get_attr: [{{network.name}}Port, ip_address]}
289       {{network.name}}IpSubnet: {get_attr: [{{network.name}}Port, ip_subnet]}
290       {{network.name}}IpUri: {get_attr: [{{network.name}}Port, ip_address_uri]}
291   {%- endfor %}
292
293   NetHostMap:
294     type: OS::Heat::Value
295     properties:
296       type: json
297       value:
298         external:
299           fqdn:
300             list_join:
301             - '.'
302             - - {get_attr: [{{role.name}}, name]}
303               - external
304               - {get_param: CloudDomain}
305           short:
306             list_join:
307             - '.'
308             - - {get_attr: [{{role.name}}, name]}
309               - external
310         internal_api:
311           fqdn:
312             list_join:
313             - '.'
314             - - {get_attr: [{{role.name}}, name]}
315               - internalapi
316               - {get_param: CloudDomain}
317           short:
318             list_join:
319             - '.'
320             - - {get_attr: [{{role.name}}, name]}
321               - internalapi
322         storage:
323           fqdn:
324             list_join:
325             - '.'
326             - - {get_attr: [{{role.name}}, name]}
327               - storage
328               - {get_param: CloudDomain}
329           short:
330             list_join:
331             - '.'
332             - - {get_attr: [{{role.name}}, name]}
333               - storage
334         storage_mgmt:
335           fqdn:
336             list_join:
337             - '.'
338             - - {get_attr: [{{role.name}}, name]}
339               - storagemgmt
340               - {get_param: CloudDomain}
341           short:
342             list_join:
343             - '.'
344             - - {get_attr: [{{role.name}}, name]}
345               - storagemgmt
346         tenant:
347           fqdn:
348             list_join:
349             - '.'
350             - - {get_attr: [{{role.name}}, name]}
351               - tenant
352               - {get_param: CloudDomain}
353           short:
354             list_join:
355             - '.'
356             - - {get_attr: [{{role.name}}, name]}
357               - tenant
358         management:
359           fqdn:
360             list_join:
361             - '.'
362             - - {get_attr: [{{role.name}}, name]}
363               - management
364               - {get_param: CloudDomain}
365           short:
366             list_join:
367             - '.'
368             - - {get_attr: [{{role.name}}, name]}
369               - management
370         ctlplane:
371           fqdn:
372             list_join:
373             - '.'
374             - - {get_attr: [{{role.name}}, name]}
375               - ctlplane
376               - {get_param: CloudDomain}
377           short:
378             list_join:
379             - '.'
380             - - {get_attr: [{{role.name}}, name]}
381               - ctlplane
382
383   PreNetworkConfig:
384     type: OS::TripleO::{{role.name}}::PreNetworkConfig
385     properties:
386       server: {get_resource: {{role.name}}}
387       RoleParameters: {get_param: RoleParameters}
388       ServiceNames: {get_param: ServiceNames}
389       deployment_actions: {get_attr: [DeploymentActions, value]}
390
391   NetworkDeployment:
392     type: OS::TripleO::SoftwareDeployment
393     depends_on: PreNetworkConfig
394     properties:
395       name: NetworkDeployment
396       config: {get_resource: NetworkConfig}
397       server: {get_resource: {{role.name}}}
398       actions: {get_param: NetworkDeploymentActions}
399       input_values:
400         bridge_name: {get_param: NeutronPhysicalBridge}
401         interface_name: {get_param: NeutronPublicInterface}
402       actions:
403         if:
404           - server_not_blacklisted
405           - {get_param: NetworkDeploymentActions}
406           - []
407
408   {{role.name}}UpgradeInitConfig:
409     type: OS::Heat::SoftwareConfig
410     properties:
411       group: script
412       config:
413         list_join:
414         - ''
415         - - "#!/bin/bash\n\n"
416           - "if [[ -f /etc/resolv.conf.save ]] ; then rm /etc/resolv.conf.save; fi\n\n"
417           - get_param: UpgradeInitCommand
418           - get_param: UpgradeInitCommonCommand
419
420   # Note we may be able to make this conditional on UpgradeInitCommandNotEmpty
421   # but https://bugs.launchpad.net/heat/+bug/1649900 needs fixing first
422   {{role.name}}UpgradeInitDeployment:
423     type: OS::Heat::SoftwareDeployment
424     depends_on: NetworkDeployment
425     properties:
426       name: {{role.name}}UpgradeInitDeployment
427       server: {get_resource: {{role.name}}}
428       config: {get_resource: {{role.name}}UpgradeInitConfig}
429       actions:
430         if:
431           - server_not_blacklisted
432           - ['CREATE', 'UPDATE']
433           - []
434
435   {{role.name}}Deployment:
436     type: OS::Heat::StructuredDeployment
437     depends_on: {{role.name}}UpgradeInitDeployment
438     properties:
439       name: {{role.name}}Deployment
440       config: {get_resource: {{role.name}}Config}
441       server: {get_resource: {{role.name}}}
442       input_values:
443         enable_package_upgrade: {get_attr: [UpdateDeployment, update_managed_packages]}
444       actions:
445         if:
446           - server_not_blacklisted
447           - ['CREATE', 'UPDATE']
448           - []
449
450   {{role.name}}Config:
451     type: OS::Heat::StructuredConfig
452     properties:
453       group: hiera
454       config:
455         hierarchy:
456           - '"%{::uuid}"'
457           - heat_config_%{::deploy_config_name}
458           - config_step
459           - {{role.name.lower()}}_extraconfig
460           - extraconfig
461           - service_names
462           - service_configs
463           - {{role.name.lower()}}
464           - bootstrap_node # provided by allNodesConfig
465           - all_nodes # provided by allNodesConfig
466           - vip_data # provided by allNodesConfig
467           - '"%{::osfamily}"'
468         merge_behavior: deeper
469         datafiles:
470           service_names:
471             service_names: {get_param: ServiceNames}
472             sensu::subscriptions: {get_param: MonitoringSubscriptions}
473           service_configs:
474             map_replace:
475               - {get_param: ServiceConfigSettings}
476               - values: {get_attr: [NetIpMap, net_ip_map]}
477           {{role.name.lower()}}_extraconfig: {get_param: {{role.name}}ExtraConfig}
478           extraconfig: {get_param: ExtraConfig}
479           {{role.name.lower()}}:
480             tripleo::packages::enable_upgrade: {get_input: enable_package_upgrade}
481             tripleo::profile::base::logging::fluentd::fluentd_sources: {get_param: LoggingSources}
482             tripleo::profile::base::logging::fluentd::fluentd_groups: {get_param: LoggingGroups}
483             fqdn_internal_api: {get_attr: [NetHostMap, value, internal_api, fqdn]}
484             fqdn_storage: {get_attr: [NetHostMap, value, storage, fqdn]}
485             fqdn_storage_mgmt: {get_attr: [NetHostMap, value, storage_mgmt, fqdn]}
486             fqdn_tenant: {get_attr: [NetHostMap, value, tenant, fqdn]}
487             fqdn_management: {get_attr: [NetHostMap, value, management, fqdn]}
488             fqdn_ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]}
489             fqdn_external: {get_attr: [NetHostMap, value, external, fqdn]}
490
491   # Resource for site-specific injection of root certificate
492   NodeTLSCAData:
493     depends_on: {{role.name}}Deployment
494     type: OS::TripleO::NodeTLSCAData
495     properties:
496       server: {get_resource: {{role.name}}}
497
498   # Hook for site-specific additional pre-deployment config, e.g extra hieradata
499   {{role.name}}ExtraConfigPre:
500     depends_on: {{role.name}}Deployment
501     type: OS::TripleO::{{role.name}}ExtraConfigPre
502     # We have to use conditions here so that we don't break backwards
503     # compatibility with templates everywhere
504     condition: server_not_blacklisted
505     properties:
506         server: {get_resource: {{role.name}}}
507
508   # Hook for site-specific additional pre-deployment config,
509   # applying to all nodes, e.g node registration/unregistration
510   NodeExtraConfig:
511     depends_on: [{{role.name}}ExtraConfigPre, NodeTLSCAData]
512     type: OS::TripleO::NodeExtraConfig
513     # We have to use conditions here so that we don't break backwards
514     # compatibility with templates everywhere
515     condition: server_not_blacklisted
516     properties:
517         server: {get_resource: {{role.name}}}
518
519   UpdateConfig:
520     type: OS::TripleO::Tasks::PackageUpdate
521
522   UpdateDeployment:
523     type: OS::Heat::SoftwareDeployment
524     depends_on: NetworkDeployment
525     properties:
526       name: UpdateDeployment
527       config: {get_resource: UpdateConfig}
528       server: {get_resource: {{role.name}}}
529       input_values:
530         update_identifier:
531           get_param: UpdateIdentifier
532       actions:
533         if:
534           - server_not_blacklisted
535           - ['CREATE', 'UPDATE']
536           - []
537
538   DeploymentActions:
539     type: OS::Heat::Value
540     properties:
541       value:
542         if:
543           - server_not_blacklisted
544           - ['CREATE', 'UPDATE']
545           - []
546
547   SshHostPubKey:
548     type: OS::TripleO::Ssh::HostPubKey
549     depends_on: {{role.name}}Deployment
550     properties:
551         server: {get_resource: {{role.name}}}
552         deployment_actions: {get_attr: [DeploymentActions, value]}
553
554 outputs:
555   ip_address:
556     description: IP address of the server in the ctlplane network
557     value: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
558   hostname:
559     description: Hostname of the server
560     value: {get_attr: [{{role.name}}, name]}
561   hostname_map:
562     description: Mapping of network names to hostnames
563     value:
564   {%- for network in networks %}
565       {{network.name_lower|default(network.name.lower())}}: {get_attr: [NetHostMap, value, {{network.name_lower|default(network.name.lower()) }}, fqdn]}
566   {%- endfor %}
567       ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]}
568   hosts_entry:
569     value:
570       str_replace:
571         template: |
572           PRIMARYIP PRIMARYHOST.DOMAIN PRIMARYHOST
573   {%- for network in networks %}
574           {{network.name}}IP {{network.name}}HOST.DOMAIN {{network.name}}HOST
575   {%- endfor %}
576           CTLPLANEIP CTLPLANEHOST.DOMAIN CTLPLANEHOST
577         params:
578           PRIMARYIP: {get_attr: [NetIpMap, net_ip_map, {get_param: [ServiceNetMap, {{role.name}}HostnameResolveNetwork]}]}
579           DOMAIN: {get_param: CloudDomain}
580           PRIMARYHOST: {get_attr: [{{role.name}}, name]}
581   {%- for network in networks %}
582           {{network.name}}IP: {get_attr: [{{network.name}}Port, ip_address]}
583           {{network.name}}HOST: {get_attr: [NetHostMap, value, {{network.name_lower|default(network.name.lower())}}, short]}
584   {%- endfor %}
585           CTLPLANEIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
586           CTLPLANEHOST: {get_attr: [NetHostMap, value, ctlplane, short]}
587   known_hosts_entry:
588     description: Entry for ssh known hosts
589     value:
590       str_replace:
591         template: "PRIMARYIP,PRIMARYHOST.DOMAIN,PRIMARYHOST,\
592   {%- for network in networks %}
593 {{network.name}}IP,{{network.name}}HOST.DOMAIN,{{network.name}}HOST,\
594   {%- endfor %}
595 CTLPLANEIP,CTLPLANEHOST.DOMAIN,CTLPLANEHOST HOSTSSHPUBKEY"
596         params:
597           PRIMARYIP: {get_attr: [NetIpMap, net_ip_map, {get_param: [ServiceNetMap, {{role.name}}HostnameResolveNetwork]}]}
598           DOMAIN: {get_param: CloudDomain}
599           PRIMARYHOST: {get_attr: [{{role.name}}, name]}
600   {%- for network in networks %}
601           {{network.name}}IP: {get_attr: [{{network.name}}Port, ip_address]}
602           {{network.name}}HOST: {get_attr: [NetHostMap, value, {{network.name_lower|default(network.name.lower())}}, short]}
603   {%- endfor %}
604           CTLPLANEIP: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
605           CTLPLANEHOST: {get_attr: [NetHostMap, value, ctlplane, short]}
606           HOSTSSHPUBKEY: {get_attr: [SshHostPubKey, ecdsa]}
607   nova_server_resource:
608     description: Heat resource handle for {{role.name}} server
609     value:
610       {get_resource: {{role.name}}}
611     condition: server_not_blacklisted
612   deployed_server_port_map:
613     description: |
614       Map of Heat created hostname of the server to ip address. This is the
615       hostname before it has been mapped with the HostnameMap parameter, and
616       the IP address from the ctlplane network. This map can be used to construct
617       the DeployedServerPortMap parameter when using split-stack.
618     value:
619       map_replace:
620         - hostname:
621             fixed_ips:
622               - ip_address: {get_attr: [{{role.name}}, networks, ctlplane, 0]}
623         - keys:
624             hostname:
625               list_join:
626                 - '-'
627                 - - {get_param: Hostname}
628                   - ctlplane
629   deployed_server_deployment_swift_data_map:
630     description:
631       Map of Heat created hostname of the server to the Swift container and object
632       used to created the temporary url for metadata polling with
633       os-collect-config.
634     value:
635       map_replace:
636         - hostname:
637             container:
638               str_split:
639                 - '/'
640                 - {get_attr: [{{role.name}}, os_collect_config, request, metadata_url]}
641                 - 5
642             object:
643               str_split:
644                 - '?'
645                 - str_split:
646                     - '/'
647                     - {get_attr: [{{role.name}}, os_collect_config, request, metadata_url]}
648                     - 6
649                 - 0
650         - keys: {hostname: {get_param: Hostname}}
651   os_collect_config:
652     description: The os-collect-config configuration associated with this server resource
653     value: {get_attr: [{{role.name}}, os_collect_config]}
654   {%- for network in networks %}
655   {{network.name_lower|default(network.name.lower())}}_ip_address:
656     description: IP address of the server in the {{network.name}} network
657     value: {get_attr: [{{network.name}}Port, ip_address]}
658   {%- endfor %}