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