2 # shellcheck disable=SC2034
3 ##############################################################################
4 # Copyright (c) 2018 Mirantis Inc., Enea AB and others.
5 # All rights reserved. This program and the accompanying materials
6 # are made available under the terms of the Apache License, Version 2.0
7 # which accompanies this distribution, and is available at
8 # http://www.apache.org/licenses/LICENSE-2.0
9 ##############################################################################
11 # Data derived from XDF (PDF/IDF/SDF/etc), used as input in deploy.sh
14 {%- import 'net_map.j2' as nm with context -%}
15 {%- set arch = conf[conf.MCP_JUMP_ARCH] -%}
16 {%- set V = conf.virtual -%}
17 {%- set section_map = {
19 'control': nm.ctl01.idx,
20 'compute': nm.cmp001.idx
23 {%- macro bash_arr(_l) -%}
24 ({%- for n in _l -%}'{{ n }}' {% endfor -%})
27 {#- Pack list as `sep`-separated string, replacing spaces with '|' -#}
28 {%- macro pack(x = [], sep = ',') -%}
29 {{ x | join(sep) | replace(' ', '|') }}
32 {#- Pack all vnode data as string -#}
33 {%- macro serialize_vnodes() -%}
35 {%- for section in section_map -%}
36 {%- for n in V.nodes[section] -%}
37 {%- if section_map[section] < 0 or conf.nodes[section_map[section] + loop.index0].node.type == 'virtual' -%}
38 {%- if n not in V -%}{%- do V.update({n: {}}) -%}{%- endif -%}
39 {%- do arr.append(pack([n, V[n].ram or arch.default.ram,
40 V[n].vcpus or arch.default.vcpus])) -%}
44 '{{ pack(arr, '|') }}'
47 {#- Return a bash array of node names or a Salt query, optionally filtered by type #}
48 {%- macro filter_nodes(type, output_as_query = False, sections = section_map) -%}
50 {%- for section in sections -%}
51 {%- for n in V.nodes[section] -%}
52 {%- if ( (section_map[section] < 0 and type == 'virtual') or
53 (section_map[section] >= 0 and
54 conf.nodes[section_map[section] + loop.index0].node.type in type) ) -%}
55 {%- do arr.append(n) -%}
59 {%- if output_as_query -%}
60 '{{ arr | join('* or ') }}*'
66 {#- Pack apt_pkg data as string -#}
67 {%- macro serialize_apt_pkg() -%}
69 {%- set sections = [arch.common] -%}
70 {%- if conf.MCP_VCP -%}
71 {%- do sections.append(arch.control) -%}
73 {%- for c in sections -%}
74 {%- do arr.append(pack([pack(c.apt['keys']), pack(c.apt.repos),
75 pack(c.pkg.install), pack(c.pkg.remove)], '^')) -%}
77 '{{ pack(arr, '^') }}'
80 {%- set bridges = conf.idf.fuel.jumphost.bridges %}
81 # Determine bridge names based on IDF, where all bridges are now mandatory
83 '{{ bridges.admin or "pxebr" }}'
84 '{{ bridges.mgmt or "mgmt" }}'
85 '{{ bridges.private or "internal" }}'
86 '{{ bridges.public or "public" }}'
89 export CLUSTER_DOMAIN={{ conf.cluster.domain }}
90 cluster_states={{ bash_arr(conf.cluster.states) }}
91 virtual_nodes={{ filter_nodes('virtual') }}
92 base_image={{ arch.base_image }}
94 # Serialize vnode data as '<name0>,<ram0>,<vcpu0>|<name1>,<ram1>,<vcpu1>[...]'
95 virtual_nodes_data={{ serialize_vnodes() }}
97 # Serialize repos, packages to (pre-)install/remove for:
98 # - foundation node VM base image (virtual: all VMs, baremetal: cfg01|mas01)
99 # - virtualized control plane VM base image (only when VCP is used)
100 virtual_repos_pkgs={{ serialize_apt_pkg() }}