Restore AllNodesExtraMapData

This commit is the same as I890bbef764b6bae7cb71cfedaff2ce17829737fb, which was
previously applied to tripleo-common, but lost in the migration to
tripleo-ansible.

Commit a7661065743086961b8ef93056b810e7d2a49eda removed the
all-nodes-config.j2.yaml Heat template. This template had the support
for specifying hieradata to merge into the all_nodes hieradata via the
AllNodesExtraMapData.

This commit restores the merge logic so that the merged hieradata from
the parameter value and the calculated hieradata is rendered in
all_nodes.json.

Change-Id: I49948f8d74c3846321af4f423a4891a71d0fabdc
Closes-Bug: #1839546
changes/47/678247/2
James Slagle 3 years ago
parent a40b1f1a38
commit 7137cae523
  1. 12
      tripleo_ansible/roles/tripleo-hieradata/templates/all_nodes.j2

@ -1,26 +1,26 @@
{% set all_nodes = {} %}
{% set _ = all_nodes.__setitem__('enabled_services', (enabled_services | unique)) %}
{% set _ = all_nodes.__setitem__('enabled_services', ((enabled_services + all_nodes_extra_map_data['enabled_services'] | default ([])) | unique)) %}
{% for service in enabled_services %}
{# <service>_enabled: true #}
{% set _ = all_nodes.__setitem__((service ~ '_enabled'), true) %}
{# <service>_node_ips: <list of ips> #}
{% set _ = all_nodes.__setitem__((service ~ '_node_ips'), (groups[service] | default ([]) | map('extract', hostvars, service_net_map[service ~ '_network'] | default('ctlplane') ~ '_ip') | list)) %}
{% set _ = all_nodes.__setitem__((service ~ '_node_ips'), (groups[service] | default ([]) | map('extract', hostvars, service_net_map[service ~ '_network'] | default('ctlplane') ~ '_ip') | list) + all_nodes_extra_map_data[service ~ '_node_ips'] | default([])) %}
{% if nova_additional_cell %}
{# <service>_cell_node_names: <list of hostnames> #}
{% set _ = all_nodes.__setitem__((service ~ '_cell_node_names'), (groups[service] | default ([]) | map('extract', hostvars, service_net_map[service ~ '_network'] | default('ctlplane') ~ '_hostname') | list)) %}
{% else %}
{# <service>_node_names: <list of hostnames> #}
{% set _ = all_nodes.__setitem__((service ~ '_node_names'), (groups[service] | default ([]) | map('extract', hostvars, service_net_map[service ~ '_network'] | default('ctlplane') ~ '_hostname') | list)) %}
{% set _ = all_nodes.__setitem__((service ~ '_node_names'), (groups[service] | default ([]) | map('extract', hostvars, service_net_map[service ~ '_network'] | default('ctlplane') ~ '_hostname') | list) + all_nodes_extra_map_data[service ~ '_node_names'] | default([])) %}
{% endif %}
{# <service>_short_node_names: <list of hostnames> #}
{% set _ = all_nodes.__setitem__((service ~ '_short_node_names'), (groups[service] | default ([]) | map('extract', hostvars, 'inventory_hostname') | list)) %}
{% set _ = all_nodes.__setitem__((service ~ '_short_node_names'), (groups[service] | default ([]) | map('extract', hostvars, 'inventory_hostname') | list) + all_nodes_extra_map_data[service ~ '_short_node_names'] | default([])) %}
{# <service>_short_bootstrap_node_name: hostname #}
{% set services = (groups[service] | default ([]) | map('extract', hostvars, 'inventory_hostname')) | list %}
{% set services = (groups[service] | default ([]) | map('extract', hostvars, 'inventory_hostname')) | list + [all_nodes_extra_map_data[service ~ '_short_bootstrap_node_name'] | default('')] %}
{% if (services | length) > 0 %}
{% set _ = all_nodes.__setitem__((service ~ '_short_bootstrap_node_name'), (services | first)) %}
{% endif %}
{# <service>_bootstrap_node_ip: hostname #}
{% set services = (groups[service] | default ([]) | map('extract', hostvars, service_net_map[service ~ '_network'] | default('ctlplane') ~ '_ip')) | list %}
{% set services = (groups[service] | default ([]) | map('extract', hostvars, service_net_map[service ~ '_network'] | default('ctlplane') ~ '_ip')) | list + [all_nodes_extra_map_data[service ~ '_short_bootstrap_node_ip'] | default('')] %}
{% if (services | length) > 0 %}
{% set _ = all_nodes.__setitem__((service ~ '_bootstrap_node_ip'), (services | first)) %}
{% endif %}

Loading…
Cancel
Save