Merge "Move step_config/docker_config calculation into services.yaml"
[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: Role Specific parameters to be provided to service
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 outputs:
93   role_data:
94     description: Combined Role data for this set of services.
95     value:
96       service_names:
97         {get_attr: [ServiceChain, role_data, service_name]}
98       monitoring_subscriptions:
99         yaql:
100           expression: list($.data.role_data.where($ != null).select($.get('monitoring_subscription')).where($ != null))
101           data: {role_data: {get_attr: [ServiceChain, role_data]}}
102       logging_sources:
103         # Transform the individual logging_source configuration from
104         # each service in the chain into a global list, adding some
105         # default configuration at the same time.
106         yaql:
107           expression: >
108             let(
109             default_format => $.data.default_format,
110             pos_file_path => $.data.pos_file_path,
111             sources => $.data.sources.flatten()
112             ) ->
113             $sources.where($ != null).select({
114             'type' => 'tail',
115             'tag' => $.tag,
116             'path' => $.path,
117             'format' => $.get('format', $default_format),
118             'pos_file' => $.get('pos_file', $pos_file_path + '/' + $.tag + '.pos')
119             })
120           data:
121             sources:
122               - {get_attr: [LoggingConfiguration, LoggingDefaultSources]}
123               - yaql:
124                   expression: list($.data.role_data.where($ != null).select($.get('logging_source')).where($ != null))
125                   data: {role_data: {get_attr: [ServiceChain, role_data]}}
126
127               - {get_attr: [LoggingConfiguration, LoggingExtraSources]}
128             default_format: {get_attr: [LoggingConfiguration, LoggingDefaultFormat]}
129             pos_file_path: {get_attr: [LoggingConfiguration, LoggingPosFilePath]}
130       logging_groups:
131         # Build a list of unique groups to which we should add the
132         # fluentd user.
133         yaql:
134           expression: >
135             set(($.data.default + $.data.extra + $.data.role_data.where($ != null).select($.get('logging_groups'))).flatten()).where($)
136           data:
137             default: {get_attr: [LoggingConfiguration, LoggingDefaultGroups]}
138             extra: {get_attr: [LoggingConfiguration, LoggingExtraGroups]}
139             role_data: {get_attr: [ServiceChain, role_data]}
140       config_settings: {map_merge: {get_attr: [ServiceChain, role_data, config_settings]}}
141       global_config_settings:
142         map_merge:
143           yaql:
144             expression: list($.data.role_data.where($ != null).select($.get('global_config_settings')).where($ != null))
145             data: {role_data: {get_attr: [ServiceChain, role_data]}}
146       service_config_settings:
147         yaql:
148           expression: $.data.role_data.where($ != null).select($.get('service_config_settings')).where($ != null).reduce($1.mergeWith($2), {})
149           data: {role_data: {get_attr: [ServiceChain, role_data]}}
150       service_workflow_tasks:
151         yaql:
152           expression: $.data.role_data.where($ != null).select($.get('service_workflow_tasks')).where($ != null).reduce($1.mergeWith($2), {})
153           data: {role_data: {get_attr: [ServiceChain, role_data]}}
154       step_config: {get_attr: [PuppetStepConfig, value]}
155       upgrade_tasks:
156         yaql:
157           # Note we use distinct() here to filter any identical tasks, e.g yum update for all services
158           expression: $.data.where($ != null).select($.get('upgrade_tasks')).where($ != null).flatten().distinct()
159           data: {get_attr: [ServiceChain, role_data]}
160       upgrade_batch_tasks:
161         yaql:
162           # Note we use distinct() here to filter any identical tasks, e.g yum update for all services
163           expression: $.data.where($ != null).select($.get('upgrade_batch_tasks')).where($ != null).flatten().distinct()
164           data: {get_attr: [ServiceChain, role_data]}
165       service_metadata_settings: {get_attr: [ServiceServerMetadataHook, metadata]}
166
167       # Keys to support docker/services
168       puppet_config: {get_attr: [ServiceChain, role_data, puppet_config]}
169       kolla_config:
170         map_merge: {get_attr: [ServiceChain, role_data, kolla_config]}
171       docker_config:
172         {get_attr: [DockerConfig, value]}
173       docker_puppet_tasks:
174         {get_attr: [ServiceChain, role_data, docker_puppet_tasks]}
175       host_prep_tasks:
176         yaql:
177           # Note we use distinct() here to filter any identical tasks
178           expression: $.data.where($ != null).select($.get('host_prep_tasks')).where($ != null).flatten().distinct()
179           data: {get_attr: [ServiceChain, role_data]}