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