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