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