Merge "Cleanup haproxy service from explicit services enablement"
[apex-tripleo-heat-templates.git] / puppet / all-nodes-config.yaml
1 heat_template_version: 2016-10-14
2 description: 'All Nodes Config for Puppet'
3
4 parameters:
5   hosts:
6     type: comma_delimited_list
7   # FIXME(shardy) this can be comma_delimited_list when
8   # https://bugs.launchpad.net/heat/+bug/1617019 is fixed
9   enabled_services:
10     type: string
11   controller_ips:
12     type: comma_delimited_list
13   service_ips:
14     type: json
15   service_node_names:
16     type: json
17   controller_names:
18     type: comma_delimited_list
19   memcache_node_ips:
20     type: comma_delimited_list
21   keystone_public_api_node_ips:
22     type: comma_delimited_list
23   keystone_admin_api_node_ips:
24     type: comma_delimited_list
25   NetVipMap:
26     type: json
27   ServiceNetMap:
28     type: json
29   DeployIdentifier:
30     type: string
31     default: ''
32     description: >
33       Setting this to a unique value will re-run any deployment tasks which
34       perform configuration on a Heat stack-update.
35   UpdateIdentifier:
36     type: string
37     description: >
38       Setting to a previously unused value during stack-update will trigger
39       package update on all nodes
40   StackAction:
41     type: string
42     description: >
43       Heat action on performed top-level stack.
44     constraints:
45     - allowed_values: ['CREATE', 'UPDATE']
46
47 resources:
48
49   allNodesConfigImpl:
50     type: OS::Heat::StructuredConfig
51     properties:
52       group: os-apply-config
53       config:
54         hosts:
55           list_join:
56           - "\n"
57           - {get_param: hosts}
58         hiera:
59           datafiles:
60             bootstrap_node:
61               mapped_data:
62                 bootstrap_nodeid: {get_input: bootstrap_nodeid}
63                 bootstrap_nodeid_ip: {get_input: bootstrap_nodeid_ip}
64             all_nodes:
65               mapped_data:
66                 map_merge:
67                   - enabled_services: {get_param: enabled_services}
68                   # This writes out a mapping of service_name_enabled: 'true'
69                   # For any services not enabled, hiera foo_enabled will
70                   # return nil, as it's undefined
71                   - map_merge:
72                       repeat:
73                         template:
74                           # Note this must be string 'true' due to
75                           # https://bugs.launchpad.net/heat/+bug/1617203
76                           SERVICE_enabled: 'true'
77                         for_each:
78                           SERVICE:
79                             str_split: [',', {get_param: enabled_services}]
80                   # provides a mapping of service_name_ips to a list of IPs
81                   - {get_param: service_ips}
82                   - {get_param: service_node_names}
83                   - controller_node_ips:
84                       list_join:
85                       - ','
86                       - {get_param: controller_ips}
87                     controller_node_names:
88                       list_join:
89                       - ','
90                       - {get_param: controller_names}
91                     memcached_node_ips_v6:
92                       str_replace:
93                         template: "['inet6:[SERVERS_LIST]']"
94                         params:
95                           SERVERS_LIST:
96                             list_join:
97                             - "]','inet6:["
98                             - {get_param: memcache_node_ips}
99                     keystone_public_api_node_ips:
100                       str_replace:
101                         template: "['SERVERS_LIST']"
102                         params:
103                           SERVERS_LIST:
104                             list_join:
105                             - "','"
106                             - {get_param: keystone_public_api_node_ips}
107                     keystone_admin_api_node_ips:
108                       str_replace:
109                         template: "['SERVERS_LIST']"
110                         params:
111                           SERVERS_LIST:
112                             list_join:
113                             - "','"
114                             - {get_param: keystone_admin_api_node_ips}
115
116                     deploy_identifier: {get_param: DeployIdentifier}
117                     update_identifier: {get_param: UpdateIdentifier}
118                     stack_action: {get_param: StackAction}
119             vip_data:
120               mapped_data:
121                 map_merge:
122                   # Dynamically generate per-service VIP data based on enabled_services
123                   # This works as follows (outer->inner functions)
124                   # yaql - filters services where no mapping exists in ServiceNetMap
125                   #   map_replace: substitute e.g internal_api with the IP from NetVipMap
126                   #     map_replace: substitute e.g heat_api_network with network name from ServiceNetMap
127                   #       map_merge/repeat: generate a per-service mapping
128                   - yaql:
129                       # This filters any entries where the value hasn't been substituted for
130                       # a list, e.g it's still $service_network.  This happens when there is
131                       # no network defined for the service in the ServiceNetMap, which is OK
132                       # as not all services have to be bound to a network, so we filter them
133                       expression: dict($.data.map.items().where(isString($[1]) and not $[1].endsWith("_network")))
134                       data:
135                         map:
136                           map_replace:
137                             - map_replace:
138                                 - map_merge:
139                                     repeat:
140                                       template:
141                                         SERVICE_vip: SERVICE_network
142                                       for_each:
143                                         SERVICE:
144                                           str_split: [',', {get_param: enabled_services}]
145                                 - values: {get_param: ServiceNetMap}
146                             - values: {get_param: NetVipMap}
147                   - keystone_admin_api_vip:
148                       get_param: [NetVipMap, {get_param: [ServiceNetMap, keystone_admin_api_network]}]
149                     keystone_public_api_vip:
150                       get_param: [NetVipMap, {get_param: [ServiceNetMap, keystone_public_api_network]}]
151                     public_virtual_ip: {get_param: [NetVipMap, external]}
152                     controller_virtual_ip: {get_param: [NetVipMap, ctlplane]}
153                     internal_api_virtual_ip: {get_param: [NetVipMap, internal_api]}
154                     storage_virtual_ip: {get_param: [NetVipMap, storage]}
155                     storage_mgmt_virtual_ip: {get_param: [NetVipMap, storage_mgmt]}
156                     # public_virtual_ip and controller_virtual_ip are needed in
157                     # both HAproxy & keepalived.
158                     tripleo::haproxy::public_virtual_ip: {get_param: [NetVipMap, external]}
159                     tripleo::haproxy::controller_virtual_ip: {get_param: [NetVipMap, ctlplane]}
160                     tripleo::keepalived::public_virtual_ip: {get_param: [NetVipMap, external]}
161                     tripleo::keepalived::controller_virtual_ip: {get_param: [NetVipMap, ctlplane]}
162                     tripleo::keepalived::internal_api_virtual_ip: {get_param: [NetVipMap, internal_api]}
163                     tripleo::keepalived::storage_virtual_ip: {get_param: [NetVipMap, storage]}
164                     tripleo::keepalived::storage_mgmt_virtual_ip: {get_param: [NetVipMap, storage_mgmt]}
165                     tripleo::redis_notification::haproxy_monitor_ip: {get_param: [NetVipMap, ctlplane]}
166
167 outputs:
168   config_id:
169     description: The ID of the allNodesConfigImpl resource.
170     value:
171       {get_resource: allNodesConfigImpl}
172   hosts_entries:
173     description: |
174       The content that should be appended to your /etc/hosts if you want to get
175       hostname-based access to the deployed nodes (useful for testing without
176       setting up a DNS).
177     value: {get_attr: [allNodesConfigImpl, config, hosts]}