From 45a7963810830f3fe17ce7869e0458356f31a947 Mon Sep 17 00:00:00 2001 From: Mark Goddard Date: Thu, 1 Apr 2021 17:41:12 +0100 Subject: [PATCH] Support additional pass through host variables 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 --- ansible/group_vars/all/kolla | 70 ++++++++++++++++--- .../configuration/reference/kolla-ansible.rst | 50 ++++++++++++- etc/kayobe/kolla.yml | 44 ++++++++++++ .../extra-host-vars-13c28b790bc54f6b.yaml | 13 ++++ 4 files changed, 167 insertions(+), 10 deletions(-) create mode 100644 releasenotes/notes/extra-host-vars-13c28b790bc54f6b.yaml diff --git a/ansible/group_vars/all/kolla b/ansible/group_vars/all/kolla index 3c98b95f5..1c9c52f46 100644 --- a/ansible/group_vars/all/kolla +++ b/ansible/group_vars/all/kolla @@ -300,23 +300,49 @@ 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" +# 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_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_api_interface: "api_interface" - kolla_bifrost_network_interface: "bifrost_network_interface" +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. @@ -369,10 +395,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" @@ -390,11 +416,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" @@ -408,6 +446,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. diff --git a/doc/source/configuration/reference/kolla-ansible.rst b/doc/source/configuration/reference/kolla-ansible.rst index ef1302aec..251e4874a 100644 --- a/doc/source/configuration/reference/kolla-ansible.rst +++ b/doc/source/configuration/reference/kolla-ansible.rst @@ -413,7 +413,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 @@ -429,6 +433,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 @@ -441,6 +448,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 @@ -466,6 +476,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 @@ -488,6 +501,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 ---------------------- diff --git a/etc/kayobe/kolla.yml b/etc/kayobe/kolla.yml index 74f805fad..8e06b6291 100644 --- a/etc/kayobe/kolla.yml +++ b/etc/kayobe/kolla.yml @@ -120,11 +120,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 @@ -157,11 +179,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 diff --git a/releasenotes/notes/extra-host-vars-13c28b790bc54f6b.yaml b/releasenotes/notes/extra-host-vars-13c28b790bc54f6b.yaml new file mode 100644 index 000000000..270cd5e43 --- /dev/null +++ b/releasenotes/notes/extra-host-vars-13c28b790bc54f6b.yaml @@ -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 `__ + for details.