Merge "Refactor setup_docker_host.sh as host_prep_tasks"
[apex-tripleo-heat-templates.git] / network / ports / net_ip_list_map.j2.yaml
1 heat_template_version: pike
2
3 parameters:
4   ControlPlaneIpList:
5     default: []
6     type: comma_delimited_list
7 {%- for network in networks %}
8   {{network.name}}IpList:
9     default: []
10     type: comma_delimited_list
11 {%- endfor %}
12   EnabledServices:
13     default: []
14     type: comma_delimited_list
15   ServiceNetMap:
16     default: {}
17     type: json
18   ServiceHostnameList:
19     default: []
20     type: comma_delimited_list
21   NetworkHostnameMap:
22     default: []
23     type: json
24
25   InternalApiNetName:
26     default: internal_api
27     description: The name of the internal_api network.
28     type: string
29   ExternalNetName:
30     default: external
31     description: The name of the external network.
32     type: string
33   ManagementNetName:
34     default: management
35     description: The name of the management network.
36     type: string
37   StorageNetName:
38     default: storage
39     description: The name of the storage network.
40     type: string
41   StorageMgmtNetName:
42     default: storage_mgmt
43     description: The name of the storage_mgmt network.
44     type: string
45   TenantNetName:
46     default: tenant
47     description: The name of the tenant network.
48 {%- for network in networks %}
49   {{network.name}}NetName:
50     default: {{network.name_lower}}
51     description: The name of the {{network.name_lower}} network.
52     type: string
53 {%- endfor %}
54
55
56 resources:
57    # This adds the extra "services" on for keystone
58    # so that keystone_admin_api_network and
59    # keystone_public_api_network point to the correct
60    # network on the nodes running the "keystone" service
61   EnabledServicesValue:
62     type: OS::Heat::Value
63     properties:
64       type: comma_delimited_list
65       value:
66         yaql:
67           expression: let(root => $) -> $.data.extra_services.items().where($[0] in $root.data.enabled_services).select($[1]).flatten() + $root.data.enabled_services
68           data:
69             enabled_services: {get_param: EnabledServices}
70             extra_services:
71               # If anything other than keystone needs this
72               # then we should add an extra_networks interface
73               # to the service templates role_data but for
74               # now we hard-code the keystone special case
75               keystone:
76                 - keystone_admin_api
77                 - keystone_public_api
78
79   NetIpMapValue:
80     type: OS::Heat::Value
81     properties:
82       type: json
83       value:
84         map_replace:
85           - ctlplane: {get_param: ControlPlaneIpList}
86 {%- for network in networks %}
87             {{network.name_lower}}: {get_param: {{network.name}}IpList}
88 {%- endfor %}
89           - keys:
90 {%- for network in networks %}
91               {{network.name_lower}}: {get_param: {{network.name}}NetName}
92 {%- endfor %}
93
94 outputs:
95   net_ip_map:
96     description: >
97       A Hash containing a mapping of network names to assigned lists
98       of IP addresses.
99     value: {get_attr: [NetIpMapValue, value]}
100   service_ips:
101     description: >
102       Map of enabled services to a list of their IP addresses
103     value:
104       yaql:
105         # This filters any entries where the value hasn't been substituted for
106         # a list, e.g it's still $service_network.  This happens when there is
107         # no network defined for the service in the ServiceNetMap, which is OK
108         # as not all services have to be bound to a network, so we filter them
109         expression: dict($.data.map.items().where(not isString($[1])))
110         data:
111           map:
112             map_replace:
113               - map_replace:
114                   - map_merge:
115                       repeat:
116                         template:
117                           SERVICE_node_ips: SERVICE_network
118                         for_each:
119                           SERVICE: {get_attr: [EnabledServicesValue, value]}
120                   - values: {get_param: ServiceNetMap}
121               - values: {get_attr: [NetIpMapValue, value]}
122   ctlplane_service_ips:
123     description: >
124       Map of enabled services to a list of their ctlplane IP addresses
125     value:
126       yaql:
127         expression: dict($.data.map.items().where(len($[1]) > 0))
128         data:
129           map:
130             map_merge:
131               repeat:
132                 template:
133                   SERVICE_ctlplane_node_ips: {get_param: ControlPlaneIpList}
134                 for_each:
135                   SERVICE: {get_attr: [EnabledServicesValue, value]}
136   service_hostnames:
137     description: >
138       Map of enabled services to a list of hostnames where they're running
139     value:
140       map_replace:
141         - yaql:
142             # This filters any entries where the value hasn't been substituted for
143             # a list, e.g it's still $service_network.  This happens when there is
144             # no network defined for the service in the ServiceNetMap, which is OK
145             # as not all services have to be bound to a network, so we filter them
146             expression: dict($.data.map.items().where(not $[1].endsWith("_network")))
147             data:
148               map:
149                 map_replace:
150                   - map_merge:
151                       repeat:
152                         template:
153                           SERVICE_node_names: SERVICE_network
154                         for_each:
155                           SERVICE: {get_attr: [EnabledServicesValue, value]}
156                   - values: {get_param: ServiceNetMap}
157         - values: {get_param: NetworkHostnameMap}
158   short_service_hostnames:
159     description: >
160       Map of enabled services to a list of hostnames where they're running regardless of the network
161     value:
162       yaql:
163         # If ServiceHostnameList is empty the role is deployed with zero nodes
164         # therefore we don't want to add any *_node_names to the map
165         expression: dict($.data.map.items().where(len($[1]) > 0))
166         data:
167           map:
168             map_merge:
169               repeat:
170                 template:
171                   SERVICE_short_node_names: {get_param: ServiceHostnameList}
172                 for_each:
173                     SERVICE: {get_attr: [EnabledServicesValue, value]}
174   short_service_bootstrap_hostnames:
175     description: >
176       Map of enabled services to a list of hostnames where they're running regardless of the network
177       Used for bootstrap purposes
178     value:
179       yaql:
180         # If ServiceHostnameList is empty the role is deployed with zero nodes
181         # therefore we don't want to add any *_node_names to the map
182         expression: dict($.data.map.items().where(len($[1]) > 0))
183         data:
184           map:
185             map_merge:
186               repeat:
187                 template:
188                   SERVICE_short_bootstrap_node_name: {get_param: ServiceHostnameList}
189                 for_each:
190                     SERVICE: {get_attr: [EnabledServicesValue, value]}