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