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