ffe2d2d43ccfc04e29e7b4fbf5985a3d75cce185
[apex-tripleo-heat-templates.git] / puppet / services / services.yaml
1 heat_template_version: 2016-10-14
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   ServiceNetMap:
14     default: {}
15     description: Mapping of service_name -> network name. Typically set
16                  via parameter_defaults in the resource registry.  This
17                  mapping overrides those in ServiceNetMapDefaults.
18     type: json
19   EndpointMap:
20     default: {}
21     description: Mapping of service endpoint -> protocol. Typically set
22                  via parameter_defaults in the resource registry.
23     type: json
24   DefaultPasswords:
25     default: {}
26     description: Mapping of service -> default password. Used to help
27                  pass top level passwords managed by Heat into services.
28     type: json
29
30 resources:
31
32   ServiceChain:
33     type: OS::Heat::ResourceChain
34     properties:
35       resources: {get_param: Services}
36       concurrent: true
37       resource_properties:
38         ServiceNetMap: {get_param: ServiceNetMap}
39         EndpointMap: {get_param: EndpointMap}
40         DefaultPasswords: {get_param: DefaultPasswords}
41
42   LoggingConfiguration:
43     type: OS::TripleO::LoggingConfiguration
44
45 outputs:
46   role_data:
47     description: Combined Role data for this set of services.
48     value:
49       service_names:
50         # Filter any null/None service_names which may be present due to mapping
51         # of services to OS::Heat::None
52         yaql:
53           expression: list($.data.s_names.where($ != null))
54           data: {s_names: {get_attr: [ServiceChain, role_data, service_name]}}
55       monitoring_subscriptions:
56         yaql:
57           expression: list($.data.role_data.where($ != null).select($.get('monitoring_subscription')).where($ != null))
58           data: {role_data: {get_attr: [ServiceChain, role_data]}}
59       logging_sources:
60         # Transform the individual logging_source configuration from
61         # each service in the chain into a global list, adding some
62         # default configuration at the same time.
63         yaql:
64           expression: >
65             let(
66             default_format => $.data.default_format,
67             pos_file_path => $.data.pos_file_path,
68             sources => $.data.sources.flatten()
69             ) ->
70             $sources.where($ != null).select({
71             'type' => 'tail',
72             'tag' => $.tag,
73             'path' => $.path,
74             'format' => $.get('format', $default_format),
75             'pos_file' => $.get('pos_file', $pos_file_path + '/' + $.tag + '.pos')
76             })
77           data:
78             sources:
79               - {get_attr: [LoggingConfiguration, LoggingDefaultSources]}
80               - yaql:
81                   expression: list($.data.role_data.where($ != null).select($.get('logging_source')).where($ != null))
82                   data: {role_data: {get_attr: [ServiceChain, role_data]}}
83
84               - {get_attr: [LoggingConfiguration, LoggingExtraSources]}
85             default_format: {get_attr: [LoggingConfiguration, LoggingDefaultFormat]}
86             pos_file_path: {get_attr: [LoggingConfiguration, LoggingPosFilePath]}
87       logging_groups:
88         # Build a list of unique groups to which we should add the
89         # fluentd user.
90         yaql:
91           expression: >
92             set($.data.groups.flatten()).where($)
93           data:
94             groups:
95               - [{get_attr: [LoggingConfiguration, LoggingDefaultGroups]}]
96               - yaql:
97                   expression: list($.data.role_data.where($ != null).select($.get('logging_groups')).where($ != null))
98                   data: {role_data: {get_attr: [ServiceChain, role_data]}}
99               - [{get_attr: [LoggingConfiguration, LoggingExtraGroups]}]
100       config_settings: {map_merge: {get_attr: [ServiceChain, role_data, config_settings]}}
101       global_config_settings:
102         map_merge:
103           yaql:
104             expression: list($.data.role_data.where($ != null).select($.get('global_config_settings')).where($ != null))
105             data: {role_data: {get_attr: [ServiceChain, role_data]}}
106       service_config_settings:
107         yaql:
108           expression: $.data.role_data.where($ != null).select($.get('service_config_settings')).where($ != null).reduce($1.mergeWith($2), {})
109           data: {role_data: {get_attr: [ServiceChain, role_data]}}
110       step_config: {list_join: ["\n", {get_attr: [ServiceChain, role_data, step_config]}]}