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,6 +145,11 @@ pushd "${OSA_CLONE_DIR}/tests"
fi fi
popd popd
if [[ "${ACTION}" == "varstest" ]]; then
pushd "${OSA_CLONE_DIR}/tests"
openstack-ansible test-vars-overrides.yml
popd
else
pushd "${OSA_CLONE_DIR}/playbooks" pushd "${OSA_CLONE_DIR}/playbooks"
# Disable Ansible color output # Disable Ansible color output
export ANSIBLE_NOCOLOR=1 export ANSIBLE_NOCOLOR=1
@ -187,6 +192,7 @@ pushd "${OSA_CLONE_DIR}/playbooks"
log_instance_info log_instance_info
popd popd
fi
# If the action is to upgrade, then checkout the original SHA for # If the action is to upgrade, then checkout the original SHA for
# the checkout, and execute the upgrade. # the checkout, and execute the upgrade.

View File

@ -184,3 +184,28 @@
when: pip_conf_file.stat.exists when: pip_conf_file.stat.exists
tags: tags:
- container-conf-files - 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 action: deploy
scenario: aio scenario: aio
# Ensuring overrides work
- job:
name: openstack-ansible-varstest-aio-ubuntu-xenial
parent: openstack-ansible-deploy-aio-ubuntu-xenial
vars:
action: varstest
# ubuntu # ubuntu
- job: - job:
name: openstack-ansible-deploy-aio-ubuntu-xenial name: openstack-ansible-deploy-aio-ubuntu-xenial

View File

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