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