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