kayobe/ansible/roles/kolla-ansible/tests/test-defaults.yml

167 lines
6.5 KiB
YAML

---
- 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: "master"
kolla_ansible_venv: "{{ temp_path }}/venv"
kolla_config_path: "{{ temp_path }}/etc/kolla"
kolla_node_custom_config_path: "{{ temp_path }}/etc/kolla/config"
kolla_ansible_passwords_path: "{{ temp_path }}/passwords.yml"
# Required config.
kolla_base_distro: "fake-distro"
kolla_install_type: "fake-install-type"
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_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_bifrost_network_interface: "eth8"
kolla_provision_interface: "eth9"
kolla_inspector_dnsmasq_interface: "eth10"
kolla_enable_tls_external: False
kolla_enable_grafana: False
kolla_external_fqdn_cert: "fake-cert"
kolla_openstack_logging_debug: False
- name: Verify kolla-ansible installation
command: "{{ temp_path }}/venv/bin/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_install_type: "fake-install-type"
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"
network_interface: "eth0"
kolla_external_vip_interface: "eth1"
storage_interface: "eth3"
cluster_interface: "eth4"
dns_interface: "eth5"
neutron_external_interface: "eth6,eth7"
neutron_bridge_name: "br0,br1"
bifrost_network_interface: "eth8"
ironic_dnsmasq_interface: "eth10"
neutron_plugin_agent: "openvswitch"
kolla_enable_tls_external: False
kolla_external_fqdn_cert: "fake-cert"
openstack_logging_debug: False
- 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_kafka
- enable_influxdb
- enable_mariadb
- enable_neutron
- enable_nova
- enable_zookeeper
- grafana_admin_username
- name: Check whether inventory files exist
stat:
path: "{{ temp_path ~ '/etc/kolla/inventory/' ~ item }}"
with_items:
- seed
- overcloud
register: inventory_stat
- name: Validate inventory files
assert:
that:
- item.stat.exists
- item.stat.size > 0
msg: >
Inventory file {{ item.item }} was not found.
with_items: "{{ inventory_stat.results }}"
- 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 }}"