Performance: Parallelise Kolla Ansible host vars generation

Kayobe generates a host_vars file for each host in the Kolla Ansible
inventory. These contain network interfaces and other host-specific
things. Currently this is done by iterating over all hosts, which does
not scale well with a large number of hosts.

This change extracts the host vars generation into a separate role, and
executes it in a play targeted at all hosts, with delegate_to:
localhost. This ensures that host variable files are generated in
parallel.

Story: 2007993
Task: 40629

Change-Id: Iae75e17024adee9c2874c14d3ed36f4c87ba48d7
This commit is contained in:
Mark Goddard 2020-08-04 17:03:54 +01:00
parent b778ac01cf
commit b12f9e35e5
14 changed files with 519 additions and 328 deletions

View File

@ -306,6 +306,24 @@ 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
# the kolla-ansible seed host, if set. See also
# kolla_seed_inventory_pass_through_host_vars_map.
kolla_seed_inventory_pass_through_host_vars:
- "ansible_host"
- "ansible_port"
- "ansible_ssh_private_key_file"
- "kolla_api_interface"
- "kolla_bifrost_network_interface"
# 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"
# Custom overcloud inventory containing a mapping from top level groups to
# hosts.
kolla_overcloud_inventory_custom_top_level:
@ -357,6 +375,45 @@ kolla_overcloud_inventory_kolla_top_level_groups:
- "storage"
- "deployment"
# 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:
- "ansible_host"
- "ansible_port"
- "ansible_ssh_private_key_file"
- "kolla_network_interface"
- "kolla_api_interface"
- "kolla_storage_interface"
- "kolla_cluster_interface"
- "kolla_swift_storage_interface"
- "kolla_swift_replication_interface"
- "kolla_provision_interface"
- "kolla_inspector_dnsmasq_interface"
- "kolla_dns_interface"
- "kolla_tunnel_interface"
- "kolla_external_vip_interface"
- "kolla_neutron_external_interfaces"
- "kolla_neutron_bridge_names"
# 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_network_interface: "network_interface"
kolla_api_interface: "api_interface"
kolla_storage_interface: "storage_interface"
kolla_cluster_interface: "cluster_interface"
kolla_swift_storage_interface: "swift_storage_interface"
kolla_swift_replication_interface: "swift_replication_interface"
kolla_provision_interface: "provision_interface"
kolla_inspector_dnsmasq_interface: "ironic_dnsmasq_interface"
kolla_dns_interface: "dns_interface"
kolla_tunnel_interface: "tunnel_interface"
kolla_neutron_external_interfaces: "neutron_external_interface"
kolla_neutron_bridge_names: "neutron_bridge_name"
###############################################################################
# Kolla-ansible configuration.

View File

@ -4,7 +4,162 @@
gather_facts: true
tags: always
- name: Set interfaces for overcloud hosts
- name: Validate configuration options for kolla-ansible
hosts: localhost
tags:
- kolla-ansible
- config-validation
tasks:
- name: Validate serial console configuration
block:
- name: Check ipmitool-socat is in enabled in kolla_ironic_enabled_console_interfaces
fail:
msg: >
kolla_ironic_enabled_console_interfaces must contain ipmitool-socat if you set
ironic_serial_console_autoenable to true
when:
- kolla_ironic_enabled_console_interfaces is defined
- "'ipmitool-socat' not in kolla_ironic_enabled_console_interfaces"
when: ironic_serial_console_autoenable | bool
- name: Ensure Kolla Ansible is configured
hosts: localhost
tags:
- kolla-ansible
gather_facts: false
vars:
# We need to reference configuration for the network node.
# We pick the first host from the group for this. It is possible that at
# this point these groups have no hosts in, and we should handle that case
# gracefully.
network_host: "{{ groups['network'][0] }}"
pre_tasks:
# Configuration of extra user-provided Kolla globals.
- block:
- name: Check whether a Kolla extra globals configuration file exists
stat:
path: "{{ kayobe_config_path ~ '/kolla/globals.yml' }}"
get_checksum: False
get_md5: False
mime: False
register: globals_stat
- name: Read the Kolla extra globals configuration file
set_fact:
kolla_extra_globals: "{{ lookup('template', kayobe_config_path ~ '/kolla/globals.yml') | from_yaml }}"
when: globals_stat.stat.exists
tags:
- config
# Configuration and validation of network host networking.
- block:
- name: Set facts containing the VIP addresses and FQDNs
set_fact:
kolla_internal_vip_address: "{{ internal_net_name | net_vip_address }}"
kolla_internal_fqdn: "{{ internal_net_name | net_fqdn or internal_net_name | net_vip_address }}"
kolla_external_vip_address: "{{ public_net_name | net_vip_address }}"
kolla_external_fqdn: "{{ public_net_name | net_fqdn or public_net_name | net_vip_address }}"
when: kolla_enable_haproxy | bool
- name: Set facts containing the VIP addresses and FQDNs
set_fact:
kolla_internal_vip_address: "{{ internal_net_name | net_ip(network_host) }}"
kolla_internal_fqdn: "{{ internal_net_name | net_ip(network_host) }}"
kolla_external_vip_address: "{{ public_net_name | net_ip(network_host) }}"
kolla_external_fqdn: "{{ public_net_name | net_ip(network_host) }}"
when: not kolla_enable_haproxy | bool
- name: Validate Kolla Ansible API address configuration
fail:
msg: >
The Kolla Ansible variable {{ item.var_name }}
({{ item.description }}) is invalid. Value:
"{{ hostvars[inventory_hostname][item.var_name] | default('<undefined>') }}".
when:
- item.required | bool
- hostvars[inventory_hostname][item.var_name] is not defined or not hostvars[inventory_hostname][item.var_name]
with_items:
- var_name: "kolla_internal_vip_address"
description: "Internal API VIP address"
required: True
- var_name: "kolla_internal_fqdn"
description: "Internal API Fully Qualified Domain Name (FQDN)"
required: True
- var_name: "kolla_external_vip_address"
description: "external API VIP address"
required: True
- var_name: "kolla_external_fqdn"
description: "External API Fully Qualified Domain Name (FQDN)"
required: True
when: groups['network'] | length > 0
tags:
- config
- config-validation
- import_role:
name: kolla-ansible
vars:
kolla_ansible_install_epel: "{{ dnf_install_epel }}"
kolla_external_fqdn_cert: "{{ kolla_config_path }}/certificates/haproxy.pem"
kolla_internal_fqdn_cert: "{{ kolla_config_path }}/certificates/haproxy-internal.pem"
kolla_ansible_passwords_path: "{{ kayobe_config_path }}/kolla/passwords.yml"
kolla_overcloud_group_vars_path: "{{ kayobe_config_path }}/kolla/inventory/group_vars"
kolla_ansible_certificates_path: "{{ kayobe_config_path }}/kolla/certificates"
# NOTE: This differs from the default SELinux mode in kolla ansible,
# which is permissive. The justification for using this mode is twofold:
# 1. it avoids filling up the audit log
# 2. it avoids an issue seen when using diskimage-builder in the bifrost
# container.
# We could look at making the SELinux mode configurable in future.
kolla_selinux_state: disabled
kolla_inspector_dhcp_pool_start: "{{ inspection_net_name | net_inspection_allocation_pool_start }}"
kolla_inspector_dhcp_pool_end: "{{ inspection_net_name | net_inspection_allocation_pool_end }}"
kolla_inspector_default_gateway: "{{ inspection_net_name | net_inspection_gateway or inspection_net_name | net_gateway }}"
kolla_inspector_extra_kernel_options: "{{ inspector_extra_kernel_options }}"
kolla_enable_host_ntp: false
docker_daemon_mtu: "{{ public_net_name | net_mtu | default }}"
- name: Generate Kolla Ansible host vars for the seed host
hosts: seed
tags:
- config
- config-validation
- kolla-ansible
gather_facts: False
tasks:
- name: Set bifrost network interface
set_fact:
kolla_bifrost_network_interface: "{{ provision_oc_net_name | net_interface | replace('-', '_') }}"
when: provision_oc_net_name in network_interfaces
- name: Validate seed Kolla Ansible network configuration
fail:
msg: >
The Kolla Ansible variable {{ item.var_name }}
({{ item.description }}) is invalid. Value:
"{{ hostvars[inventory_hostname][item.var_name] | default('<undefined>') }}".
when:
- item.required | bool
- hostvars[inventory_hostname][item.var_name] is not defined or not hostvars[inventory_hostname][item.var_name]
with_items:
- var_name: "kolla_bifrost_network_interface"
description: "Bifrost network interface name"
required: True
# Strictly api_interface is not required but kolla-ansible currently
# references it in prechecks.
- name: Set API network interface
set_fact:
kolla_api_interface: "{{ kolla_bifrost_network_interface }}"
- import_role:
name: kolla-ansible-host-vars
vars:
kolla_ansible_pass_through_host_vars: "{{ kolla_seed_inventory_pass_through_host_vars }}"
kolla_ansible_pass_through_host_vars_map: "{{ kolla_seed_inventory_pass_through_host_vars_map }}"
kolla_ansible_inventory_path: "{{ kolla_config_path }}/inventory/seed"
- name: Generate Kolla Ansible host vars for overcloud hosts
hosts: overcloud
tags:
- config
@ -158,150 +313,12 @@
kolla_neutron_bridge_names: "{{ kolla_neutron_bridge_names | join(',') }}"
kolla_neutron_external_interfaces: "{{ kolla_neutron_external_interfaces | join(',') }}"
- name: Set interfaces for the seed host
hosts: seed
tags:
- config
- config-validation
- kolla-ansible
gather_facts: False
tasks:
- name: Set bifrost network interface
set_fact:
kolla_bifrost_network_interface: "{{ provision_oc_net_name | net_interface | replace('-', '_') }}"
when: provision_oc_net_name in network_interfaces
- name: Validate seed Kolla Ansible network configuration
fail:
msg: >
The Kolla Ansible variable {{ item.var_name }}
({{ item.description }}) is invalid. Value:
"{{ hostvars[inventory_hostname][item.var_name] | default('<undefined>') }}".
when:
- item.required | bool
- hostvars[inventory_hostname][item.var_name] is not defined or not hostvars[inventory_hostname][item.var_name]
with_items:
- var_name: "kolla_bifrost_network_interface"
description: "Bifrost network interface name"
required: True
# Strictly api_interface is not required but kolla-ansible currently
# references it in prechecks.
- name: Set API network interface
set_fact:
kolla_api_interface: "{{ kolla_bifrost_network_interface }}"
- name: Validate configuration options for kolla-ansible
hosts: localhost
tags:
- kolla-ansible
- config-validation
tasks:
- name: Validate serial console configuration
block:
- name: Check ipmitool-socat is in enabled in kolla_ironic_enabled_console_interfaces
fail:
msg: >
kolla_ironic_enabled_console_interfaces must contain ipmitool-socat if you set
ironic_serial_console_autoenable to true
when:
- kolla_ironic_enabled_console_interfaces is defined
- "'ipmitool-socat' not in kolla_ironic_enabled_console_interfaces"
when: ironic_serial_console_autoenable | bool
- name: Ensure Kolla Ansible is configured
hosts: localhost
tags:
- kolla-ansible
gather_facts: false
vars:
# We need to reference configuration for the network node.
# We pick the first host from the group for this. It is possible that at
# this point these groups have no hosts in, and we should handle that case
# gracefully.
network_host: "{{ groups['network'][0] }}"
pre_tasks:
# Configuration of extra user-provided Kolla globals.
- block:
- name: Check whether a Kolla extra globals configuration file exists
stat:
path: "{{ kayobe_config_path ~ '/kolla/globals.yml' }}"
get_checksum: False
get_md5: False
mime: False
register: globals_stat
- name: Read the Kolla extra globals configuration file
set_fact:
kolla_extra_globals: "{{ lookup('template', kayobe_config_path ~ '/kolla/globals.yml') | from_yaml }}"
when: globals_stat.stat.exists
tags:
- config
# Configuration and validation of network host networking.
- block:
- name: Set facts containing the VIP addresses and FQDNs
set_fact:
kolla_internal_vip_address: "{{ internal_net_name | net_vip_address }}"
kolla_internal_fqdn: "{{ internal_net_name | net_fqdn or internal_net_name | net_vip_address }}"
kolla_external_vip_address: "{{ public_net_name | net_vip_address }}"
kolla_external_fqdn: "{{ public_net_name | net_fqdn or public_net_name | net_vip_address }}"
when: kolla_enable_haproxy | bool
- name: Set facts containing the VIP addresses and FQDNs
set_fact:
kolla_internal_vip_address: "{{ internal_net_name | net_ip(network_host) }}"
kolla_internal_fqdn: "{{ internal_net_name | net_ip(network_host) }}"
kolla_external_vip_address: "{{ public_net_name | net_ip(network_host) }}"
kolla_external_fqdn: "{{ public_net_name | net_ip(network_host) }}"
when: not kolla_enable_haproxy | bool
- name: Validate Kolla Ansible API address configuration
fail:
msg: >
The Kolla Ansible variable {{ item.var_name }}
({{ item.description }}) is invalid. Value:
"{{ hostvars[inventory_hostname][item.var_name] | default('<undefined>') }}".
when:
- item.required | bool
- hostvars[inventory_hostname][item.var_name] is not defined or not hostvars[inventory_hostname][item.var_name]
with_items:
- var_name: "kolla_internal_vip_address"
description: "Internal API VIP address"
required: True
- var_name: "kolla_internal_fqdn"
description: "Internal API Fully Qualified Domain Name (FQDN)"
required: True
- var_name: "kolla_external_vip_address"
description: "external API VIP address"
required: True
- var_name: "kolla_external_fqdn"
description: "External API Fully Qualified Domain Name (FQDN)"
required: True
when: groups['network'] | length > 0
tags:
- config
- config-validation
- import_role:
name: kolla-ansible
name: kolla-ansible-host-vars
vars:
kolla_ansible_install_epel: "{{ dnf_install_epel }}"
kolla_external_fqdn_cert: "{{ kolla_config_path }}/certificates/haproxy.pem"
kolla_internal_fqdn_cert: "{{ kolla_config_path }}/certificates/haproxy-internal.pem"
kolla_ansible_passwords_path: "{{ kayobe_config_path }}/kolla/passwords.yml"
kolla_overcloud_group_vars_path: "{{ kayobe_config_path }}/kolla/inventory/group_vars"
kolla_ansible_certificates_path: "{{ kayobe_config_path }}/kolla/certificates"
# NOTE: This differs from the default SELinux mode in kolla ansible,
# which is permissive. The justification for using this mode is twofold:
# 1. it avoids filling up the audit log
# 2. it avoids an issue seen when using diskimage-builder in the bifrost
# container.
# We could look at making the SELinux mode configurable in future.
kolla_selinux_state: disabled
kolla_inspector_dhcp_pool_start: "{{ inspection_net_name | net_inspection_allocation_pool_start }}"
kolla_inspector_dhcp_pool_end: "{{ inspection_net_name | net_inspection_allocation_pool_end }}"
kolla_inspector_default_gateway: "{{ inspection_net_name | net_inspection_gateway or inspection_net_name | net_gateway }}"
kolla_inspector_extra_kernel_options: "{{ inspector_extra_kernel_options }}"
kolla_enable_host_ntp: false
docker_daemon_mtu: "{{ public_net_name | net_mtu | default }}"
kolla_ansible_pass_through_host_vars: "{{ kolla_overcloud_inventory_pass_through_host_vars }}"
kolla_ansible_pass_through_host_vars_map: "{{ kolla_overcloud_inventory_pass_through_host_vars_map }}"
kolla_ansible_inventory_path: "{{ kolla_config_path }}/inventory/overcloud"
# Kolla ansible expects these variables to be comma-separated lists.
kolla_neutron_bridge_names: "{{ kolla_neutron_bridge_names | join(',') }}"
kolla_neutron_external_interfaces: "{{ kolla_neutron_external_interfaces | join(',') }}"

View File

@ -0,0 +1,12 @@
---
# List of names of host variables to pass through from kayobe hosts to
# kolla-ansible hosts.
kolla_ansible_pass_through_host_vars:
# Dict mapping names of variables in kolla_ansible_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_ansible_pass_through_host_vars_map:
# Path to the Kolla Ansible inventory.
kolla_ansible_inventory_path:

View File

@ -0,0 +1,15 @@
---
- name: Ensure the Kolla Ansible host vars directory exists
file:
path: "{{ kolla_ansible_inventory_path }}/host_vars"
state: directory
mode: 0750
run_once: true
delegate_to: localhost
- name: Ensure the Kolla Ansible host vars file exists
template:
src: host-vars.j2
dest: "{{ kolla_ansible_inventory_path }}/host_vars/{{ inventory_hostname }}"
mode: 0640
delegate_to: localhost

View File

@ -0,0 +1,7 @@
---
{% for hv_name in kolla_ansible_pass_through_host_vars %}
{% set host_hv=hostvars[inventory_hostname] %}
{% if hv_name in host_hv %}
{{ kolla_ansible_pass_through_host_vars_map.get(hv_name, hv_name) }}: {{ host_hv[hv_name] | to_json }}
{% endif %}
{% endfor %}

View File

@ -0,0 +1,11 @@
---
- import_playbook: test.yml
- hosts: localhost
connection: local
tasks:
- name: Fail if any tests failed
fail:
msg: >
Test failures: {{ test_failures }}
when: test_failures is defined

View File

@ -0,0 +1,151 @@
---
- name: Test kolla-ansible-host-vars role extras
hosts: localhost
connection: local
tasks:
- name: Add a controller host to the inventory
add_host:
name: test-controller
groups: controllers
ansible_host: "1.2.3.5"
kolla_network_interface: "eth0"
kolla_external_vip_interface: "eth1"
kolla_api_interface: "eth2"
kolla_storage_interface: "eth3"
kolla_cluster_interface: "eth4"
kolla_dns_interface: "eth5"
kolla_neutron_external_interfaces: "eth6,eth7"
kolla_neutron_bridge_names: "br0,br1"
kolla_provision_interface: "eth8"
kolla_inspector_dnsmasq_interface: "eth9"
kolla_tunnel_interface: "eth10"
kolla_swift_storage_interface: "eth13"
kolla_swift_replication_interface: "eth14"
- name: Add a compute host to the inventory
add_host:
name: test-compute
groups: compute
ansible_host: "1.2.3.6"
kolla_network_interface: "eth0"
kolla_api_interface: "eth2"
kolla_storage_interface: "eth3"
kolla_neutron_external_interfaces: "eth4,eth5"
kolla_neutron_bridge_names: "br0,br1"
kolla_tunnel_interface: "eth6"
- name: Test kolla-ansible-host-vars role extras
hosts: controllers:compute
connection: local
gather_facts: no
tasks:
- name: Create a temporary directory
tempfile:
state: directory
register: tempfile_result
delegate_to: localhost
run_once: true
- block:
- name: Test the kolla-ansible-host-vars role with default values
include_role:
name: ../../kolla-ansible-host-vars
vars:
kolla_ansible_pass_through_host_vars:
- "ansible_host"
- "ansible_port"
- "ansible_ssh_private_key_file"
- "kolla_network_interface"
- "kolla_api_interface"
- "kolla_storage_interface"
- "kolla_cluster_interface"
- "kolla_swift_storage_interface"
- "kolla_swift_replication_interface"
- "kolla_provision_interface"
- "kolla_inspector_dnsmasq_interface"
- "kolla_dns_interface"
- "kolla_tunnel_interface"
- "kolla_external_vip_interface"
- "kolla_neutron_external_interfaces"
- "kolla_neutron_bridge_names"
kolla_ansible_pass_through_host_vars_map:
kolla_network_interface: "network_interface"
kolla_api_interface: "api_interface"
kolla_storage_interface: "storage_interface"
kolla_cluster_interface: "cluster_interface"
kolla_swift_storage_interface: "swift_storage_interface"
kolla_swift_replication_interface: "swift_replication_interface"
kolla_provision_interface: "provision_interface"
kolla_inspector_dnsmasq_interface: "ironic_dnsmasq_interface"
kolla_dns_interface: "dns_interface"
kolla_tunnel_interface: "tunnel_interface"
kolla_neutron_external_interfaces: "neutron_external_interface"
kolla_neutron_bridge_names: "neutron_bridge_name"
kolla_ansible_inventory_path: "{{ temp_path }}"
- name: Check whether inventory host vars files exist
stat:
path: "{{ temp_path ~ '/host_vars/' ~ inventory_hostname }}"
register: host_vars_stat
- name: Validate inventory host vars files
assert:
that:
- host_vars_stat.stat.exists
- host_vars_stat.stat.size > 0
msg: >
Inventory file {{ temp_path ~ '/host_vars/' ~ inventory_hostname }} was not found.
- name: Read inventory host vars files
slurp:
src: "{{ host_vars_stat.stat.path }}"
register: host_vars_slurp
- name: Validate inventory host vars file contents
assert:
that:
- host_vars_content is defined
- host_vars_content == expected_contents[inventory_hostname]
vars:
host_vars_content: "{{ host_vars_slurp.content | b64decode }}"
expected_contents:
test-controller: |
---
ansible_host: "1.2.3.5"
network_interface: "eth0"
api_interface: "eth2"
storage_interface: "eth3"
cluster_interface: "eth4"
swift_storage_interface: "eth13"
swift_replication_interface: "eth14"
provision_interface: "eth8"
ironic_dnsmasq_interface: "eth9"
dns_interface: "eth5"
tunnel_interface: "eth10"
kolla_external_vip_interface: "eth1"
neutron_external_interface: "eth6,eth7"
neutron_bridge_name: "br0,br1"
test-compute: |
---
ansible_host: "1.2.3.6"
network_interface: "eth0"
api_interface: "eth2"
storage_interface: "eth3"
tunnel_interface: "eth6"
neutron_external_interface: "eth4,eth5"
neutron_bridge_name: "br0,br1"
always:
- name: Ensure the temporary directory is removed
file:
path: "{{ temp_path }}"
state: absent
- name: Refresh the inventory
meta: refresh_inventory
rescue:
- name: Flag that a failure occurred
set_fact:
test_failures: "{{ test_failures | default(0) | int + 1 }}"
vars:
temp_path: "{{ tempfile_result.path }}"

View File

@ -63,24 +63,6 @@ kolla_seed_inventory_custom:
# Directory containing custom Kolla-Ansible group vars.
kolla_overcloud_group_vars_path:
# 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:
- "ansible_host"
- "ansible_port"
- "ansible_ssh_private_key_file"
- "kolla_api_interface"
- "kolla_bifrost_network_interface"
# 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"
# Custom overcloud inventory containing a mapping from top level groups to
# hosts.
kolla_overcloud_inventory_custom_top_level:
@ -107,45 +89,6 @@ kolla_overcloud_inventory_top_level_group_map: {}
# 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 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:
- "ansible_host"
- "ansible_port"
- "ansible_ssh_private_key_file"
- "kolla_network_interface"
- "kolla_api_interface"
- "kolla_storage_interface"
- "kolla_cluster_interface"
- "kolla_swift_storage_interface"
- "kolla_swift_replication_interface"
- "kolla_provision_interface"
- "kolla_inspector_dnsmasq_interface"
- "kolla_dns_interface"
- "kolla_tunnel_interface"
- "kolla_external_vip_interface"
- "kolla_neutron_external_interfaces"
- "kolla_neutron_bridge_names"
# 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_overcloud_inventory_pass_through_host_vars_map:
kolla_network_interface: "network_interface"
kolla_api_interface: "api_interface"
kolla_storage_interface: "storage_interface"
kolla_cluster_interface: "cluster_interface"
kolla_swift_storage_interface: "swift_storage_interface"
kolla_swift_replication_interface: "swift_replication_interface"
kolla_provision_interface: "provision_interface"
kolla_inspector_dnsmasq_interface: "ironic_dnsmasq_interface"
kolla_dns_interface: "dns_interface"
kolla_tunnel_interface: "tunnel_interface"
kolla_neutron_external_interfaces: "neutron_external_interface"
kolla_neutron_bridge_names: "neutron_bridge_name"
###############################################################################
# Kolla-ansible global configuration options.

View File

@ -36,8 +36,7 @@
become: True
with_items:
- "{{ kolla_config_path }}"
- "{{ kolla_seed_inventory_path }}/host_vars"
- "{{ kolla_overcloud_inventory_path }}/host_vars"
- "{{ kolla_seed_inventory_path }}"
- "{{ kolla_overcloud_inventory_path }}/group_vars"
- "{{ kolla_node_custom_config_path }}"
@ -55,18 +54,6 @@
dest: "{{ kolla_seed_inventory_path }}/hosts"
mode: 0640
- name: Ensure the Kolla seed host vars files exist
template:
src: host-vars.j2
dest: "{{ kolla_seed_inventory_path }}/host_vars/{{ host }}"
mode: 0640
with_inventory_hostnames: "seed"
vars:
host_vars: "{{ kolla_seed_inventory_pass_through_host_vars }}"
host_vars_map: "{{ kolla_seed_inventory_pass_through_host_vars_map }}"
loop_control:
loop_var: host
- name: Ensure the Kolla overcloud inventory file exists
copy:
content: "{{ kolla_overcloud_inventory }}"
@ -84,18 +71,6 @@
dest: "{{ kolla_overcloud_inventory_path }}/"
when: kolla_ansible_custom_overcloud_group_vars.stat.exists
- name: Ensure the Kolla overcloud host vars files exist
template:
src: host-vars.j2
dest: "{{ kolla_overcloud_inventory_path }}/host_vars/{{ host }}"
mode: 0640
with_inventory_hostnames: "{{ kolla_overcloud_top_level_groups }}"
vars:
host_vars: "{{ kolla_overcloud_inventory_pass_through_host_vars }}"
host_vars_map: "{{ kolla_overcloud_inventory_pass_through_host_vars_map }}"
loop_control:
loop_var: host
- name: Ensure the Kolla passwords file exists
vars:
# NOTE(mgoddard): Use the Python interpreter used to run ansible-playbook,

View File

@ -1,7 +0,0 @@
---
{% for hv_name in host_vars %}
{% set host_hv=hostvars[host] %}
{% if hv_name in host_hv %}
{{ host_vars_map.get(hv_name, hv_name) }}: {{ host_hv[hv_name] | to_json }}
{% endif %}
{% endfor %}

View File

@ -129,9 +129,7 @@
path: "{{ temp_path ~ '/etc/kolla/inventory/' ~ item }}"
with_items:
- seed
- seed/host_vars
- overcloud
- overcloud/host_vars
- overcloud/group_vars
register: inventory_stat

View File

@ -7,40 +7,16 @@
add_host:
name: test-seed
groups: seed
ansible_host: "1.2.3.4"
kolla_api_interface: "eth0"
kolla_bifrost_network_interface: "eth1"
- name: Add a controller host to the inventory
add_host:
name: test-controller
groups: controllers
ansible_host: "1.2.3.5"
kolla_network_interface: "eth0"
kolla_external_vip_interface: "eth1"
kolla_api_interface: "eth2"
kolla_storage_interface: "eth3"
kolla_cluster_interface: "eth4"
kolla_dns_interface: "eth5"
kolla_neutron_external_interfaces: "eth6,eth7"
kolla_neutron_bridge_names: "br0,br1"
kolla_provision_interface: "eth8"
kolla_inspector_dnsmasq_interface: "eth9"
kolla_tunnel_interface: "eth10"
kolla_swift_storage_interface: "eth13"
kolla_swift_replication_interface: "eth14"
- name: Add a compute host to the inventory
add_host:
name: test-compute
groups: compute
ansible_host: "1.2.3.6"
kolla_network_interface: "eth0"
kolla_api_interface: "eth2"
kolla_storage_interface: "eth3"
kolla_neutron_external_interfaces: "eth4,eth5"
kolla_neutron_bridge_names: "br0,br1"
kolla_tunnel_interface: "eth6"
- name: Create a temporary directory
tempfile:
@ -453,72 +429,6 @@
- test-controller
- test-compute
- name: Check whether inventory host vars files exist
stat:
path: "{{ temp_path ~ '/etc/kolla/inventory/' ~ item }}"
with_items:
- seed/host_vars/test-seed
- overcloud/host_vars/test-controller
- overcloud/host_vars/test-compute
register: host_vars_stat
- name: Validate inventory host vars files
assert:
that:
- item.stat.exists
- item.stat.size > 0
msg: >
Inventory file {{ item.item }} was not found.
with_items: "{{ host_vars_stat.results }}"
- name: Read inventory host vars files
slurp:
src: "{{ item.stat.path }}"
with_items: "{{ host_vars_stat.results }}"
register: host_vars_slurp
- name: Validate inventory host vars file contents
assert:
that:
- host_vars_content is defined
- host_vars_content == item.1
with_together:
- "{{ host_vars_slurp.results }}"
- "{{ expected_contents }}"
vars:
host_vars_content: "{{ item.0.content | b64decode }}"
expected_contents:
- |
---
ansible_host: "1.2.3.4"
api_interface: "eth0"
bifrost_network_interface: "eth1"
- |
---
ansible_host: "1.2.3.5"
network_interface: "eth0"
api_interface: "eth2"
storage_interface: "eth3"
cluster_interface: "eth4"
swift_storage_interface: "eth13"
swift_replication_interface: "eth14"
provision_interface: "eth8"
ironic_dnsmasq_interface: "eth9"
dns_interface: "eth5"
tunnel_interface: "eth10"
kolla_external_vip_interface: "eth1"
neutron_external_interface: "eth6,eth7"
neutron_bridge_name: "br0,br1"
- |
---
ansible_host: "1.2.3.6"
network_interface: "eth0"
api_interface: "eth2"
storage_interface: "eth3"
tunnel_interface: "eth6"
neutron_external_interface: "eth4,eth5"
neutron_bridge_name: "br0,br1"
- name: Check whether inventory group vars files exist
stat:
path: "{{ temp_path ~ '/etc/kolla/inventory/overcloud/group_vars/' ~ item }}"

View File

@ -380,6 +380,86 @@ to enable debug logging for Nova services:
---
nova_logging_debug: true
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.
``kolla_seed_inventory_pass_through_host_vars``
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``. The default is:
.. code-block:: yaml
kolla_seed_inventory_pass_through_host_vars:
- "ansible_host"
- "ansible_port"
- "ansible_ssh_private_key_file"
- "kolla_api_interface"
- "kolla_bifrost_network_interface"
``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
Kolla Ansible. If a variable name is not in this mapping the kayobe name is
used. The default is:
.. code-block:: yaml
kolla_seed_inventory_pass_through_host_vars_map:
kolla_api_interface: "api_interface"
kolla_bifrost_network_interface: "bifrost_network_interface"
``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
``kolla_overcloud_inventory_pass_through_host_vars_map``. The default is:
.. code-block:: yaml
kolla_overcloud_inventory_pass_through_host_vars:
- "ansible_host"
- "ansible_port"
- "ansible_ssh_private_key_file"
- "kolla_network_interface"
- "kolla_api_interface"
- "kolla_storage_interface"
- "kolla_cluster_interface"
- "kolla_swift_storage_interface"
- "kolla_swift_replication_interface"
- "kolla_provision_interface"
- "kolla_inspector_dnsmasq_interface"
- "kolla_dns_interface"
- "kolla_tunnel_interface"
- "kolla_external_vip_interface"
- "kolla_neutron_external_interfaces"
- "kolla_neutron_bridge_names"
``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
in Kolla Ansible. If a variable name is not in this mapping the Kayobe name
is used. The default is:
.. code-block:: yaml
kolla_overcloud_inventory_pass_through_host_vars_map:
kolla_network_interface: "network_interface"
kolla_api_interface: "api_interface"
kolla_storage_interface: "storage_interface"
kolla_cluster_interface: "cluster_interface"
kolla_swift_storage_interface: "swift_storage_interface"
kolla_swift_replication_interface: "swift_replication_interface"
kolla_provision_interface: "provision_interface"
kolla_inspector_dnsmasq_interface: "ironic_dnsmasq_interface"
kolla_dns_interface: "dns_interface"
kolla_tunnel_interface: "tunnel_interface"
kolla_neutron_external_interfaces: "neutron_external_interface"
kolla_neutron_bridge_names: "neutron_bridge_name"
Custom Group Variables
----------------------

View File

@ -120,6 +120,17 @@
# Full custom seed inventory contents.
#kolla_seed_inventory_custom:
# 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 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:
# Custom overcloud inventory containing a mapping from top level groups to
# hosts.
#kolla_overcloud_inventory_custom_top_level:
@ -146,6 +157,17 @@
# 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 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 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-ansible configuration.