Change flat network name for nosdn fdio scenario
[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   DockerConfigScripts:
93     type: OS::Heat::Value
94     properties:
95       type: json
96       value:
97         yaql:
98           expression:
99             # select 'docker_config_scripts' only from services that have it
100             coalesce($.data.service_names, []).zip(coalesce($.data.docker_config_scripts, [])).where($[1] != null).select($[1]).reduce($1.mergeWith($2), {})
101           data:
102             service_names: {get_attr: [ServiceChain, role_data, service_names]}
103             docker_config_scripts: {get_attr: [ServiceChain, role_data, docker_config_scripts]}
104
105   CellV2Discovery:
106     type: OS::Heat::Value
107     properties:
108       type: boolean
109       value:
110         yaql:
111           expression:
112             # If any service in this role requires cellv2_discovery then this value is true
113             coalesce($.data.cellv2_discovery, []).contains(true)
114           data:
115             cellv2_discovery: {get_attr: [ServiceChain, role_data, cellv2_discovery]}
116
117   LoggingSourcesConfig:
118     type: OS::Heat::Value
119     properties:
120       type: comma_delimited_list
121       value:
122         # Transform the individual logging_source configuration from
123         # each service in the chain into a global list, adding some
124         # default configuration at the same time.
125         yaql:
126           expression: >
127             let(
128             default_format => coalesce($.data.default_format, ''),
129             pos_file_path => coalesce($.data.pos_file_path, ''),
130             sources => coalesce($.data.sources, {}).flatten()
131             ) ->
132             $sources.where($ != null).select({
133             'type' => 'tail',
134             'tag' => $.tag,
135             'path' => $.path,
136             'format' => $.get('format', $default_format),
137             'pos_file' => $.get('pos_file', $pos_file_path + '/' + $.tag + '.pos')
138             })
139           data:
140             sources:
141               - {get_attr: [LoggingConfiguration, LoggingDefaultSources]}
142               - yaql:
143                   expression: list(coalesce($.data.role_data, []).where($ != null).select($.get('logging_source')).where($ != null))
144                   data: {role_data: {get_attr: [ServiceChain, role_data]}}
145
146               - {get_attr: [LoggingConfiguration, LoggingExtraSources]}
147             default_format: {get_attr: [LoggingConfiguration, LoggingDefaultFormat]}
148             pos_file_path: {get_attr: [LoggingConfiguration, LoggingPosFilePath]}
149
150   LoggingGroupsConfig:
151     type: OS::Heat::Value
152     properties:
153       type: comma_delimited_list
154       value:
155         # Build a list of unique groups to which we should add the
156         # fluentd user.
157         yaql:
158           expression: >
159             set((coalesce($.data.default, []) + coalesce($.data.extra, []) + coalesce($.data.role_data, []).where($ != null).select($.get('logging_groups'))).flatten()).where($)
160           data:
161             default: {get_attr: [LoggingConfiguration, LoggingDefaultGroups]}
162             extra: {get_attr: [LoggingConfiguration, LoggingExtraGroups]}
163             role_data: {get_attr: [ServiceChain, role_data]}
164
165   MonitoringSubscriptionsConfig:
166     type: OS::Heat::Value
167     properties:
168       type: comma_delimited_list
169       value:
170         yaql:
171           expression: list(coalesce($.data.role_data, []).where($ != null).select($.get('monitoring_subscription')).where($ != null))
172           data: {role_data: {get_attr: [ServiceChain, role_data]}}
173
174   ServiceNames:
175     type: OS::Heat::Value
176     properties:
177       type: comma_delimited_list
178       value:
179         filter:
180           - [null]
181           - {get_attr: [ServiceChain, role_data, service_name]}
182
183   GlobalConfigSettings:
184     type: OS::Heat::Value
185     properties:
186       type: json
187       value:
188         map_merge:
189           yaql:
190             expression: list(coalesce($.data.role_data, []).where($ != null).select($.get('global_config_settings')).where($ != null))
191             data: {role_data: {get_attr: [ServiceChain, role_data]}}
192
193   ServiceConfigSettings:
194     type: OS::Heat::Value
195     properties:
196       type: json
197       value:
198         yaql:
199           expression: coalesce($.data.role_data, []).where($ != null).select($.get('service_config_settings')).where($ != null).reduce($1.mergeWith($2), {})
200           data: {role_data: {get_attr: [ServiceChain, role_data]}}
201
202   WorkflowTasks:
203     type: OS::Heat::Value
204     properties:
205       type: json
206       value:
207         yaql:
208           expression: coalesce($.data.role_data, []).where($ != null).select($.get('workflow_tasks')).where($ != null).reduce($1.mergeWith($2), {})
209           data: {role_data: {get_attr: [ServiceChain, role_data]}}
210
211   UpgradeTasks:
212     type: OS::Heat::Value
213     properties:
214       type: comma_delimited_list
215       value:
216         yaql:
217           # Note we use distinct() here to filter any identical tasks, e.g yum update for all services
218           expression: coalesce($.data, []).where($ != null).select($.get('upgrade_tasks')).where($ != null).flatten().distinct()
219           data: {get_attr: [ServiceChain, role_data]}
220
221   PostUpgradeTasks:
222     type: OS::Heat::Value
223     properties:
224       type: comma_delimited_list
225       value:
226         yaql:
227           # Note we use distinct() here to filter any identical tasks, e.g yum update for all services
228           expression: coalesce($.data, []).where($ != null).select($.get('post_upgrade_tasks')).where($ != null).flatten().distinct()
229           data: {get_attr: [ServiceChain, role_data]}
230
231   UpdateTasks:
232     type: OS::Heat::Value
233     properties:
234       type: comma_delimited_list
235       value:
236         yaql:
237           # Note we use distinct() here to filter any identical tasks, e.g yum update for all services
238           expression: coalesce($.data, []).where($ != null).select($.get('update_tasks')).where($ != null).flatten().distinct()
239           data: {get_attr: [ServiceChain, role_data]}
240
241   UpgradeBatchTasks:
242     type: OS::Heat::Value
243     properties:
244       type: comma_delimited_list
245       value:
246         yaql:
247           expression: coalesce($.data, []).where($ != null).select($.get('upgrade_batch_tasks')).where($ != null).flatten().distinct()
248           data: {get_attr: [ServiceChain, role_data]}
249
250   PuppetConfig:
251     type: OS::Heat::Value
252     properties:
253       type: comma_delimited_list
254       value:
255         yaql:
256           expression: coalesce($.data, []).where($ != null).select($.get('puppet_config')).where($ != null).distinct()
257           data: {get_attr: [ServiceChain, role_data]}
258
259   KollaConfig:
260     type: OS::Heat::Value
261     properties:
262       type: json
263       value:
264         yaql:
265           expression: coalesce($.data.role_data, []).where($ != null).select($.get('kolla_config')).where($ != null).reduce($1.mergeWith($2), {})
266           data: {role_data: {get_attr: [ServiceChain, role_data]}}
267
268   DockerPuppetTasks:
269     type: OS::Heat::Value
270     properties:
271       type: json
272       value:
273         yaql:
274           expression: dict(coalesce($.data, []).where($ != null).select($.get('docker_puppet_tasks')).where($ != null).selectMany($.items()).groupBy($[0], $[1]))
275           data: {get_attr: [ServiceChain, role_data]}
276
277   HostPrepTasks:
278     type: OS::Heat::Value
279     properties:
280       type: comma_delimited_list
281       value:
282         yaql:
283           # Note we use distinct() here to filter any identical tasks
284           expression: coalesce($.data, []).where($ != null).select($.get('host_prep_tasks')).where($ != null).flatten().distinct()
285           data: {get_attr: [ServiceChain, role_data]}
286
287 outputs:
288   role_data:
289     description: Combined Role data for this set of services.
290     value:
291       service_names: {get_attr: [ServiceNames, value]}
292       monitoring_subscriptions: {get_attr: [MonitoringSubscriptionsConfig, value]}
293       logging_sources: {get_attr: [LoggingSourcesConfig, value]}
294       logging_groups: {get_attr: [LoggingGroupsConfig, value]}
295       config_settings: {map_merge: {get_attr: [ServiceChain, role_data, config_settings]}}
296       global_config_settings: {get_attr: [GlobalConfigSettings, value]}
297       service_config_settings: {get_attr: [ServiceConfigSettings, value]}
298       workflow_tasks: {get_attr: [WorkflowTasks, value]}
299       step_config: {get_attr: [PuppetStepConfig, value]}
300       upgrade_tasks: {get_attr: [UpgradeTasks, value]}
301       post_upgrade_tasks: {get_attr: [PostUpgradeTasks, value]}
302       update_tasks: {get_attr: [UpdateTasks, value]}
303       upgrade_batch_tasks: {get_attr: [UpgradeBatchTasks, value]}
304       service_metadata_settings: {get_attr: [ServiceServerMetadataHook, metadata]}
305
306       # Keys to support docker/services
307       puppet_config: {get_attr: [PuppetConfig, value]}
308       kolla_config: {get_attr: [KollaConfig, value]}
309       docker_config: {get_attr: [DockerConfig, value]}
310       docker_config_scripts: {get_attr: [DockerConfigScripts, value]}
311       docker_puppet_tasks: {get_attr: [DockerPuppetTasks, value]}
312       host_prep_tasks: {get_attr: [HostPrepTasks, value]}
313       cellv2_discovery: {get_attr: [CellV2Discovery, value]}