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