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