kayobe/ansible/roles/kolla-ansible/tests/test-defaults.yml
Will Szumski c75a32e72f Pass through kolla inventories as is
Previously, we only supported passing through group_vars. Passing
through the inventory as is allows you to use other features of ansible
inventory such as host vars. It also simplifies the logic of merging
multiple inventories as we can just pass the inventory to ansible and
let ansible take care of the rest. This is useful for the multiple
environments feature.

Change-Id: I28f5d73d414d405d67f5fc92ab371aa2e28a4ce3
Story: 2002009
Task: 42910
Depends-On: https://review.opendev.org/c/openstack/kolla-ansible/+/802863
2023-05-30 18:42:24 +02:00

170 lines
6.7 KiB
YAML

---
- name: Test kolla-ansible role defaults
hosts: localhost
connection: local
tasks:
- name: Create a temporary directory
tempfile:
state: directory
register: tempfile_result
- block:
- name: Test the kolla-ansible role with default values
include_role:
name: ../../kolla-ansible
vars:
kolla_ansible_source_path: "{{ temp_path }}/src"
kolla_ansible_ctl_install_type: "source"
kolla_ansible_source_url: "http://github.com/openstack/kolla-ansible"
kolla_ansible_source_version: "{{ openstack_branch }}"
kolla_ansible_venv: "{{ temp_path }}/venv"
kolla_config_path: "{{ temp_path }}/etc/kolla"
kolla_node_custom_config_path: "{{ temp_path }}/etc/kolla/config"
# Purposely does not exist to simulate the case when no group vars
# are provided
kolla_overcloud_inventory_search_paths:
- "{{ temp_path }}/etc/kayobe/"
kolla_ansible_passwords_path: "{{ temp_path }}/passwords.yml"
# Required config.
kolla_base_distro: "fake-distro"
kolla_base_distro_version: "1.23"
kolla_docker_namespace: "fake-namespace"
kolla_openstack_release: "fake-release"
kolla_internal_vip_address: "10.0.0.1"
kolla_internal_fqdn: "fake.internal.fqdn"
kolla_external_vip_address: "10.0.0.2"
kolla_external_fqdn: "fake.external.fqdn"
kolla_ansible_certificates_path: "{{ temp_path }}/etc/kayobe/kolla/certificates"
kolla_enable_tls_external: False
kolla_enable_tls_internal: False
kolla_enable_grafana: False
kolla_openstack_logging_debug: False
kolla_globals_paths_extra:
- "{{ tempfile_result.path ~ '/etc/kayobe/' }}"
apt_cache_valid_time: 3600
- name: Verify kolla-ansible installation
shell: ". {{ temp_path }}/venv/bin/activate && kolla-ansible -h"
changed_when: False
- name: Verify ansible installation
command: "{{ temp_path }}/venv/bin/ansible -h"
changed_when: False
- name: Validate globals.yml contents
assert:
that:
- item.key in globals_yml
- globals_yml[item.key] == item.value
msg: >
Unexpected value for variable "{{ item.key }}" in globals.yml.
Expected "{{ item.value }}", actual
"{{ globals_yml.get(item.key, '<missing>') }}".
with_dict: "{{ expected_variables }}"
vars:
# NOTE: Can't use set_fact for this, as it causes kolla-ansible
# Jinja expressions to be evaluated.
globals_yml: "{{ lookup('file', temp_path ~ '/etc/kolla/globals.yml') | from_yaml }}"
expected_variables:
config_strategy: "COPY_ALWAYS"
kolla_base_distro: "fake-distro"
kolla_base_distro_version: "1.23"
openstack_release: "fake-release"
kolla_internal_vip_address: "10.0.0.1"
kolla_internal_fqdn: "fake.internal.fqdn"
kolla_external_vip_address: "10.0.0.2"
kolla_external_fqdn: "fake.external.fqdn"
node_custom_config: "{{ temp_path }}/etc/kolla/config"
docker_namespace: "fake-namespace"
neutron_plugin_agent: "openvswitch"
kolla_enable_tls_external: False
kolla_enable_tls_internal: False
openstack_logging_debug: False
kolla_user: "kolla"
kolla_group: "kolla"
- name: Validate variables are absent from globals.yml
assert:
that: item not in globals_yml
msg: >
Unexpected variable "{{ item }}" found in globals.yml, value
"{{ globals_yml.get(item) }}".
with_items: "{{ unexpected_variables }}"
vars:
# NOTE: Can't use set_fact for this, as it causes kolla-ansible
# Jinja expressions to be evaluated.
globals_yml: "{{ lookup('file', temp_path ~ '/etc/kolla/globals.yml') | from_yaml }}"
unexpected_variables:
- docker_registry
- docker_registry_username
- docker_registry_password
- neutron_type_drivers
- neutron_tenant_network_types
- enable_glance
- enable_ironic
- enable_ironic_neutron_agent
- enable_influxdb
- enable_mariadb
- enable_neutron
- enable_nova
- enable_prometheus
- grafana_admin_username
- network_interface
- api_interface
- kolla_external_vip_interface
- storage_interface
- cluster_interface
- provision_interface
- ironic_dnsmasq_interface
- dns_interface
- tunnel_interface
- bifrost_network_interface
- neutron_external_interface
- neutron_bridge_name
- ironic_dnsmasq_dhcp_ranges
- name: Check whether inventory files exist
stat:
path: "{{ temp_path ~ '/etc/kolla/inventory/' ~ item }}"
with_items:
- seed
- overcloud
register: inventory_stat
- name: Look for inventory overrides
find:
paths: "{{ temp_path ~ '/etc/kolla/extra-inventories/' }}"
register: kolla_ansible_overcloud_inventory_overrides
- name: Check that no inventory overrides are configured
assert:
that:
- kolla_ansible_overcloud_inventory_overrides.matched == 0
msg: >
Overcloud group vars were found when they should not be set.
- name: Validate passwords.yml contents
assert:
that: item in passwords_yml
msg: >
Expected variable "{{ item }}" not present in passwords.yml.
with_items: "{{ expected_variables }}"
vars:
# NOTE: Can't use set_fact for this, as it causes kolla-ansible
# Jinja expressions to be evaluated.
passwords_yml: "{{ lookup('file', temp_path ~ '/etc/kolla/passwords.yml') | from_yaml }}"
expected_variables:
- database_password
always:
- name: Ensure the temporary directory is removed
file:
path: "{{ temp_path }}"
state: absent
rescue:
- name: Flag that a failure occurred
set_fact:
test_failures: "{{ test_failures | default(0) | int + 1 }}"
vars:
temp_path: "{{ tempfile_result.path }}"