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