Skip to content

Commit

Permalink
Support additional pass through host variables
Browse files Browse the repository at this point in the history
Allow passing through additional host variables from Kayobe to Kolla
Ansible without overriding the entire list.

* kolla_seed_inventory_pass_through_host_vars_extra
* kolla_seed_inventory_pass_through_host_vars_map_extra
* kolla_overcloud_inventory_pass_through_host_vars_extra
* kolla_overcloud_inventory_pass_through_host_vars_map_extra

Story: 2008797
Task: 42201

Change-Id: I41d9169f0312108e42bb12c52c6c7ee2509cf2ab
  • Loading branch information
markgoddard authored and jovial committed Dec 9, 2022
1 parent fb49b7b commit 3dfa3e0
Show file tree
Hide file tree
Showing 4 changed files with 166 additions and 9 deletions.
68 changes: 60 additions & 8 deletions ansible/group_vars/all/kolla
Original file line number Diff line number Diff line change
Expand Up @@ -312,24 +312,50 @@ kolla_build_customizations: {}
# Full custom seed inventory contents.
kolla_seed_inventory_custom:

# List of names of host variables to pass through from kayobe hosts to
# List of names of default host variables to pass through from kayobe hosts to
# the kolla-ansible seed host, if set. See also
# kolla_seed_inventory_pass_through_host_vars_map.
kolla_seed_inventory_pass_through_host_vars:
kolla_seed_inventory_pass_through_host_vars_default:
- "ansible_host"
- "ansible_port"
- "ansible_ssh_private_key_file"
- "kolla_api_interface"
- "kolla_bifrost_network_interface"

# Dict mapping names of variables in
# List of names of additional host variables to pass through from kayobe hosts
# to the kolla-ansible seed host, if set. See also
# kolla_seed_inventory_pass_through_host_vars_map.
kolla_seed_inventory_pass_through_host_vars_extra: []

# List of names of host variables to pass through from kayobe hosts to
# the kolla-ansible seed host, if set. See also
# kolla_seed_inventory_pass_through_host_vars_map.
kolla_seed_inventory_pass_through_host_vars: >-
{{ kolla_seed_inventory_pass_through_host_vars_default +
kolla_seed_inventory_pass_through_host_vars_extra }}

# Dict mapping names of default variables in
# kolla_seed_inventory_pass_through_host_vars to the variable to use in
# kolla-ansible. If a variable name is not in this mapping the kayobe name is
# used.
kolla_seed_inventory_pass_through_host_vars_map:
kolla_seed_inventory_pass_through_host_vars_map_default:
kolla_api_interface: "api_interface"
kolla_bifrost_network_interface: "bifrost_network_interface"

# Dict mapping names of extra variables in
# kolla_seed_inventory_pass_through_host_vars to the variable to use in
# kolla-ansible. If a variable name is not in this mapping the kayobe name is
# used.
kolla_seed_inventory_pass_through_host_vars_map_extra: {}

# Dict mapping names of variables in
# kolla_seed_inventory_pass_through_host_vars to the variable to use in
# kolla-ansible. If a variable name is not in this mapping the kayobe name is
# used.
kolla_seed_inventory_pass_through_host_vars_map: >-
{{ kolla_seed_inventory_pass_through_host_vars_map_default |
combine(kolla_seed_inventory_pass_through_host_vars_map_extra) }}

# Custom overcloud inventory containing a mapping from top level groups to
# hosts.
kolla_overcloud_inventory_custom_top_level:
Expand Down Expand Up @@ -381,10 +407,10 @@ kolla_overcloud_inventory_kolla_top_level_groups:
- "storage"
- "deployment"

# List of names of host variables to pass through from kayobe hosts to
# List of names of default host variables to pass through from kayobe hosts to
# kolla-ansible hosts, if set. See also
# kolla_overcloud_inventory_pass_through_host_vars_map.
kolla_overcloud_inventory_pass_through_host_vars:
kolla_overcloud_inventory_pass_through_host_vars_default:
- "ansible_host"
- "ansible_port"
- "ansible_ssh_private_key_file"
Expand All @@ -402,11 +428,23 @@ kolla_overcloud_inventory_pass_through_host_vars:
- "kolla_neutron_external_interfaces"
- "kolla_neutron_bridge_names"

# Dict mapping names of variables in
# List of names of additional host variables to pass through from kayobe hosts
# to kolla-ansible hosts, if set. See also
# kolla_overcloud_inventory_pass_through_host_vars_map.
kolla_overcloud_inventory_pass_through_host_vars_extra: []

# List of names of host variables to pass through from kayobe hosts to
# kolla-ansible hosts, if set. See also
# kolla_overcloud_inventory_pass_through_host_vars_map.
kolla_overcloud_inventory_pass_through_host_vars: >-
{{ kolla_overcloud_inventory_pass_through_host_vars_default +
kolla_overcloud_inventory_pass_through_host_vars_extra }}

# Dict mapping names of default variables in
# kolla_overcloud_inventory_pass_through_host_vars to the variable to use in
# kolla-ansible. If a variable name is not in this mapping the kayobe name is
# used.
kolla_overcloud_inventory_pass_through_host_vars_map:
kolla_overcloud_inventory_pass_through_host_vars_map_default:
kolla_network_interface: "network_interface"
kolla_api_interface: "api_interface"
kolla_storage_interface: "storage_interface"
Expand All @@ -420,6 +458,20 @@ kolla_overcloud_inventory_pass_through_host_vars_map:
kolla_neutron_external_interfaces: "neutron_external_interface"
kolla_neutron_bridge_names: "neutron_bridge_name"

# Dict mapping names of additional variables in
# kolla_overcloud_inventory_pass_through_host_vars to the variable to use in
# kolla-ansible. If a variable name is not in this mapping the kayobe name is
# used.
kolla_overcloud_inventory_pass_through_host_vars_map_extra: {}

# Dict mapping names of variables in
# kolla_overcloud_inventory_pass_through_host_vars to the variable to use in
# kolla-ansible. If a variable name is not in this mapping the kayobe name is
# used.
kolla_overcloud_inventory_pass_through_host_vars_map: >-
{{ kolla_overcloud_inventory_pass_through_host_vars_map_default |
combine(kolla_overcloud_inventory_pass_through_host_vars_map_extra) }}

###############################################################################
# Kolla-ansible configuration.

Expand Down
50 changes: 49 additions & 1 deletion doc/source/configuration/reference/kolla-ansible.rst
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,11 @@ Host variables

Kayobe generates a host_vars file for each host in the Kolla Ansible
inventory. These contain network interfaces and other host-specific
things.
things. Some Kayobe Ansible variables are passed through to Kolla Ansible, as
defined by the following variables. The default set of variables should
typically be kept. Additional variables may be passed through via the
``*_extra`` variables, as described below. If a passed through variable is not
defined for a host, it is ignored.

``kolla_seed_inventory_pass_through_host_vars``
List of names of host variables to pass through from kayobe hosts to the
Expand All @@ -401,6 +405,9 @@ things.
- "kolla_api_interface"
- "kolla_bifrost_network_interface"
It is possible to extend this list via
``kolla_seed_inventory_pass_through_host_vars_extra``.

``kolla_seed_inventory_pass_through_host_vars_map``
Dict mapping names of variables in
``kolla_seed_inventory_pass_through_host_vars`` to the variable to use in
Expand All @@ -413,6 +420,9 @@ things.
kolla_api_interface: "api_interface"
kolla_bifrost_network_interface: "bifrost_network_interface"
It is possible to extend this dict via
``kolla_seed_inventory_pass_through_host_vars_map_extra``.

``kolla_overcloud_inventory_pass_through_host_vars``
List of names of host variables to pass through from Kayobe hosts to
Kolla Ansible hosts, if set. See also
Expand All @@ -438,6 +448,9 @@ things.
- "kolla_neutron_external_interfaces"
- "kolla_neutron_bridge_names"
It is possible to extend this list via
``kolla_overcloud_inventory_pass_through_host_vars_extra``.

``kolla_overcloud_inventory_pass_through_host_vars_map``
Dict mapping names of variables in
``kolla_overcloud_inventory_pass_through_host_vars`` to the variable to use
Expand All @@ -460,6 +473,41 @@ things.
kolla_neutron_external_interfaces: "neutron_external_interface"
kolla_neutron_bridge_names: "neutron_bridge_name"
It is possible to extend this dict via
``kolla_overcloud_inventory_pass_through_host_vars_map_extra``.

Example: pass through an additional host variable
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

In this example we pass through a variable named ``my_kayobe_var`` from Kayobe
to Kolla Ansible.

.. code-block:: yaml
:caption: ``$KAYOBE_CONFIG_PATH/kolla.yml``
kolla_overcloud_inventory_pass_through_host_vars_extra:
- my_kayobe_var
This variable might be defined in the Kayobe inventory, e.g.

.. code-block:: yaml
:caption: ``$KAYOBE_CONFIG_PATH/inventory/host_vars/controller01``
my_kayobe_var: foo
The variable may then be referenced in
``$KAYOBE_CONFIG_PATH/kolla/globals.yml``, Kolla Ansible group variables, or in
Kolla Ansible custom service configuration.

In case the variable requires a different name in Kolla Ansible, use
``kolla_overcloud_inventory_pass_through_host_vars_map_extra``:

.. code-block:: yaml
:caption: ``$KAYOBE_CONFIG_PATH/kolla.yml``
kolla_overcloud_inventory_pass_through_host_vars_map_extra:
my_kayobe_var: my_kolla_ansible_var
Custom Group Variables
----------------------

Expand Down
44 changes: 44 additions & 0 deletions etc/kayobe/kolla.yml
Original file line number Diff line number Diff line change
Expand Up @@ -127,11 +127,33 @@
# Full custom seed inventory contents.
#kolla_seed_inventory_custom:

# List of names of default host variables to pass through from kayobe hosts to
# the kolla-ansible seed host, if set. See also
# kolla_seed_inventory_pass_through_host_vars_map.
#kolla_seed_inventory_pass_through_host_vars_default:

# List of names of additional host variables to pass through from kayobe hosts
# to the kolla-ansible seed host, if set. See also
# kolla_seed_inventory_pass_through_host_vars_map.
#kolla_seed_inventory_pass_through_host_vars_extra:

# List of names of host variables to pass through from kayobe hosts to
# the kolla-ansible seed host, if set. See also
# kolla_seed_inventory_pass_through_host_vars_map.
#kolla_seed_inventory_pass_through_host_vars:

# Dict mapping names of default variables in
# kolla_seed_inventory_pass_through_host_vars to the variable to use in
# kolla-ansible. If a variable name is not in this mapping the kayobe name is
# used.
#kolla_seed_inventory_pass_through_host_vars_map_default:

# Dict mapping names of extra variables in
# kolla_seed_inventory_pass_through_host_vars to the variable to use in
# kolla-ansible. If a variable name is not in this mapping the kayobe name is
# used.
#kolla_seed_inventory_pass_through_host_vars_map_extra:

# Dict mapping names of variables in
# kolla_seed_inventory_pass_through_host_vars to the variable to use in
# kolla-ansible. If a variable name is not in this mapping the kayobe name is
Expand Down Expand Up @@ -164,11 +186,33 @@
# have no hosts mapped to them will be provided with an empty group definition.
#kolla_overcloud_inventory_kolla_top_level_groups:

# List of names of default host variables to pass through from kayobe hosts to
# kolla-ansible hosts, if set. See also
# kolla_overcloud_inventory_pass_through_host_vars_map.
#kolla_overcloud_inventory_pass_through_host_vars_default:

# List of names of additional host variables to pass through from kayobe hosts
# to kolla-ansible hosts, if set. See also
# kolla_overcloud_inventory_pass_through_host_vars_map.
#kolla_overcloud_inventory_pass_through_host_vars_extra:

# List of names of host variables to pass through from kayobe hosts to
# kolla-ansible hosts, if set. See also
# kolla_overcloud_inventory_pass_through_host_vars_map.
#kolla_overcloud_inventory_pass_through_host_vars:

# Dict mapping names of default variables in
# kolla_overcloud_inventory_pass_through_host_vars to the variable to use in
# kolla-ansible. If a variable name is not in this mapping the kayobe name is
# used.
#kolla_overcloud_inventory_pass_through_host_vars_map_default:

# Dict mapping names of additional variables in
# kolla_overcloud_inventory_pass_through_host_vars to the variable to use in
# kolla-ansible. If a variable name is not in this mapping the kayobe name is
# used.
#kolla_overcloud_inventory_pass_through_host_vars_map_extra:

# Dict mapping names of variables in
# kolla_overcloud_inventory_pass_through_host_vars to the variable to use in
# kolla-ansible. If a variable name is not in this mapping the kayobe name is
Expand Down
13 changes: 13 additions & 0 deletions releasenotes/notes/extra-host-vars-13c28b790bc54f6b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
features:
- |
Adds support for passing through additional host variables from Kayobe to
Kolla Ansible. This is done via the following variables:
* ``kolla_seed_inventory_pass_through_host_vars_extra``
* ``kolla_seed_inventory_pass_through_host_vars_map_extra``
* ``kolla_overcloud_inventory_pass_through_host_vars_extra``
* ``kolla_overcloud_inventory_pass_through_host_vars_map_extra``
See `story 2008797 <https://storyboard.openstack.org/#!/story/2008797>`__
for details.

0 comments on commit 3dfa3e0

Please sign in to comment.