Create variable override tests

This way we ensure in the integrated gates that deployers can
override their variables in userspace.

The bigger interest will come when we upgrade to a new version
of ansible, where the variable behavior could be different.
It then proves we are respecting our contract.

Change-Id: I707b3fd6fdc9e7080d7202f2d70e85f441f5db16
This commit is contained in:
Jean-Philippe Evrard 2017-11-23 13:02:09 +00:00 committed by Jean-Philippe Evrard
parent 33836d3d5e
commit dbe09ddf6f
5 changed files with 115 additions and 31 deletions

View File

@ -145,48 +145,54 @@ pushd "${OSA_CLONE_DIR}/tests"
fi
popd
pushd "${OSA_CLONE_DIR}/playbooks"
# Disable Ansible color output
export ANSIBLE_NOCOLOR=1
if [[ "${ACTION}" == "varstest" ]]; then
pushd "${OSA_CLONE_DIR}/tests"
openstack-ansible test-vars-overrides.yml
popd
else
pushd "${OSA_CLONE_DIR}/playbooks"
# Disable Ansible color output
export ANSIBLE_NOCOLOR=1
# Create ansible logging directory
mkdir -p ${ANSIBLE_LOG_DIR}
# Create ansible logging directory
mkdir -p ${ANSIBLE_LOG_DIR}
# Log some data about the instance and the rest of the system
log_instance_info
# Log some data about the instance and the rest of the system
log_instance_info
# First we gather facts about the hosts to populate the fact cache.
# We can't gather the facts for all hosts yet because the containers
# aren't built yet.
ansible -m setup -a 'gather_subset=network,hardware,virtual' hosts 2>${ANSIBLE_LOG_DIR}/facts-hosts.log
# First we gather facts about the hosts to populate the fact cache.
# We can't gather the facts for all hosts yet because the containers
# aren't built yet.
ansible -m setup -a 'gather_subset=network,hardware,virtual' hosts 2>${ANSIBLE_LOG_DIR}/facts-hosts.log
# Prepare the hosts
export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_DIR}/setup-hosts.log"
openstack-ansible setup-hosts.yml -e osa_gather_facts=False
# Prepare the hosts
export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_DIR}/setup-hosts.log"
openstack-ansible setup-hosts.yml -e osa_gather_facts=False
# Log some data about the instance and the rest of the system
log_instance_info
# Log some data about the instance and the rest of the system
log_instance_info
# Once setup-hosts is complete, we should gather facts for everything
# (now including containers) so that the fact cache is complete for the
# remainder of the run.
ansible -m setup -a 'gather_subset=network,hardware,virtual' all 1>${ANSIBLE_LOG_DIR}/facts-all.log
# Once setup-hosts is complete, we should gather facts for everything
# (now including containers) so that the fact cache is complete for the
# remainder of the run.
ansible -m setup -a 'gather_subset=network,hardware,virtual' all 1>${ANSIBLE_LOG_DIR}/facts-all.log
# Prepare the infrastructure
export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_DIR}/setup-infrastructure.log"
openstack-ansible setup-infrastructure.yml -e osa_gather_facts=False
# Prepare the infrastructure
export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_DIR}/setup-infrastructure.log"
openstack-ansible setup-infrastructure.yml -e osa_gather_facts=False
# Log some data about the instance and the rest of the system
log_instance_info
# Log some data about the instance and the rest of the system
log_instance_info
# Setup OpenStack
export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_DIR}/setup-openstack.log"
openstack-ansible setup-openstack.yml -e osa_gather_facts=False
# Setup OpenStack
export ANSIBLE_LOG_PATH="${ANSIBLE_LOG_DIR}/setup-openstack.log"
openstack-ansible setup-openstack.yml -e osa_gather_facts=False
# Log some data about the instance and the rest of the system
log_instance_info
# Log some data about the instance and the rest of the system
log_instance_info
popd
popd
fi
# If the action is to upgrade, then checkout the original SHA for
# the checkout, and execute the upgrade.

View File

@ -184,3 +184,28 @@
when: pip_conf_file.stat.exists
tags:
- container-conf-files
- name: Create vars override folders if we need to test them
file:
path: "{{ item }}"
state: directory
with_items:
- /etc/openstack_deploy/group_vars
- /etc/openstack_deploy/host_vars
when: "{{ (lookup('env','ACTION') | default(false,true)) == 'varstest' }}"
- name: Create user-space overrides
lineinfile:
path: "{{ item.path }}"
state: present
line: "{{ item.line }}"
create: yes
with_items:
- path: /etc/openstack_deploy/group_vars/hosts.yml
line: 'babar: "elephant"'
- path: /etc/openstack_deploy/group_vars/hosts.yml
line: 'lxc_hosts_package_state: "present"'
- path: /etc/openstack_deploy/host_vars/localhost.yml
line: 'security_package_state: "present"'
- path: /etc/openstack_deploy/host_vars/localhost.yml
line: 'tintin: "milou"'

View File

@ -0,0 +1,44 @@
---
# Copyright 2017, Rackspace US, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
- name: Ensuring group vars
hosts: "hosts"
gather_facts: no
connection: local
user: root
tasks:
- name: Ensuring babar is well defined
assert:
that:
- "babar == 'elephant'"
- name: Ensuring lxc_hosts_package_state is well overriden
assert:
that:
- "lxc_hosts_package_state == 'present'"
- name: Ensuring host vars
hosts: localhost
gather_facts: no
connection: local
user: root
tasks:
- name: Ensuring tintin has milou
assert:
that:
- "tintin == 'milou'"
- name: Ensuring security_package_state is overriden
assert:
that:
- "security_package_state == 'present'"

View File

@ -35,6 +35,13 @@
action: deploy
scenario: aio
# Ensuring overrides work
- job:
name: openstack-ansible-varstest-aio-ubuntu-xenial
parent: openstack-ansible-deploy-aio-ubuntu-xenial
vars:
action: varstest
# ubuntu
- job:
name: openstack-ansible-deploy-aio-ubuntu-xenial

View File

@ -18,6 +18,7 @@
check:
jobs:
- openstack-ansible-linters
- openstack-ansible-varstest-aio-ubuntu-xenial
- openstack-ansible-deploy-aio-centos-7
- openstack-ansible-deploy-aio-opensuse-423
- openstack-ansible-deploy-aio-ubuntu-xenial
@ -30,6 +31,7 @@
gate:
jobs:
- openstack-ansible-linters
- openstack-ansible-varstest-aio-ubuntu-xenial
- openstack-ansible-deploy-aio-ubuntu-xenial
- openstack-ansible-deploy-ceph-ubuntu-xenial
periodic: