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