7d36b46cfbb2634d4538afecb1efb0850364b754
[apex-tripleo-heat-templates.git] / puppet / ceph-storage.yaml
1 heat_template_version: 2015-04-30
2 description: 'OpenStack ceph storage node configured by Puppet'
3 parameters:
4   Flavor:
5     description: Flavor for the Ceph Storage node.
6     type: string
7     constraints:
8       - custom_constraint: nova.flavor
9   Image:
10     type: string
11     default: overcloud-ceph-storage
12     constraints:
13       - custom_constraint: glance.image
14   ImageUpdatePolicy:
15     default: 'REBUILD_PRESERVE_EPHEMERAL'
16     description: What policy to use when reconstructing instances. REBUILD for rebuilds, REBUILD_PRESERVE_EPHEMERAL to preserve /mnt.
17     type: string
18   KeyName:
19     description: Name of an existing EC2 KeyPair to enable SSH access to the instances
20     type: string
21     default: default
22     constraints:
23       - custom_constraint: nova.keypair
24   NtpServer:
25     default: ''
26     description: Comma-separated list of ntp servers
27     type: comma_delimited_list
28   EnablePackageInstall:
29     default: 'false'
30     description: Set to true to enable package installation via Puppet
31     type: boolean
32   ServiceNetMap:
33     default: {}
34     description: Mapping of service_name -> network name. Typically set
35                  via parameter_defaults in the resource registry.
36     type: json
37   UpdateIdentifier:
38     default: ''
39     type: string
40     description: >
41       Setting to a previously unused value during stack-update will trigger
42       package update on all nodes
43   Hostname:
44     type: string
45     default: '' # Defaults to Heat created hostname
46   ExtraConfig:
47     default: {}
48     description: |
49       Additional hiera configuration to inject into the cluster. Note
50       that CephStorageExtraConfig takes precedence over ExtraConfig.
51     type: json
52   CephStorageExtraConfig:
53     default: {}
54     description: |
55       Role specific additional hiera configuration to inject into the cluster.
56     type: json
57   NetworkDeploymentActions:
58     type: comma_delimited_list
59     description: >
60       Heat action when to apply network configuration changes
61     default: ['CREATE']
62
63 resources:
64   CephStorage:
65     type: OS::Nova::Server
66     properties:
67       image: {get_param: Image}
68       image_update_policy: {get_param: ImageUpdatePolicy}
69       flavor: {get_param: Flavor}
70       key_name: {get_param: KeyName}
71       networks:
72         - network: ctlplane
73       user_data_format: SOFTWARE_CONFIG
74       user_data: {get_resource: UserData}
75       name: {get_param: Hostname}
76
77   # Combine the NodeAdminUserData and NodeUserData mime archives
78   UserData:
79     type: OS::Heat::MultipartMime
80     properties:
81       parts:
82       - config: {get_resource: NodeAdminUserData}
83         type: multipart
84       - config: {get_resource: NodeUserData}
85         type: multipart
86
87   # Creates the "heat-admin" user if configured via the environment
88   # Should return a OS::Heat::MultipartMime reference via OS::stack_id
89   NodeAdminUserData:
90     type: OS::TripleO::NodeAdminUserData
91
92   # For optional operator additional userdata
93   # Should return a OS::Heat::MultipartMime reference via OS::stack_id
94   NodeUserData:
95     type: OS::TripleO::NodeUserData
96
97   StoragePort:
98     type: OS::TripleO::CephStorage::Ports::StoragePort
99     properties:
100       ControlPlaneIP: {get_attr: [CephStorage, networks, ctlplane, 0]}
101
102   StorageMgmtPort:
103     type: OS::TripleO::CephStorage::Ports::StorageMgmtPort
104     properties:
105       ControlPlaneIP: {get_attr: [CephStorage, networks, ctlplane, 0]}
106
107   NetworkConfig:
108     type: OS::TripleO::CephStorage::Net::SoftwareConfig
109     properties:
110       ControlPlaneIp: {get_attr: [CephStorage, networks, ctlplane, 0]}
111       StorageIpSubnet: {get_attr: [StoragePort, ip_subnet]}
112       StorageMgmtIpSubnet: {get_attr: [StorageMgmtPort, ip_subnet]}
113
114   NetIpMap:
115     type: OS::TripleO::Network::Ports::NetIpMap
116     properties:
117       ControlPlaneIp: {get_attr: [CephStorage, networks, ctlplane, 0]}
118       StorageIp: {get_attr: [StoragePort, ip_address]}
119       StorageMgmtIp: {get_attr: [StorageMgmtPort, ip_address]}
120
121   NetIpSubnetMap:
122     type: OS::TripleO::Network::Ports::NetIpSubnetMap
123     properties:
124       ControlPlaneIp: {get_attr: [CephStorage, networks, ctlplane, 0]}
125       StorageIpSubnet: {get_attr: [StoragePort, ip_subnet]}
126       StorageMgmtIpSubnet: {get_attr: [StorageMgmtPort, ip_subnet]}
127
128   NetworkDeployment:
129     type: OS::TripleO::SoftwareDeployment
130     properties:
131       config: {get_resource: NetworkConfig}
132       server: {get_resource: CephStorage}
133       actions: {get_param: NetworkDeploymentActions}
134
135   CephStorageDeployment:
136     type: OS::Heat::StructuredDeployment
137     depends_on: NetworkDeployment
138     properties:
139       config: {get_resource: CephStorageConfig}
140       server: {get_resource: CephStorage}
141       input_values:
142         ntp_servers: {get_param: NtpServer}
143         enable_package_install: {get_param: EnablePackageInstall}
144         enable_package_upgrade: {get_attr: [UpdateDeployment, update_managed_packages]}
145         ceph_cluster_network: {get_attr: [NetIpSubnetMap, net_ip_subnet_map, {get_param: [ServiceNetMap, CephClusterNetwork]}]}
146         ceph_public_network: {get_attr: [NetIpSubnetMap, net_ip_subnet_map, {get_param: [ServiceNetMap, CephPublicNetwork]}]}
147
148   CephStorageConfig:
149     type: OS::Heat::StructuredConfig
150     properties:
151       group: os-apply-config
152       config:
153         hiera:
154           hierarchy:
155             - '"%{::uuid}"'
156             - heat_config_%{::deploy_config_name}
157             - ceph_extraconfig
158             - extraconfig
159             - ceph_cluster # provided by CephClusterConfig
160             - ceph
161             - '"%{::osfamily}"'
162             - common
163           datafiles:
164             common:
165               raw_data: {get_file: hieradata/common.yaml}
166             ceph_extraconfig:
167               mapped_data: {get_param: CephStorageExtraConfig}
168             extraconfig:
169               mapped_data: {get_param: ExtraConfig}
170             ceph:
171               raw_data: {get_file: hieradata/ceph.yaml}
172               mapped_data:
173                 ntp::servers: {get_input: ntp_servers}
174                 tripleo::packages::enable_install: {get_input: enable_package_install}
175                 tripleo::packages::enable_upgrade: {get_input: enable_package_upgrade}
176                 ceph::profile::params::cluster_network: {get_input: ceph_cluster_network}
177                 ceph::profile::params::public_network: {get_input: ceph_public_network}
178
179   # Resource for site-specific injection of root certificate
180   NodeTLSCAData:
181     depends_on: CephStorageDeployment
182     type: OS::TripleO::NodeTLSCAData
183     properties:
184       server: {get_resource: CephStorage}
185
186   # Hook for site-specific additional pre-deployment config, e.g extra hieradata
187   CephStorageExtraConfigPre:
188     depends_on: CephStorageDeployment
189     type: OS::TripleO::CephStorageExtraConfigPre
190     properties:
191         server: {get_resource: CephStorage}
192
193   # Hook for site-specific additional pre-deployment config,
194   # applying to all nodes, e.g node registration/unregistration
195   NodeExtraConfig:
196     depends_on: [CephStorageExtraConfigPre, NodeTLSCAData]
197     type: OS::TripleO::NodeExtraConfig
198     properties:
199         server: {get_resource: CephStorage}
200
201   UpdateConfig:
202     type: OS::TripleO::Tasks::PackageUpdate
203
204   UpdateDeployment:
205     type: OS::Heat::SoftwareDeployment
206     properties:
207       config: {get_resource: UpdateConfig}
208       server: {get_resource: CephStorage}
209       input_values:
210         update_identifier:
211           get_param: UpdateIdentifier
212
213 outputs:
214   hosts_entry:
215     value:
216       str_replace:
217         template: "IP HOST.localdomain HOST"
218         params:
219           IP: {get_attr: [NetIpMap, net_ip_map, {get_param: [ServiceNetMap, CephStorageHostnameResolveNetwork]}]}
220           HOST: {get_attr: [CephStorage, name]}
221   nova_server_resource:
222     description: Heat resource handle for the ceph storage server
223     value:
224       {get_resource: CephStorage}
225   storage_ip_address:
226     description: IP address of the server in the storage network
227     value: {get_attr: [StoragePort, ip_address]}
228   storage_mgmt_ip_address:
229     description: IP address of the server in the storage_mgmt network
230     value: {get_attr: [StorageMgmtPort, ip_address]}
231   config_identifier:
232     description: identifier which changes if the node configuration may need re-applying
233     value:
234       list_join:
235       - ','
236       - - {get_attr: [CephStorageDeployment, deploy_stdout]}
237         - {get_attr: [NodeTLSCAData, deploy_stdout]}
238         - {get_attr: [CephStorageExtraConfigPre, deploy_stdout]}
239         - {get_param: UpdateIdentifier}