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