a0015c7eff869df8c756f3304e82986b4580187e
[apex-tripleo-heat-templates.git] / common / services.yaml
1 heat_template_version: pike
2
3 description: >
4   Utility stack to convert an array of services into a set of combined
5   role configs.
6
7 parameters:
8   Services:
9     default: []
10     description: |
11         List nested stack service templates.
12     type: comma_delimited_list
13   ServiceData:
14     default: {}
15     description: Dictionary packing service data
16     type: json
17   ServiceNetMap:
18     default: {}
19     description: Mapping of service_name -> network name. Typically set
20                  via parameter_defaults in the resource registry.  This
21                  mapping overrides those in ServiceNetMapDefaults.
22     type: json
23   EndpointMap:
24     default: {}
25     description: Mapping of service endpoint -> protocol. Typically set
26                  via parameter_defaults in the resource registry.
27     type: json
28   DefaultPasswords:
29     default: {}
30     description: Mapping of service -> default password. Used to help
31                  pass top level passwords managed by Heat into services.
32     type: json
33   RoleName:
34     default: ''
35     description: Role name on which the service is applied
36     type: string
37   RoleParameters:
38     description: Parameters specific to the role
39     default: {}
40     type: json
41
42 resources:
43
44   ServiceChain:
45     type: OS::Heat::ResourceChain
46     properties:
47       resources: {get_param: Services}
48       concurrent: true
49       resource_properties:
50         ServiceData: {get_param: ServiceData}
51         ServiceNetMap: {get_param: ServiceNetMap}
52         EndpointMap: {get_param: EndpointMap}
53         DefaultPasswords: {get_param: DefaultPasswords}
54         RoleName: {get_param: RoleName}
55         RoleParameters: {get_param: RoleParameters}
56
57   LoggingConfiguration:
58     type: OS::TripleO::LoggingConfiguration
59
60   ServiceServerMetadataHook:
61     type: OS::TripleO::ServiceServerMetadataHook
62     properties:
63       RoleData: {get_attr: [ServiceChain, role_data]}
64
65   PuppetStepConfig:
66     type: OS::Heat::Value
67     properties:
68       type: string
69       value:
70         yaql:
71           expression:
72             # select 'step_config' only from services that do not have a docker_config
73             coalesce($.data.service_names, []).zip(coalesce($.data.step_config, []), coalesce($.data.docker_config, [])).where($[2] = null).where($[1] != null).select($[1]).join("\n")
74           data:
75             service_names: {get_attr: [ServiceChain, role_data, service_name]}
76             step_config: {get_attr: [ServiceChain, role_data, step_config]}
77             docker_config: {get_attr: [ServiceChain, role_data, docker_config]}
78
79   DockerConfig:
80     type: OS::Heat::Value
81     properties:
82       type: json
83       value:
84         yaql:
85           expression:
86             # select 'docker_config' only from services that have it
87             coalesce($.data.service_names, []).zip(coalesce($.data.docker_config, [])).where($[1] != null).select($[1]).reduce($1.mergeWith($2), {})
88           data:
89             service_names: {get_attr: [ServiceChain, role_data, service_names]}
90             docker_config: {get_attr: [ServiceChain, role_data, docker_config]}
91
92   LoggingSourcesConfig:
93     type: OS::Heat::Value
94     properties:
95       type: comma_delimited_list
96       value:
97         # Transform the individual logging_source configuration from
98         # each service in the chain into a global list, adding some
99         # default configuration at the same time.
100         yaql:
101           expression: >
102             let(
103             default_format => coalesce($.data.default_format, ''),
104             pos_file_path => coalesce($.data.pos_file_path, ''),
105             sources => coalesce($.data.sources, {}).flatten()
106             ) ->
107             $sources.where($ != null).select({
108             'type' => 'tail',
109             'tag' => $.tag,
110             'path' => $.path,
111             'format' => $.get('format', $default_format),
112             'pos_file' => $.get('pos_file', $pos_file_path + '/' + $.tag + '.pos')
113             })
114           data:
115             sources:
116               - {get_attr: [LoggingConfiguration, LoggingDefaultSources]}
117               - yaql:
118                   expression: list(coalesce($.data.role_data, []).where($ != null).select($.get('logging_source')).where($ != null))
119                   data: {role_data: {get_attr: [ServiceChain, role_data]}}
120
121               - {get_attr: [LoggingConfiguration, LoggingExtraSources]}
122             default_format: {get_attr: [LoggingConfiguration, LoggingDefaultFormat]}
123             pos_file_path: {get_attr: [LoggingConfiguration, LoggingPosFilePath]}
124
125   LoggingGroupsConfig:
126     type: OS::Heat::Value
127     properties:
128       type: comma_delimited_list
129       value:
130         # Build a list of unique groups to which we should add the
131         # fluentd user.
132         yaql:
133           expression: >
134             set((coalesce($.data.default, []) + coalesce($.data.extra, []) + coalesce($.data.role_data, []).where($ != null).select($.get('logging_groups'))).flatten()).where($)
135           data:
136             default: {get_attr: [LoggingConfiguration, LoggingDefaultGroups]}
137             extra: {get_attr: [LoggingConfiguration, LoggingExtraGroups]}
138             role_data: {get_attr: [ServiceChain, role_data]}
139
140   MonitoringSubscriptionsConfig:
141     type: OS::Heat::Value
142     properties:
143       type: comma_delimited_list
144       value:
145         yaql:
146           expression: list(coalesce($.data.role_data, []).where($ != null).select($.get('monitoring_subscription')).where($ != null))
147           data: {role_data: {get_attr: [ServiceChain, role_data]}}
148
149   ServiceNames:
150     type: OS::Heat::Value
151     properties:
152       type: comma_delimited_list
153       value:
154         filter:
155           - [null]
156           - {get_attr: [ServiceChain, role_data, service_name]}
157
158   GlobalConfigSettings:
159     type: OS::Heat::Value
160     properties:
161       type: json
162       value:
163         map_merge:
164           yaql:
165             expression: list(coalesce($.data.role_data, []).where($ != null).select($.get('global_config_settings')).where($ != null))
166             data: {role_data: {get_attr: [ServiceChain, role_data]}}
167
168   ServiceConfigSettings:
169     type: OS::Heat::Value
170     properties:
171       type: json
172       value:
173         yaql:
174           expression: coalesce($.data.role_data, []).where($ != null).select($.get('service_config_settings')).where($ != null).reduce($1.mergeWith($2), {})
175           data: {role_data: {get_attr: [ServiceChain, role_data]}}
176
177   WorkflowTasks:
178     type: OS::Heat::Value
179     properties:
180       type: json
181       value:
182         yaql:
183           expression: coalesce($.data.role_data, []).where($ != null).select($.get('workflow_tasks')).where($ != null).reduce($1.mergeWith($2), {})
184           data: {role_data: {get_attr: [ServiceChain, role_data]}}
185
186   UpgradeTasks:
187     type: OS::Heat::Value
188     properties:
189       type: comma_delimited_list
190       value:
191         yaql:
192           # Note we use distinct() here to filter any identical tasks, e.g yum update for all services
193           expression: coalesce($.data, []).where($ != null).select($.get('upgrade_tasks')).where($ != null).flatten().distinct()
194           data: {get_attr: [ServiceChain, role_data]}
195
196   PostUpgradeTasks:
197     type: OS::Heat::Value
198     properties:
199       type: comma_delimited_list
200       value:
201         yaql:
202           # Note we use distinct() here to filter any identical tasks, e.g yum update for all services
203           expression: coalesce($.data, []).where($ != null).select($.get('post_upgrade_tasks')).where($ != null).flatten().distinct()
204           data: {get_attr: [ServiceChain, role_data]}
205
206   UpdateTasks:
207     type: OS::Heat::Value
208     properties:
209       type: comma_delimited_list
210       value:
211         yaql:
212           # Note we use distinct() here to filter any identical tasks, e.g yum update for all services
213           expression: coalesce($.data, []).where($ != null).select($.get('update_tasks')).where($ != null).flatten().distinct()
214           data: {get_attr: [ServiceChain, role_data]}
215
216   UpgradeBatchTasks:
217     type: OS::Heat::Value
218     properties:
219       type: comma_delimited_list
220       value:
221         yaql:
222           expression: coalesce($.data, []).where($ != null).select($.get('upgrade_batch_tasks')).where($ != null).flatten().distinct()
223           data: {get_attr: [ServiceChain, role_data]}
224
225   PuppetConfig:
226     type: OS::Heat::Value
227     properties:
228       type: comma_delimited_list
229       value:
230         yaql:
231           expression: coalesce($.data, []).where($ != null).select($.get('puppet_config')).where($ != null).distinct()
232           data: {get_attr: [ServiceChain, role_data]}
233
234   KollaConfig:
235     type: OS::Heat::Value
236     properties:
237       type: json
238       value:
239         yaql:
240           expression: coalesce($.data.role_data, []).where($ != null).select($.get('kolla_config')).where($ != null).reduce($1.mergeWith($2), {})
241           data: {role_data: {get_attr: [ServiceChain, role_data]}}
242
243   DockerPuppetTasks:
244     type: OS::Heat::Value
245     properties:
246       type: json
247       value:
248         yaql:
249           expression: dict(coalesce($.data, []).where($ != null).select($.get('docker_puppet_tasks')).where($ != null).selectMany($.items()).groupBy($[0], $[1]))
250           data: {get_attr: [ServiceChain, role_data]}
251
252   HostPrepTasks:
253     type: OS::Heat::Value
254     properties:
255       type: comma_delimited_list
256       value:
257         yaql:
258           # Note we use distinct() here to filter any identical tasks
259           expression: coalesce($.data, []).where($ != null).select($.get('host_prep_tasks')).where($ != null).flatten().distinct()
260           data: {get_attr: [ServiceChain, role_data]}
261
262 outputs:
263   role_data:
264     description: Combined Role data for this set of services.
265     value:
266       service_names: {get_attr: [ServiceNames, value]}
267       monitoring_subscriptions: {get_attr: [MonitoringSubscriptionsConfig, value]}
268       logging_sources: {get_attr: [LoggingSourcesConfig, value]}
269       logging_groups: {get_attr: [LoggingGroupsConfig, value]}
270       config_settings: {map_merge: {get_attr: [ServiceChain, role_data, config_settings]}}
271       global_config_settings: {get_attr: [GlobalConfigSettings, value]}
272       service_config_settings: {get_attr: [ServiceConfigSettings, value]}
273       workflow_tasks: {get_attr: [WorkflowTasks, value]}
274       step_config: {get_attr: [PuppetStepConfig, value]}
275       upgrade_tasks: {get_attr: [UpgradeTasks, value]}
276       post_upgrade_tasks: {get_attr: [PostUpgradeTasks, value]}
277       update_tasks: {get_attr: [UpdateTasks, value]}
278       upgrade_batch_tasks: {get_attr: [UpgradeBatchTasks, value]}
279       service_metadata_settings: {get_attr: [ServiceServerMetadataHook, metadata]}
280
281       # Keys to support docker/services
282       puppet_config: {get_attr: [PuppetConfig, value]}
283       kolla_config: {get_attr: [KollaConfig, value]}
284       docker_config: {get_attr: [DockerConfig, value]}
285       docker_puppet_tasks: {get_attr: [DockerPuppetTasks, value]}
286       host_prep_tasks: {get_attr: [HostPrepTasks, value]}