Skip to content
Snippets Groups Projects
  • Mark Goddard's avatar
    994d7902
    Fix kolla-ansible role tests · 994d7902
    Mark Goddard authored
    The kolla-ansible CLI now requires the kolla_ansible python module to be
    importable. We need to activate the virtualenv to make this work.
    
    Change-Id: I43d4761409df3eea146dc7ff16b4c8d80855a91b
    994d7902
    History
    Fix kolla-ansible role tests
    Mark Goddard authored
    The kolla-ansible CLI now requires the kolla_ansible python module to be
    importable. We need to activate the virtualenv to make this work.
    
    Change-Id: I43d4761409df3eea146dc7ff16b4c8d80855a91b
test-defaults.yml 6.32 KiB
---
- 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_enable_tls_external: False
            kolla_enable_grafana: False
            kolla_external_fqdn_cert: "fake-cert"
            kolla_openstack_logging_debug: False

        - 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_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"
              neutron_plugin_agent: "openvswitch"