kayobe/ansible/roles/kolla-ansible/templates/overcloud-top-level.j2
Mark Goddard bea399ef81 Per-host network interface configuration
Adds support for configuration of per-host network interfaces in Kolla Ansible.
Previously, all interfaces were configured in globals.yml, meaning that all
hosts used the same interface names. Now, interfaces are configured for each
host via inventory files.

This does have the drawback that host entries in the inventory are rather long
and not too readable. An improvement on this could be to generate host_vars
files. With a little more intelligence, it would be possible to use group_vars
files or even globals.yml when interfaces are uniform within a group or
globally.

Change-Id: I95a128d762ff9faf70467f83cb276a5ab619d1ea
Story: 2001658
Task: 6691
2018-09-03 11:36:56 +01:00

75 lines
2.5 KiB
Django/Jinja

# This inventory section provides a mapping of the top level groups to hosts.
#
# Top level groups define the roles of hosts, e.g. controller or compute.
# Components define groups of services, e.g. nova or ironic.
# Services define single containers, e.g. nova-compute or ironic-api.
{% set top_level_groups = kolla_overcloud_inventory_top_level_group_map.values() |
selectattr('groups', 'defined') |
map(attribute='groups') |
sum(start=[]) |
unique |
list %}
{% for group in top_level_groups %}
# Top level {{ group }} group.
[{{ group }}]
# These hostnames must be resolvable from your deployment host
{% for host in groups.get(group, []) %}
{% set host_hv=hostvars[host] %}
{{ host }}{% for hv_name in kolla_overcloud_inventory_pass_through_host_vars %}{% if hv_name in host_hv %} {{ kolla_overcloud_inventory_pass_through_host_vars_map.get(hv_name, hv_name) }}='{{ host_hv[hv_name] | to_json }}'{% endif %}{% endfor %}
{% endfor %}
{% endfor %}
[overcloud:children]
{% for group in top_level_groups %}
{{ group }}
{% endfor %}
[overcloud:vars]
ansible_user={{ kolla_ansible_user }}
{% if kolla_ansible_become | bool %}
ansible_become=true
{% endif %}
{% if kolla_ansible_target_venv is not none %}
# Execute ansible modules on the remote target hosts using a virtualenv.
ansible_python_interpreter={{ kolla_ansible_target_venv }}/bin/python
{% endif %}
{% for kolla_group, kolla_group_config in kolla_overcloud_inventory_top_level_group_map.items() %}
{% if 'groups' in kolla_group_config %}
{% set renamed_groups = kolla_group_config.groups | difference([kolla_group]) | list %}
{% if renamed_groups | length > 0 %}
# Mapping from kolla-ansible group {{ kolla_group }} to top level kayobe
# groups.
[{{ kolla_group }}:children]
{% for group in kolla_group_config.groups %}
{{ group }}
{% endfor %}
{% endif %}
{% endif %}
{% if 'vars' in kolla_group_config %}
# Mapping from kolla-ansible group {{ kolla_group }} to top level kayobe
# variables.
[{{ kolla_group }}:vars]
{% for var_name, var_value in kayobe_group_config.vars.items() %}
{{ var_name }}={{ var_value }}
{% endfor %}
{% endif %}
{% endfor %}
{% for group in kolla_overcloud_inventory_kolla_top_level_groups %}
{% if not kolla_overcloud_inventory_top_level_group_map.get(group, {}).get('groups') %}
# Empty group definition for {{ group }}.
[{{ group }}]
{% endif %}
{% endfor %}
[compute:children]
inner-compute
external-compute