Merge "Fix nova-compute service name in upgrade steps"
[apex-tripleo-heat-templates.git] / puppet / role.role.j2.yaml
1 heat_template_version: ocata
2 description: 'OpenStack {{role}} node configured by Puppet'
3 parameters:
4   Overcloud{{role}}Flavor:
5     description: Flavor for the {{role}} node.
6     default: baremetal
7     type: string
8 {% if disable_constraints is not defined %}
9     constraints:
10       - custom_constraint: nova.flavor
11 {% endif %}
12   {{role}}Image:
13     type: string
14     default: overcloud-full
15 {% if 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 disable_constraints is not defined %}
28     constraints:
29       - custom_constraint: nova.keypair
30 {% endif %}
31   NeutronPublicInterface:
32     default: nic1
33     description: What interface to bridge onto br-ex for network nodes.
34     type: string
35   ServiceNetMap:
36     default: {}
37     description: Mapping of service_name -> network name. Typically set
38                  via parameter_defaults in the resource registry.
39     type: json
40   EndpointMap:
41     default: {}
42     description: Mapping of service endpoint -> protocol. Typically set
43                  via parameter_defaults in the resource registry.
44     type: json
45   UpdateIdentifier:
46     default: ''
47     type: string
48     description: >
49       Setting to a previously unused value during stack-update will trigger
50       package update on all nodes
51   Hostname:
52     type: string
53     default: '' # Defaults to Heat created hostname
54   HostnameMap:
55     type: json
56     default: {}
57     description: Optional mapping to override hostnames
58   ExtraConfig:
59     default: {}
60     description: |
61       Additional hiera configuration to inject into the cluster. Note
62       that {{role}}ExtraConfig takes precedence over ExtraConfig.
63     type: json
64   {{role}}ExtraConfig:
65     default: {}
66     description: |
67       Role specific additional hiera configuration to inject into the cluster.
68     type: json
69   {{role}}IPs:
70     default: {}
71     type: json
72   NetworkDeploymentActions:
73     type: comma_delimited_list
74     description: >
75       Heat action when to apply network configuration changes
76     default: ['CREATE']
77   SoftwareConfigTransport:
78     default: POLL_SERVER_CFN
79     description: |
80       How the server should receive the metadata required for software configuration.
81     type: string
82     constraints:
83     - allowed_values: [POLL_SERVER_CFN, POLL_SERVER_HEAT, POLL_TEMP_URL, ZAQAR_MESSAGE]
84   CloudDomain:
85     default: 'localdomain'
86     type: string
87     description: >
88       The DNS domain used for the hosts. This should match the dhcp_domain
89       configured in the Undercloud neutron. Defaults to localdomain.
90   {{role}}ServerMetadata:
91     default: {}
92     description: >
93       Extra properties or metadata passed to Nova for the created nodes in
94       the overcloud. It's accessible via the Nova metadata API. This option is
95       role-specific and is merged with the values given to the ServerMetadata
96       parameter.
97     type: json
98   ServerMetadata:
99     default: {}
100     description: >
101       Extra properties or metadata passed to Nova for the created nodes in
102       the overcloud. It's accessible via the Nova metadata API. This applies to
103       all roles and is merged with a role-specific metadata parameter.
104     type: json
105   {{role}}SchedulerHints:
106     type: json
107     description: Optional scheduler hints to pass to nova
108     default: {}
109   NodeIndex:
110     type: number
111     default: 0
112   ServiceConfigSettings:
113     type: json
114     default: {}
115   ServiceNames:
116     type: comma_delimited_list
117     default: []
118   MonitoringSubscriptions:
119     type: comma_delimited_list
120     default: []
121   ServiceMetadataSettings:
122     type: json
123     default: {}
124   ConfigCommand:
125     type: string
126     description: Command which will be run whenever configuration data changes
127     default: os-refresh-config --timeout 14400
128   LoggingSources:
129     type: json
130     default: []
131   LoggingGroups:
132     type: comma_delimited_list
133     default: []
134   UpgradeInitCommand:
135     type: string
136     description: |
137       Command or script snippet to run on all overcloud nodes to
138       initialize the upgrade process. E.g. a repository switch.
139     default: ''
140   UpgradeInitCommonCommand:
141     type: string
142     description: |
143       Common commands required by the upgrades process. This should not
144       normally be modified by the operator and is set and unset in the
145       major-upgrade-composable-steps.yaml and major-upgrade-converge.yaml
146       environment files.
147     default: ''
148
149 resources:
150   {{role}}:
151     type: OS::TripleO::Server
152     metadata:
153       os-collect-config:
154         command: {get_param: ConfigCommand}
155     properties:
156       image: {get_param: {{role}}Image}
157       image_update_policy: {get_param: ImageUpdatePolicy}
158       flavor: {get_param: Overcloud{{role}}Flavor}
159       key_name: {get_param: KeyName}
160       networks:
161         - network: ctlplane
162       user_data_format: SOFTWARE_CONFIG
163       user_data: {get_resource: UserData}
164       name:
165         str_replace:
166             template: {get_param: Hostname}
167             params: {get_param: HostnameMap}
168       software_config_transport: {get_param: SoftwareConfigTransport}
169       metadata:
170         map_merge:
171           - {get_param: ServerMetadata}
172           - {get_param: {{role}}ServerMetadata}
173           - {get_param: ServiceMetadataSettings}
174       scheduler_hints: {get_param: {{role}}SchedulerHints}
175
176   # Combine the NodeAdminUserData and NodeUserData mime archives
177   UserData:
178     type: OS::Heat::MultipartMime
179     properties:
180       parts:
181       - config: {get_resource: NodeAdminUserData}
182         type: multipart
183       - config: {get_resource: NodeUserData}
184         type: multipart
185       - config: {get_resource: RoleUserData}
186         type: multipart
187
188   # Creates the "heat-admin" user if configured via the environment
189   # Should return a OS::Heat::MultipartMime reference via OS::stack_id
190   NodeAdminUserData:
191     type: OS::TripleO::NodeAdminUserData
192
193   # For optional operator additional userdata
194   # Should return a OS::Heat::MultipartMime reference via OS::stack_id
195   NodeUserData:
196     type: OS::TripleO::NodeUserData
197
198   # For optional operator role-specific userdata
199   # Should return a OS::Heat::MultipartMime reference via OS::stack_id
200   RoleUserData:
201     type: OS::TripleO::{{role}}::NodeUserData
202
203   ExternalPort:
204     type: OS::TripleO::{{role}}::Ports::ExternalPort
205     properties:
206       ControlPlaneIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
207       IPPool: {get_param: {{role}}IPs}
208       NodeIndex: {get_param: NodeIndex}
209
210   InternalApiPort:
211     type: OS::TripleO::{{role}}::Ports::InternalApiPort
212     properties:
213       ControlPlaneIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
214       IPPool: {get_param: {{role}}IPs}
215       NodeIndex: {get_param: NodeIndex}
216
217   StoragePort:
218     type: OS::TripleO::{{role}}::Ports::StoragePort
219     properties:
220       ControlPlaneIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
221       IPPool: {get_param: {{role}}IPs}
222       NodeIndex: {get_param: NodeIndex}
223
224   StorageMgmtPort:
225     type: OS::TripleO::{{role}}::Ports::StorageMgmtPort
226     properties:
227       ControlPlaneIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
228       IPPool: {get_param: {{role}}IPs}
229       NodeIndex: {get_param: NodeIndex}
230
231   TenantPort:
232     type: OS::TripleO::{{role}}::Ports::TenantPort
233     properties:
234       ControlPlaneIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
235       IPPool: {get_param: {{role}}IPs}
236       NodeIndex: {get_param: NodeIndex}
237
238   ManagementPort:
239     type: OS::TripleO::{{role}}::Ports::ManagementPort
240     properties:
241       ControlPlaneIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
242       IPPool: {get_param: {{role}}IPs}
243       NodeIndex: {get_param: NodeIndex}
244
245   NetworkConfig:
246     type: OS::TripleO::{{role}}::Net::SoftwareConfig
247     properties:
248       ControlPlaneIp: {get_attr: [{{role}}, networks, ctlplane, 0]}
249       ExternalIpSubnet: {get_attr: [ExternalPort, ip_subnet]}
250       InternalApiIpSubnet: {get_attr: [InternalApiPort, ip_subnet]}
251       StorageIpSubnet: {get_attr: [StoragePort, ip_subnet]}
252       StorageMgmtIpSubnet: {get_attr: [StorageMgmtPort, ip_subnet]}
253       TenantIpSubnet: {get_attr: [TenantPort, ip_subnet]}
254       ManagementIpSubnet: {get_attr: [ManagementPort, ip_subnet]}
255
256   NetIpMap:
257     type: OS::TripleO::Network::Ports::NetIpMap
258     properties:
259       ControlPlaneIp: {get_attr: [{{role}}, networks, ctlplane, 0]}
260       ExternalIp: {get_attr: [ExternalPort, ip_address]}
261       ExternalIpSubnet: {get_attr: [ExternalPort, ip_subnet]}
262       ExternalIpUri: {get_attr: [ExternalPort, ip_address_uri]}
263       InternalApiIp: {get_attr: [InternalApiPort, ip_address]}
264       InternalApiIpSubnet: {get_attr: [InternalApiPort, ip_subnet]}
265       InternalApiIpUri: {get_attr: [InternalApiPort, ip_address_uri]}
266       StorageIp: {get_attr: [StoragePort, ip_address]}
267       StorageIpSubnet: {get_attr: [StoragePort, ip_subnet]}
268       StorageIpUri: {get_attr: [StoragePort, ip_address_uri]}
269       StorageMgmtIp: {get_attr: [StorageMgmtPort, ip_address]}
270       StorageMgmtIpSubnet: {get_attr: [StorageMgmtPort, ip_subnet]}
271       StorageMgmtIpUri: {get_attr: [StorageMgmtPort, ip_address_uri]}
272       TenantIp: {get_attr: [TenantPort, ip_address]}
273       TenantIpSubnet: {get_attr: [TenantPort, ip_subnet]}
274       TenantIpUri: {get_attr: [TenantPort, ip_address_uri]}
275       ManagementIp: {get_attr: [ManagementPort, ip_address]}
276       ManagementIpSubnet: {get_attr: [ManagementPort, ip_subnet]}
277       ManagementIpUri: {get_attr: [ManagementPort, ip_address_uri]}
278
279   NetHostMap:
280     type: OS::Heat::Value
281     properties:
282       type: json
283       value:
284         external:
285           fqdn:
286             list_join:
287             - '.'
288             - - {get_attr: [{{role}}, name]}
289               - external
290               - {get_param: CloudDomain}
291           short:
292             list_join:
293             - '.'
294             - - {get_attr: [{{role}}, name]}
295               - external
296         internal_api:
297           fqdn:
298             list_join:
299             - '.'
300             - - {get_attr: [{{role}}, name]}
301               - internalapi
302               - {get_param: CloudDomain}
303           short:
304             list_join:
305             - '.'
306             - - {get_attr: [{{role}}, name]}
307               - internalapi
308         storage:
309           fqdn:
310             list_join:
311             - '.'
312             - - {get_attr: [{{role}}, name]}
313               - storage
314               - {get_param: CloudDomain}
315           short:
316             list_join:
317             - '.'
318             - - {get_attr: [{{role}}, name]}
319               - storage
320         storage_mgmt:
321           fqdn:
322             list_join:
323             - '.'
324             - - {get_attr: [{{role}}, name]}
325               - storagemgmt
326               - {get_param: CloudDomain}
327           short:
328             list_join:
329             - '.'
330             - - {get_attr: [{{role}}, name]}
331               - storagemgmt
332         tenant:
333           fqdn:
334             list_join:
335             - '.'
336             - - {get_attr: [{{role}}, name]}
337               - tenant
338               - {get_param: CloudDomain}
339           short:
340             list_join:
341             - '.'
342             - - {get_attr: [{{role}}, name]}
343               - tenant
344         management:
345           fqdn:
346             list_join:
347             - '.'
348             - - {get_attr: [{{role}}, name]}
349               - management
350               - {get_param: CloudDomain}
351           short:
352             list_join:
353             - '.'
354             - - {get_attr: [{{role}}, name]}
355               - management
356         ctlplane:
357           fqdn:
358             list_join:
359             - '.'
360             - - {get_attr: [{{role}}, name]}
361               - ctlplane
362               - {get_param: CloudDomain}
363           short:
364             list_join:
365             - '.'
366             - - {get_attr: [{{role}}, name]}
367               - ctlplane
368
369   PreNetworkConfig:
370     type: OS::TripleO::{{role}}::PreNetworkConfig
371     properties:
372       server: {get_resource: {{role}}}
373
374   NetworkDeployment:
375     type: OS::TripleO::SoftwareDeployment
376     depends_on: PreNetworkConfig
377     properties:
378       name: NetworkDeployment
379       config: {get_resource: NetworkConfig}
380       server: {get_resource: {{role}}}
381       actions: {get_param: NetworkDeploymentActions}
382       input_values:
383         bridge_name: br-ex
384         interface_name: {get_param: NeutronPublicInterface}
385
386   {{role}}UpgradeInitConfig:
387     type: OS::Heat::SoftwareConfig
388     properties:
389       group: script
390       config:
391         list_join:
392         - ''
393         - - "#!/bin/bash\n\n"
394           - "if [[ -f /etc/resolv.conf.save ]] ; then rm /etc/resolv.conf.save; fi\n\n"
395           - get_param: UpgradeInitCommand
396           - get_param: UpgradeInitCommonCommand
397
398   # Note we may be able to make this conditional on UpgradeInitCommandNotEmpty
399   # but https://bugs.launchpad.net/heat/+bug/1649900 needs fixing first
400   {{role}}UpgradeInitDeployment:
401     type: OS::Heat::SoftwareDeployment
402     depends_on: NetworkDeployment
403     properties:
404       name: {{role}}UpgradeInitDeployment
405       server: {get_resource: {{role}}}
406       config: {get_resource: {{role}}UpgradeInitConfig}
407
408   {{role}}Deployment:
409     type: OS::Heat::StructuredDeployment
410     depends_on: {{role}}UpgradeInitDeployment
411     properties:
412       name: {{role}}Deployment
413       config: {get_resource: {{role}}Config}
414       server: {get_resource: {{role}}}
415       input_values:
416         enable_package_upgrade: {get_attr: [UpdateDeployment, update_managed_packages]}
417
418   {{role}}Config:
419     type: OS::Heat::StructuredConfig
420     properties:
421       group: hiera
422       config:
423         hierarchy:
424           - '"%{::uuid}"'
425           - heat_config_%{::deploy_config_name}
426           - {{role.lower()}}_extraconfig
427           - extraconfig
428           - service_names
429           - service_configs
430           - {{role.lower()}}
431           - bootstrap_node # provided by allNodesConfig
432           - all_nodes # provided by allNodesConfig
433           - vip_data # provided by allNodesConfig
434           - '"%{::osfamily}"'
435         merge_behavior: deeper
436         datafiles:
437           service_names:
438             service_names: {get_param: ServiceNames}
439             sensu::subscriptions: {get_param: MonitoringSubscriptions}
440           service_configs:
441             map_replace:
442               - {get_param: ServiceConfigSettings}
443               - values: {get_attr: [NetIpMap, net_ip_map]}
444           {{role.lower()}}_extraconfig: {get_param: {{role}}ExtraConfig}
445           extraconfig: {get_param: ExtraConfig}
446           {{role.lower()}}:
447             tripleo::packages::enable_upgrade: {get_input: enable_package_upgrade}
448             tripleo::profile::base::logging::fluentd::fluentd_sources: {get_param: LoggingSources}
449             tripleo::profile::base::logging::fluentd::fluentd_groups: {get_param: LoggingGroups}
450             fqdn_internal_api: {get_attr: [NetHostMap, value, internal_api, fqdn]}
451             fqdn_storage: {get_attr: [NetHostMap, value, storage, fqdn]}
452             fqdn_storage_mgmt: {get_attr: [NetHostMap, value, storage_mgmt, fqdn]}
453             fqdn_tenant: {get_attr: [NetHostMap, value, tenant, fqdn]}
454             fqdn_management: {get_attr: [NetHostMap, value, management, fqdn]}
455             fqdn_ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]}
456
457   # Resource for site-specific injection of root certificate
458   NodeTLSCAData:
459     depends_on: {{role}}Deployment
460     type: OS::TripleO::NodeTLSCAData
461     properties:
462       server: {get_resource: {{role}}}
463
464   # Hook for site-specific additional pre-deployment config, e.g extra hieradata
465   {{role}}ExtraConfigPre:
466     depends_on: {{role}}Deployment
467     type: OS::TripleO::{{role}}ExtraConfigPre
468     properties:
469         server: {get_resource: {{role}}}
470
471   # Hook for site-specific additional pre-deployment config,
472   # applying to all nodes, e.g node registration/unregistration
473   NodeExtraConfig:
474     depends_on: [{{role}}ExtraConfigPre, NodeTLSCAData]
475     type: OS::TripleO::NodeExtraConfig
476     properties:
477         server: {get_resource: {{role}}}
478
479   UpdateConfig:
480     type: OS::TripleO::Tasks::PackageUpdate
481
482   UpdateDeployment:
483     type: OS::Heat::SoftwareDeployment
484     depends_on: NetworkDeployment
485     properties:
486       name: UpdateDeployment
487       config: {get_resource: UpdateConfig}
488       server: {get_resource: {{role}}}
489       input_values:
490         update_identifier:
491           get_param: UpdateIdentifier
492
493 outputs:
494   ip_address:
495     description: IP address of the server in the ctlplane network
496     value: {get_attr: [{{role}}, networks, ctlplane, 0]}
497   hostname:
498     description: Hostname of the server
499     value: {get_attr: [{{role}}, name]}
500   hostname_map:
501     description: Mapping of network names to hostnames
502     value:
503       external: {get_attr: [NetHostMap, value, external, fqdn]}
504       internal_api: {get_attr: [NetHostMap, value, internal_api, fqdn]}
505       storage: {get_attr: [NetHostMap, value, storage, fqdn]}
506       storage_mgmt: {get_attr: [NetHostMap, value, storage_mgmt, fqdn]}
507       tenant: {get_attr: [NetHostMap, value, tenant, fqdn]}
508       management: {get_attr: [NetHostMap, value, management, fqdn]}
509       ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]}
510   hosts_entry:
511     value:
512       str_replace:
513         template: |
514           PRIMARYIP PRIMARYHOST.DOMAIN PRIMARYHOST
515           EXTERNALIP EXTERNALHOST.DOMAIN EXTERNALHOST
516           INTERNAL_APIIP INTERNAL_APIHOST.DOMAIN INTERNAL_APIHOST
517           STORAGEIP STORAGEHOST.DOMAIN STORAGEHOST
518           STORAGE_MGMTIP STORAGE_MGMTHOST.DOMAIN STORAGE_MGMTHOST
519           TENANTIP TENANTHOST.DOMAIN TENANTHOST
520           MANAGEMENTIP MANAGEMENTHOST.DOMAIN MANAGEMENTHOST
521           CTLPLANEIP CTLPLANEHOST.DOMAIN CTLPLANEHOST
522         params:
523           PRIMARYIP: {get_attr: [NetIpMap, net_ip_map, {get_param: [ServiceNetMap, {{role}}HostnameResolveNetwork]}]}
524           DOMAIN: {get_param: CloudDomain}
525           PRIMARYHOST: {get_attr: [{{role}}, name]}
526           EXTERNALIP: {get_attr: [ExternalPort, ip_address]}
527           EXTERNALHOST: {get_attr: [NetHostMap, value, external, short]}
528           INTERNAL_APIIP: {get_attr: [InternalApiPort, ip_address]}
529           INTERNAL_APIHOST: {get_attr: [NetHostMap, value, internal_api, short]}
530           STORAGEIP: {get_attr: [StoragePort, ip_address]}
531           STORAGEHOST: {get_attr: [NetHostMap, value, storage, short]}
532           STORAGE_MGMTIP: {get_attr: [StorageMgmtPort, ip_address]}
533           STORAGE_MGMTHOST: {get_attr: [NetHostMap, value, storage_mgmt, short]}
534           TENANTIP: {get_attr: [TenantPort, ip_address]}
535           TENANTHOST: {get_attr: [NetHostMap, value, tenant, short]}
536           MANAGEMENTIP: {get_attr: [ManagementPort, ip_address]}
537           MANAGEMENTHOST: {get_attr: [NetHostMap, value, management, short]}
538           CTLPLANEIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
539           CTLPLANEHOST: {get_attr: [NetHostMap, value, ctlplane, short]}
540   nova_server_resource:
541     description: Heat resource handle for {{role}} server
542     value:
543       {get_resource: {{role}}}
544   external_ip_address:
545     description: IP address of the server in the external network
546     value: {get_attr: [ExternalPort, ip_address]}
547   internal_api_ip_address:
548     description: IP address of the server in the internal_api network
549     value: {get_attr: [InternalApiPort, ip_address]}
550   storage_ip_address:
551     description: IP address of the server in the storage network
552     value: {get_attr: [StoragePort, ip_address]}
553   storage_mgmt_ip_address:
554     description: IP address of the server in the storage_mgmt network
555     value: {get_attr: [StorageMgmtPort, ip_address]}
556   tenant_ip_address:
557     description: IP address of the server in the tenant network
558     value: {get_attr: [TenantPort, ip_address]}
559   management_ip_address:
560     description: IP address of the server in the management network
561     value: {get_attr: [ManagementPort, ip_address]}