Merge "Deployed server: switch to apply-config hook"
[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   ServerMetadata:
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.
100     type: json
101   NovaComputeSchedulerHints:
102     type: json
103     description: Optional scheduler hints to pass to nova
104     default: {}
105   ServiceConfigSettings:
106     type: json
107     default: {}
108   ServiceNames:
109     type: comma_delimited_list
110     default: []
111   MonitoringSubscriptions:
112     type: comma_delimited_list
113     default: []
114   ConfigCommand:
115     type: string
116     description: Command which will be run whenever configuration data changes
117     default: os-refresh-config --timeout 14400
118
119 resources:
120
121   NovaCompute:
122     type: OS::TripleO::Server
123     metadata:
124       os-collect-config:
125         command: {get_param: ConfigCommand}
126     properties:
127       image: {get_param: NovaImage}
128       image_update_policy:
129         get_param: ImageUpdatePolicy
130       flavor: {get_param: OvercloudComputeFlavor}
131       key_name: {get_param: KeyName}
132       networks:
133         - network: ctlplane
134       user_data_format: SOFTWARE_CONFIG
135       user_data: {get_resource: UserData}
136       name:
137         str_replace:
138             template: {get_param: Hostname}
139             params: {get_param: HostnameMap}
140       software_config_transport: {get_param: SoftwareConfigTransport}
141       metadata: {get_param: ServerMetadata}
142       scheduler_hints: {get_param: NovaComputeSchedulerHints}
143
144   # Combine the NodeAdminUserData and NodeUserData mime archives
145   UserData:
146     type: OS::Heat::MultipartMime
147     properties:
148       parts:
149       - config: {get_resource: NodeAdminUserData}
150         type: multipart
151       - config: {get_resource: NodeUserData}
152         type: multipart
153
154   # Creates the "heat-admin" user if configured via the environment
155   # Should return a OS::Heat::MultipartMime reference via OS::stack_id
156   NodeAdminUserData:
157     type: OS::TripleO::NodeAdminUserData
158
159   # For optional operator additional userdata
160   # Should return a OS::Heat::MultipartMime reference via OS::stack_id
161   NodeUserData:
162     type: OS::TripleO::NodeUserData
163
164   ExternalPort:
165     type: OS::TripleO::Compute::Ports::ExternalPort
166     properties:
167       ControlPlaneIP: {get_attr: [NovaCompute, networks, ctlplane, 0]}
168       IPPool: {get_param: NovaComputeIPs}
169       NodeIndex: {get_param: NodeIndex}
170
171   InternalApiPort:
172     type: OS::TripleO::Compute::Ports::InternalApiPort
173     properties:
174       ControlPlaneIP: {get_attr: [NovaCompute, networks, ctlplane, 0]}
175       IPPool: {get_param: NovaComputeIPs}
176       NodeIndex: {get_param: NodeIndex}
177
178   StoragePort:
179     type: OS::TripleO::Compute::Ports::StoragePort
180     properties:
181       ControlPlaneIP: {get_attr: [NovaCompute, networks, ctlplane, 0]}
182       IPPool: {get_param: NovaComputeIPs}
183       NodeIndex: {get_param: NodeIndex}
184
185   StorageMgmtPort:
186     type: OS::TripleO::Compute::Ports::StorageMgmtPort
187     properties:
188       ControlPlaneIP: {get_attr: [NovaCompute, networks, ctlplane, 0]}
189       IPPool: {get_param: NovaComputeIPs}
190       NodeIndex: {get_param: NodeIndex}
191
192   TenantPort:
193     type: OS::TripleO::Compute::Ports::TenantPort
194     properties:
195       ControlPlaneIP: {get_attr: [NovaCompute, networks, ctlplane, 0]}
196       IPPool: {get_param: NovaComputeIPs}
197       NodeIndex: {get_param: NodeIndex}
198
199   ManagementPort:
200     type: OS::TripleO::Compute::Ports::ManagementPort
201     properties:
202       ControlPlaneIP: {get_attr: [NovaCompute, networks, ctlplane, 0]}
203       IPPool: {get_param: NovaComputeIPs}
204       NodeIndex: {get_param: NodeIndex}
205
206   NetIpMap:
207     type: OS::TripleO::Network::Ports::NetIpMap
208     properties:
209       ControlPlaneIp: {get_attr: [NovaCompute, networks, ctlplane, 0]}
210       ExternalIp: {get_attr: [ExternalPort, ip_address]}
211       ExternalIpSubnet: {get_attr: [ExternalPort, ip_subnet]}
212       ExternalIpUri: {get_attr: [ExternalPort, ip_address_uri]}
213       InternalApiIp: {get_attr: [InternalApiPort, ip_address]}
214       InternalApiIpSubnet: {get_attr: [InternalApiPort, ip_subnet]}
215       InternalApiIpUri: {get_attr: [InternalApiPort, ip_address_uri]}
216       StorageIp: {get_attr: [StoragePort, ip_address]}
217       StorageIpSubnet: {get_attr: [StoragePort, ip_subnet]}
218       StorageIpUri: {get_attr: [StoragePort, ip_address_uri]}
219       StorageMgmtIp: {get_attr: [StorageMgmtPort, ip_address]}
220       StorageMgmtIpSubnet: {get_attr: [StorageMgmtPort, ip_subnet]}
221       StorageMgmtIpUri: {get_attr: [StorageMgmtPort, ip_address_uri]}
222       TenantIp: {get_attr: [TenantPort, ip_address]}
223       TenantIpSubnet: {get_attr: [TenantPort, ip_subnet]}
224       TenantIpUri: {get_attr: [TenantPort, ip_address_uri]}
225       ManagementIp: {get_attr: [ManagementPort, ip_address]}
226       ManagementIpSubnet: {get_attr: [ManagementPort, ip_subnet]}
227       ManagementIpUri: {get_attr: [ManagementPort, ip_address_uri]}
228
229   NetHostMap:
230     type: OS::Heat::Value
231     properties:
232       type: json
233       value:
234         external:
235           fqdn:
236             list_join:
237             - '.'
238             - - {get_attr: [NovaCompute, name]}
239               - external
240               - {get_param: CloudDomain}
241           short:
242             list_join:
243             - '.'
244             - - {get_attr: [NovaCompute, name]}
245               - external
246         internal_api:
247           fqdn:
248             list_join:
249             - '.'
250             - - {get_attr: [NovaCompute, name]}
251               - internalapi
252               - {get_param: CloudDomain}
253           short:
254             list_join:
255             - '.'
256             - - {get_attr: [NovaCompute, name]}
257               - internalapi
258         storage:
259           fqdn:
260             list_join:
261             - '.'
262             - - {get_attr: [NovaCompute, name]}
263               - storage
264               - {get_param: CloudDomain}
265           short:
266             list_join:
267             - '.'
268             - - {get_attr: [NovaCompute, name]}
269               - storage
270         storage_mgmt:
271           fqdn:
272             list_join:
273             - '.'
274             - - {get_attr: [NovaCompute, name]}
275               - storagemgmt
276               - {get_param: CloudDomain}
277           short:
278             list_join:
279             - '.'
280             - - {get_attr: [NovaCompute, name]}
281               - storagemgmt
282         tenant:
283           fqdn:
284             list_join:
285             - '.'
286             - - {get_attr: [NovaCompute, name]}
287               - tenant
288               - {get_param: CloudDomain}
289           short:
290             list_join:
291             - '.'
292             - - {get_attr: [NovaCompute, name]}
293               - tenant
294         management:
295           fqdn:
296             list_join:
297             - '.'
298             - - {get_attr: [NovaCompute, name]}
299               - management
300               - {get_param: CloudDomain}
301           short:
302             list_join:
303             - '.'
304             - - {get_attr: [NovaCompute, name]}
305               - management
306         ctlplane:
307           fqdn:
308             list_join:
309             - '.'
310             - - {get_attr: [NovaCompute, name]}
311               - ctlplane
312               - {get_param: CloudDomain}
313           short:
314             list_join:
315             - '.'
316             - - {get_attr: [NovaCompute, name]}
317               - ctlplane
318
319   NetworkConfig:
320     type: OS::TripleO::Compute::Net::SoftwareConfig
321     properties:
322       ControlPlaneIp: {get_attr: [NovaCompute, networks, ctlplane, 0]}
323       ExternalIpSubnet: {get_attr: [ExternalPort, ip_subnet]}
324       InternalApiIpSubnet: {get_attr: [InternalApiPort, ip_subnet]}
325       StorageIpSubnet: {get_attr: [StoragePort, ip_subnet]}
326       StorageMgmtIpSubnet: {get_attr: [StorageMgmtPort, ip_subnet]}
327       TenantIpSubnet: {get_attr: [TenantPort, ip_subnet]}
328       ManagementIpSubnet: {get_attr: [ManagementPort, ip_subnet]}
329
330   NetworkDeployment:
331     type: OS::TripleO::SoftwareDeployment
332     properties:
333       name: NetworkDeployment
334       config: {get_resource: NetworkConfig}
335       server: {get_resource: NovaCompute}
336       actions: {get_param: NetworkDeploymentActions}
337       input_values:
338         bridge_name: {get_param: NeutronPhysicalBridge}
339         interface_name: {get_param: NeutronPublicInterface}
340
341   NovaComputeConfig:
342     type: OS::Heat::StructuredConfig
343     properties:
344       group: hiera
345       config:
346         hierarchy:
347           - '"%{::uuid}"'
348           - heat_config_%{::deploy_config_name}
349           - compute_extraconfig
350           - extraconfig
351           - service_names
352           - service_configs
353           - compute
354           - bootstrap_node # provided by allNodesConfig
355           - all_nodes # provided by allNodesConfig
356           - vip_data # provided by allNodesConfig
357           - '"%{::osfamily}"'
358           - neutron_bigswitch_data # Optionally provided by ComputeExtraConfigPre
359           - cisco_n1kv_data  # Optionally provided by ComputeExtraConfigPre
360           - nova_nuage_data  # Optionally provided by ComputeExtraConfigPre
361           - midonet_data # Optionally provided by AllNodesExtraConfig
362           - neutron_opencontrail_data  # Optionally provided by ComputeExtraConfigPre
363           - cisco_aci_data # Optionally provided by ComputeExtraConfigPre
364         merge_behavior: deeper
365         datafiles:
366           service_names:
367             service_names: {get_param: ServiceNames}
368             sensu::subscriptions: {get_param: MonitoringSubscriptions}
369           service_configs:
370             map_replace:
371               - {get_param: ServiceConfigSettings}
372               - values: {get_attr: [NetIpMap, net_ip_map]}
373           compute_extraconfig: {get_param: NovaComputeExtraConfig}
374           extraconfig: {get_param: ExtraConfig}
375           compute:
376             tripleo::packages::enable_upgrade: {get_input: enable_package_upgrade}
377             fqdn_internal_api: {get_attr: [NetHostMap, value, internal_api, fqdn]}
378             fqdn_storage: {get_attr: [NetHostMap, value, storage, fqdn]}
379             fqdn_storage_mgmt: {get_attr: [NetHostMap, value, storage_mgmt, fqdn]}
380             fqdn_tenant: {get_attr: [NetHostMap, value, tenant, fqdn]}
381             fqdn_management: {get_attr: [NetHostMap, value, management, fqdn]}
382             fqdn_ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]}
383
384   NovaComputeDeployment:
385     type: OS::TripleO::SoftwareDeployment
386     depends_on: NetworkDeployment
387     properties:
388       name: NovaComputeDeployment
389       config: {get_resource: NovaComputeConfig}
390       server: {get_resource: NovaCompute}
391       input_values:
392         enable_package_upgrade: {get_attr: [UpdateDeployment, update_managed_packages]}
393
394   # Resource for site-specific injection of root certificate
395   NodeTLSCAData:
396     depends_on: NovaComputeDeployment
397     type: OS::TripleO::NodeTLSCAData
398     properties:
399       server: {get_resource: NovaCompute}
400
401   # Hook for site-specific additional pre-deployment config, e.g extra hieradata
402   ComputeExtraConfigPre:
403     depends_on: NovaComputeDeployment
404     type: OS::TripleO::ComputeExtraConfigPre
405     properties:
406         server: {get_resource: NovaCompute}
407
408   # Hook for site-specific additional pre-deployment config,
409   # applying to all nodes, e.g node registration/unregistration
410   NodeExtraConfig:
411     depends_on: [ComputeExtraConfigPre, NodeTLSCAData]
412     type: OS::TripleO::NodeExtraConfig
413     properties:
414         server: {get_resource: NovaCompute}
415
416   UpdateConfig:
417     type: OS::TripleO::Tasks::PackageUpdate
418
419   UpdateDeployment:
420     type: OS::Heat::SoftwareDeployment
421     properties:
422       name: UpdateDeployment
423       config: {get_resource: UpdateConfig}
424       server: {get_resource: NovaCompute}
425       input_values:
426         update_identifier:
427           get_param: UpdateIdentifier
428
429 outputs:
430   ip_address:
431     description: IP address of the server in the ctlplane network
432     value: {get_attr: [NovaCompute, networks, ctlplane, 0]}
433   external_ip_address:
434     description: IP address of the server in the external network
435     value: {get_attr: [ExternalPort, ip_address]}
436   internal_api_ip_address:
437     description: IP address of the server in the internal_api network
438     value: {get_attr: [InternalApiPort, ip_address]}
439   storage_ip_address:
440     description: IP address of the server in the storage network
441     value: {get_attr: [StoragePort, ip_address]}
442   storage_mgmt_ip_address:
443     description: IP address of the server in the storage_mgmt network
444     value: {get_attr: [StorageMgmtPort, ip_address]}
445   tenant_ip_address:
446     description: IP address of the server in the tenant network
447     value: {get_attr: [TenantPort, ip_address]}
448   management_ip_address:
449     description: IP address of the server in the management network
450     value: {get_attr: [ManagementPort, ip_address]}
451   hostname:
452     description: Hostname of the server
453     value: {get_attr: [NovaCompute, name]}
454   hostname_map:
455     description: Mapping of network names to hostnames
456     value:
457       external: {get_attr: [NetHostMap, value, external, fqdn]}
458       internal_api: {get_attr: [NetHostMap, value, internal_api, fqdn]}
459       storage: {get_attr: [NetHostMap, value, storage, fqdn]}
460       storage_mgmt: {get_attr: [NetHostMap, value, storage_mgmt, fqdn]}
461       tenant: {get_attr: [NetHostMap, value, tenant, fqdn]}
462       management: {get_attr: [NetHostMap, value, management, fqdn]}
463       ctlplane: {get_attr: [NetHostMap, value, ctlplane, fqdn]}
464   hosts_entry:
465     description: >
466       Server's IP address and hostname in the /etc/hosts format
467     value:
468       str_replace:
469         template: |
470           PRIMARYIP PRIMARYHOST.DOMAIN PRIMARYHOST
471           EXTERNALIP EXTERNALHOST.DOMAIN EXTERNALHOST
472           INTERNAL_APIIP INTERNAL_APIHOST.DOMAIN INTERNAL_APIHOST
473           STORAGEIP STORAGEHOST.DOMAIN STORAGEHOST
474           STORAGE_MGMTIP STORAGE_MGMTHOST.DOMAIN STORAGE_MGMTHOST
475           TENANTIP TENANTHOST.DOMAIN TENANTHOST
476           MANAGEMENTIP MANAGEMENTHOST.DOMAIN MANAGEMENTHOST
477           CTLPLANEIP CTLPLANEHOST.DOMAIN CTLPLANEHOST
478         params:
479           PRIMARYIP: {get_attr: [NetIpMap, net_ip_map, {get_param: [ServiceNetMap, ComputeHostnameResolveNetwork]}]}
480           DOMAIN: {get_param: CloudDomain}
481           PRIMARYHOST: {get_attr: [NovaCompute, name]}
482           EXTERNALIP: {get_attr: [ExternalPort, ip_address]}
483           EXTERNALHOST: {get_attr: [NetHostMap, value, external, short]}
484           INTERNAL_APIIP: {get_attr: [InternalApiPort, ip_address]}
485           INTERNAL_APIHOST: {get_attr: [NetHostMap, value, internal_api, short]}
486           STORAGEIP: {get_attr: [StoragePort, ip_address]}
487           STORAGEHOST: {get_attr: [NetHostMap, value, storage, short]}
488           STORAGE_MGMTIP: {get_attr: [StorageMgmtPort, ip_address]}
489           STORAGE_MGMTHOST: {get_attr: [NetHostMap, value, storage_mgmt, short]}
490           TENANTIP: {get_attr: [TenantPort, ip_address]}
491           TENANTHOST: {get_attr: [NetHostMap, value, tenant, short]}
492           MANAGEMENTIP: {get_attr: [ManagementPort, ip_address]}
493           MANAGEMENTHOST: {get_attr: [NetHostMap, value, management, short]}
494           CTLPLANEIP: {get_attr: [NovaCompute, networks, ctlplane, 0]}
495           CTLPLANEHOST: {get_attr: [NetHostMap, value, ctlplane, short]}
496   nova_server_resource:
497     description: Heat resource handle for the Nova compute server
498     value:
499       {get_resource: NovaCompute}