Merge "FreeIPA: don't preprovision service principals if novajoin is enabled"
[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
141
142 resources:
143   {{role}}:
144     type: OS::TripleO::Server
145     metadata:
146       os-collect-config:
147         command: {get_param: ConfigCommand}
148     properties:
149       image: {get_param: {{role}}Image}
150       image_update_policy: {get_param: ImageUpdatePolicy}
151       flavor: {get_param: Overcloud{{role}}Flavor}
152       key_name: {get_param: KeyName}
153       networks:
154         - network: ctlplane
155       user_data_format: SOFTWARE_CONFIG
156       user_data: {get_resource: UserData}
157       name:
158         str_replace:
159             template: {get_param: Hostname}
160             params: {get_param: HostnameMap}
161       software_config_transport: {get_param: SoftwareConfigTransport}
162       metadata:
163         map_merge:
164           - {get_param: ServerMetadata}
165           - {get_param: {{role}}ServerMetadata}
166           - {get_param: ServiceMetadataSettings}
167       scheduler_hints: {get_param: {{role}}SchedulerHints}
168
169   # Combine the NodeAdminUserData and NodeUserData mime archives
170   UserData:
171     type: OS::Heat::MultipartMime
172     properties:
173       parts:
174       - config: {get_resource: NodeAdminUserData}
175         type: multipart
176       - config: {get_resource: NodeUserData}
177         type: multipart
178       - config: {get_resource: RoleUserData}
179         type: multipart
180
181   # Creates the "heat-admin" user if configured via the environment
182   # Should return a OS::Heat::MultipartMime reference via OS::stack_id
183   NodeAdminUserData:
184     type: OS::TripleO::NodeAdminUserData
185
186   # For optional operator additional userdata
187   # Should return a OS::Heat::MultipartMime reference via OS::stack_id
188   NodeUserData:
189     type: OS::TripleO::NodeUserData
190
191   # For optional operator role-specific userdata
192   # Should return a OS::Heat::MultipartMime reference via OS::stack_id
193   RoleUserData:
194     type: OS::TripleO::{{role}}::NodeUserData
195
196   ExternalPort:
197     type: OS::TripleO::{{role}}::Ports::ExternalPort
198     properties:
199       ControlPlaneIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
200       IPPool: {get_param: {{role}}IPs}
201       NodeIndex: {get_param: NodeIndex}
202
203   InternalApiPort:
204     type: OS::TripleO::{{role}}::Ports::InternalApiPort
205     properties:
206       ControlPlaneIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
207       IPPool: {get_param: {{role}}IPs}
208       NodeIndex: {get_param: NodeIndex}
209
210   StoragePort:
211     type: OS::TripleO::{{role}}::Ports::StoragePort
212     properties:
213       ControlPlaneIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
214       IPPool: {get_param: {{role}}IPs}
215       NodeIndex: {get_param: NodeIndex}
216
217   StorageMgmtPort:
218     type: OS::TripleO::{{role}}::Ports::StorageMgmtPort
219     properties:
220       ControlPlaneIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
221       IPPool: {get_param: {{role}}IPs}
222       NodeIndex: {get_param: NodeIndex}
223
224   TenantPort:
225     type: OS::TripleO::{{role}}::Ports::TenantPort
226     properties:
227       ControlPlaneIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
228       IPPool: {get_param: {{role}}IPs}
229       NodeIndex: {get_param: NodeIndex}
230
231   ManagementPort:
232     type: OS::TripleO::{{role}}::Ports::ManagementPort
233     properties:
234       ControlPlaneIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
235       IPPool: {get_param: {{role}}IPs}
236       NodeIndex: {get_param: NodeIndex}
237
238   NetworkConfig:
239     type: OS::TripleO::{{role}}::Net::SoftwareConfig
240     properties:
241       ControlPlaneIp: {get_attr: [{{role}}, networks, ctlplane, 0]}
242       ExternalIpSubnet: {get_attr: [ExternalPort, ip_subnet]}
243       InternalApiIpSubnet: {get_attr: [InternalApiPort, ip_subnet]}
244       StorageIpSubnet: {get_attr: [StoragePort, ip_subnet]}
245       StorageMgmtIpSubnet: {get_attr: [StorageMgmtPort, ip_subnet]}
246       TenantIpSubnet: {get_attr: [TenantPort, ip_subnet]}
247       ManagementIpSubnet: {get_attr: [ManagementPort, ip_subnet]}
248
249   NetIpMap:
250     type: OS::TripleO::Network::Ports::NetIpMap
251     properties:
252       ControlPlaneIp: {get_attr: [{{role}}, networks, ctlplane, 0]}
253       ExternalIp: {get_attr: [ExternalPort, ip_address]}
254       ExternalIpSubnet: {get_attr: [ExternalPort, ip_subnet]}
255       ExternalIpUri: {get_attr: [ExternalPort, ip_address_uri]}
256       InternalApiIp: {get_attr: [InternalApiPort, ip_address]}
257       InternalApiIpSubnet: {get_attr: [InternalApiPort, ip_subnet]}
258       InternalApiIpUri: {get_attr: [InternalApiPort, ip_address_uri]}
259       StorageIp: {get_attr: [StoragePort, ip_address]}
260       StorageIpSubnet: {get_attr: [StoragePort, ip_subnet]}
261       StorageIpUri: {get_attr: [StoragePort, ip_address_uri]}
262       StorageMgmtIp: {get_attr: [StorageMgmtPort, ip_address]}
263       StorageMgmtIpSubnet: {get_attr: [StorageMgmtPort, ip_subnet]}
264       StorageMgmtIpUri: {get_attr: [StorageMgmtPort, ip_address_uri]}
265       TenantIp: {get_attr: [TenantPort, ip_address]}
266       TenantIpSubnet: {get_attr: [TenantPort, ip_subnet]}
267       TenantIpUri: {get_attr: [TenantPort, ip_address_uri]}
268       ManagementIp: {get_attr: [ManagementPort, ip_address]}
269       ManagementIpSubnet: {get_attr: [ManagementPort, ip_subnet]}
270       ManagementIpUri: {get_attr: [ManagementPort, ip_address_uri]}
271
272   NetHostMap:
273     type: OS::Heat::Value
274     properties:
275       type: json
276       value:
277         external:
278           fqdn:
279             list_join:
280             - '.'
281             - - {get_attr: [{{role}}, name]}
282               - external
283               - {get_param: CloudDomain}
284           short:
285             list_join:
286             - '.'
287             - - {get_attr: [{{role}}, name]}
288               - external
289         internal_api:
290           fqdn:
291             list_join:
292             - '.'
293             - - {get_attr: [{{role}}, name]}
294               - internalapi
295               - {get_param: CloudDomain}
296           short:
297             list_join:
298             - '.'
299             - - {get_attr: [{{role}}, name]}
300               - internalapi
301         storage:
302           fqdn:
303             list_join:
304             - '.'
305             - - {get_attr: [{{role}}, name]}
306               - storage
307               - {get_param: CloudDomain}
308           short:
309             list_join:
310             - '.'
311             - - {get_attr: [{{role}}, name]}
312               - storage
313         storage_mgmt:
314           fqdn:
315             list_join:
316             - '.'
317             - - {get_attr: [{{role}}, name]}
318               - storagemgmt
319               - {get_param: CloudDomain}
320           short:
321             list_join:
322             - '.'
323             - - {get_attr: [{{role}}, name]}
324               - storagemgmt
325         tenant:
326           fqdn:
327             list_join:
328             - '.'
329             - - {get_attr: [{{role}}, name]}
330               - tenant
331               - {get_param: CloudDomain}
332           short:
333             list_join:
334             - '.'
335             - - {get_attr: [{{role}}, name]}
336               - tenant
337         management:
338           fqdn:
339             list_join:
340             - '.'
341             - - {get_attr: [{{role}}, name]}
342               - management
343               - {get_param: CloudDomain}
344           short:
345             list_join:
346             - '.'
347             - - {get_attr: [{{role}}, name]}
348               - management
349         ctlplane:
350           fqdn:
351             list_join:
352             - '.'
353             - - {get_attr: [{{role}}, name]}
354               - ctlplane
355               - {get_param: CloudDomain}
356           short:
357             list_join:
358             - '.'
359             - - {get_attr: [{{role}}, name]}
360               - ctlplane
361
362   PreNetworkConfig:
363     type: OS::TripleO::{{role}}::PreNetworkConfig
364     properties:
365       server: {get_resource: {{role}}}
366
367   NetworkDeployment:
368     type: OS::TripleO::SoftwareDeployment
369     depends_on: PreNetworkConfig
370     properties:
371       name: NetworkDeployment
372       config: {get_resource: NetworkConfig}
373       server: {get_resource: {{role}}}
374       actions: {get_param: NetworkDeploymentActions}
375       input_values:
376         bridge_name: br-ex
377         interface_name: {get_param: NeutronPublicInterface}
378
379   {{role}}UpgradeInitConfig:
380     type: OS::Heat::SoftwareConfig
381     properties:
382       group: script
383       config:
384         list_join:
385         - ''
386         - - "#!/bin/bash\n\n"
387           - "if [[ -f /etc/resolv.conf.save ]] ; then rm /etc/resolv.conf.save; fi\n\n"
388           - get_param: UpgradeInitCommand
389
390   # Note we may be able to make this conditional on UpgradeInitCommandNotEmpty
391   # but https://bugs.launchpad.net/heat/+bug/1649900 needs fixing first
392   {{role}}UpgradeInitDeployment:
393     type: OS::Heat::SoftwareDeployment
394     depends_on: NetworkDeployment
395     properties:
396       name: {{role}}UpgradeInitDeployment
397       server: {get_resource: {{role}}}
398       config: {get_resource: {{role}}UpgradeInitConfig}
399
400   {{role}}Deployment:
401     type: OS::Heat::StructuredDeployment
402     depends_on: {{role}}UpgradeInitDeployment
403     properties:
404       name: {{role}}Deployment
405       config: {get_resource: {{role}}Config}
406       server: {get_resource: {{role}}}
407       input_values:
408         enable_package_upgrade: {get_attr: [UpdateDeployment, update_managed_packages]}
409
410   {{role}}Config:
411     type: OS::Heat::StructuredConfig
412     properties:
413       group: hiera
414       config:
415         hierarchy:
416           - '"%{::uuid}"'
417           - heat_config_%{::deploy_config_name}
418           - {{role.lower()}}_extraconfig
419           - extraconfig
420           - service_names
421           - service_configs
422           - {{role.lower()}}
423           - bootstrap_node # provided by allNodesConfig
424           - all_nodes # provided by allNodesConfig
425           - vip_data # provided by allNodesConfig
426           - '"%{::osfamily}"'
427         merge_behavior: deeper
428         datafiles:
429           service_names:
430             service_names: {get_param: ServiceNames}
431             sensu::subscriptions: {get_param: MonitoringSubscriptions}
432           service_configs:
433             map_replace:
434               - {get_param: ServiceConfigSettings}
435               - values: {get_attr: [NetIpMap, net_ip_map]}
436           {{role.lower()}}_extraconfig: {get_param: {{role}}ExtraConfig}
437           extraconfig: {get_param: ExtraConfig}
438           {{role.lower()}}:
439             tripleo::packages::enable_upgrade: {get_input: enable_package_upgrade}
440             tripleo::profile::base::logging::fluentd::fluentd_sources: {get_param: LoggingSources}
441             tripleo::profile::base::logging::fluentd::fluentd_groups: {get_param: LoggingGroups}
442             fqdn_internal_api: {get_attr: [NetHostMap, value, internal_api, fqdn]}
443             fqdn_storage: {get_attr: [NetHostMap, value, storage, fqdn]}
444             fqdn_storage_mgmt: {get_attr: [NetHostMap, value, storage_mgmt, fqdn]}
445             fqdn_tenant: {get_attr: [NetHostMap, value, tenant, fqdn]}
446             fqdn_management: {get_attr: [NetHostMap, value, management, fqdn]}
447             fqdn_ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]}
448
449   # Resource for site-specific injection of root certificate
450   NodeTLSCAData:
451     depends_on: {{role}}Deployment
452     type: OS::TripleO::NodeTLSCAData
453     properties:
454       server: {get_resource: {{role}}}
455
456   # Hook for site-specific additional pre-deployment config, e.g extra hieradata
457   {{role}}ExtraConfigPre:
458     depends_on: {{role}}Deployment
459     type: OS::TripleO::{{role}}ExtraConfigPre
460     properties:
461         server: {get_resource: {{role}}}
462
463   # Hook for site-specific additional pre-deployment config,
464   # applying to all nodes, e.g node registration/unregistration
465   NodeExtraConfig:
466     depends_on: [{{role}}ExtraConfigPre, NodeTLSCAData]
467     type: OS::TripleO::NodeExtraConfig
468     properties:
469         server: {get_resource: {{role}}}
470
471   UpdateConfig:
472     type: OS::TripleO::Tasks::PackageUpdate
473
474   UpdateDeployment:
475     type: OS::Heat::SoftwareDeployment
476     properties:
477       config: {get_resource: UpdateConfig}
478       server: {get_resource: {{role}}}
479       input_values:
480         update_identifier:
481           get_param: UpdateIdentifier
482
483 outputs:
484   ip_address:
485     description: IP address of the server in the ctlplane network
486     value: {get_attr: [{{role}}, networks, ctlplane, 0]}
487   hostname:
488     description: Hostname of the server
489     value: {get_attr: [{{role}}, name]}
490   hostname_map:
491     description: Mapping of network names to hostnames
492     value:
493       external: {get_attr: [NetHostMap, value, external, fqdn]}
494       internal_api: {get_attr: [NetHostMap, value, internal_api, fqdn]}
495       storage: {get_attr: [NetHostMap, value, storage, fqdn]}
496       storage_mgmt: {get_attr: [NetHostMap, value, storage_mgmt, fqdn]}
497       tenant: {get_attr: [NetHostMap, value, tenant, fqdn]}
498       management: {get_attr: [NetHostMap, value, management, fqdn]}
499       ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]}
500   hosts_entry:
501     value:
502       str_replace:
503         template: |
504           PRIMARYIP PRIMARYHOST.DOMAIN PRIMARYHOST
505           EXTERNALIP EXTERNALHOST.DOMAIN EXTERNALHOST
506           INTERNAL_APIIP INTERNAL_APIHOST.DOMAIN INTERNAL_APIHOST
507           STORAGEIP STORAGEHOST.DOMAIN STORAGEHOST
508           STORAGE_MGMTIP STORAGE_MGMTHOST.DOMAIN STORAGE_MGMTHOST
509           TENANTIP TENANTHOST.DOMAIN TENANTHOST
510           MANAGEMENTIP MANAGEMENTHOST.DOMAIN MANAGEMENTHOST
511           CTLPLANEIP CTLPLANEHOST.DOMAIN CTLPLANEHOST
512         params:
513           PRIMARYIP: {get_attr: [NetIpMap, net_ip_map, {get_param: [ServiceNetMap, {{role}}HostnameResolveNetwork]}]}
514           DOMAIN: {get_param: CloudDomain}
515           PRIMARYHOST: {get_attr: [{{role}}, name]}
516           EXTERNALIP: {get_attr: [ExternalPort, ip_address]}
517           EXTERNALHOST: {get_attr: [NetHostMap, value, external, short]}
518           INTERNAL_APIIP: {get_attr: [InternalApiPort, ip_address]}
519           INTERNAL_APIHOST: {get_attr: [NetHostMap, value, internal_api, short]}
520           STORAGEIP: {get_attr: [StoragePort, ip_address]}
521           STORAGEHOST: {get_attr: [NetHostMap, value, storage, short]}
522           STORAGE_MGMTIP: {get_attr: [StorageMgmtPort, ip_address]}
523           STORAGE_MGMTHOST: {get_attr: [NetHostMap, value, storage_mgmt, short]}
524           TENANTIP: {get_attr: [TenantPort, ip_address]}
525           TENANTHOST: {get_attr: [NetHostMap, value, tenant, short]}
526           MANAGEMENTIP: {get_attr: [ManagementPort, ip_address]}
527           MANAGEMENTHOST: {get_attr: [NetHostMap, value, management, short]}
528           CTLPLANEIP: {get_attr: [{{role}}, networks, ctlplane, 0]}
529           CTLPLANEHOST: {get_attr: [NetHostMap, value, ctlplane, short]}
530   nova_server_resource:
531     description: Heat resource handle for {{role}} server
532     value:
533       {get_resource: {{role}}}
534   external_ip_address:
535     description: IP address of the server in the external network
536     value: {get_attr: [ExternalPort, ip_address]}
537   internal_api_ip_address:
538     description: IP address of the server in the internal_api network
539     value: {get_attr: [InternalApiPort, ip_address]}
540   storage_ip_address:
541     description: IP address of the server in the storage network
542     value: {get_attr: [StoragePort, ip_address]}
543   storage_mgmt_ip_address:
544     description: IP address of the server in the storage_mgmt network
545     value: {get_attr: [StorageMgmtPort, ip_address]}
546   tenant_ip_address:
547     description: IP address of the server in the tenant network
548     value: {get_attr: [TenantPort, ip_address]}
549   management_ip_address:
550     description: IP address of the server in the management network
551     value: {get_attr: [ManagementPort, ip_address]}