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:
parent
33836d3d5e
commit
dbe09ddf6f
@ -145,6 +145,11 @@ pushd "${OSA_CLONE_DIR}/tests"
|
||||
fi
|
||||
popd
|
||||
|
||||
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
|
||||
@ -187,6 +192,7 @@ pushd "${OSA_CLONE_DIR}/playbooks"
|
||||
log_instance_info
|
||||
|
||||
popd
|
||||
fi
|
||||
|
||||
# If the action is to upgrade, then checkout the original SHA for
|
||||
# the checkout, and execute the upgrade.
|
||||
|
@ -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"'
|
||||
|
44
tests/test-vars-overrides.yml
Normal file
44
tests/test-vars-overrides.yml
Normal 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'"
|
@ -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
|
||||
|
@ -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:
|
||||
|
Loading…
Reference in New Issue
Block a user