Ansible 2.1.1 role testing
Change-Id: I9132c4686f130610de24a2c7b002172d3daf3bff Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
parent
84b73aea3f
commit
3e73c5b3fb
1
.gitignore
vendored
1
.gitignore
vendored
@ -29,6 +29,7 @@ doc/build/
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
logs/
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
|
@ -39,3 +39,4 @@ python-ndg_httpsclient [platform:rpm]
|
||||
|
||||
# Required for compressing collected log files in CI
|
||||
gzip
|
||||
|
||||
|
@ -9,7 +9,7 @@ export ANSIBLE_ACTION_PLUGINS=${HOME}/.ansible/plugins/action
|
||||
export ANSIBLE_CALLBACK_PLUGINS=${HOME}/.ansible/plugins/callback
|
||||
export ANSIBLE_FILTER_PLUGINS=${HOME}/.ansible/plugins/filter
|
||||
export ANSIBLE_LOOKUP_PLUGINS=${HOME}/.ansible/plugins/lookup
|
||||
|
||||
export ANSIBLE_TRANSPORT=ssh
|
||||
# This is required as the default is the current path or a path specified
|
||||
# in ansible.cfg
|
||||
export ANSIBLE_LIBRARY=${HOME}/.ansible/plugins/library
|
||||
|
10
run_tests.sh
10
run_tests.sh
@ -24,23 +24,23 @@ if [ ! "$(which pip)" ]; then
|
||||
fi
|
||||
|
||||
# Install bindep and tox
|
||||
pip install bindep tox
|
||||
sudo pip install bindep tox
|
||||
|
||||
# CentOS 7 requires two additional packages:
|
||||
# redhat-lsb-core - for bindep profile support
|
||||
# epel-release - required to install python-ndg_httpsclient/python2-pyasn1
|
||||
if [ "$(which yum)" ]; then
|
||||
yum -y install redhat-lsb-core epel-release
|
||||
sudo yum -y install redhat-lsb-core epel-release
|
||||
fi
|
||||
|
||||
# Install OS packages using bindep
|
||||
if apt-get -v >/dev/null 2>&1 ; then
|
||||
apt-get update
|
||||
sudo apt-get update
|
||||
DEBIAN_FRONTEND=noninteractive \
|
||||
apt-get -q --option "Dpkg::Options::=--force-confold" \
|
||||
sudo apt-get -q --option "Dpkg::Options::=--force-confold" \
|
||||
--assume-yes install `bindep -b -f bindep.txt test`
|
||||
else
|
||||
yum install -y `bindep -b -f bindep.txt test`
|
||||
sudo yum install -y `bindep -b -f bindep.txt test`
|
||||
fi
|
||||
|
||||
# run through each tox env and execute the test
|
||||
|
@ -155,6 +155,7 @@
|
||||
file:
|
||||
path: "{{ item['host_directory'] }}"
|
||||
state: "directory"
|
||||
recurse: true
|
||||
with_items: "{{ lxc_container_default_bind_mounts | union(lxc_container_bind_mounts) }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
|
||||
|
19
tests/host_vars/localhost.yml
Normal file
19
tests/host_vars/localhost.yml
Normal file
@ -0,0 +1,19 @@
|
||||
---
|
||||
# Copyright 2016, 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.
|
||||
|
||||
bridges:
|
||||
- "br-mgmt"
|
||||
|
||||
ansible_python_interpreter: "/usr/bin/python2"
|
@ -1,5 +1,5 @@
|
||||
[all]
|
||||
localhost ansible_connection=local physical_host=localhost ansible_become=True
|
||||
localhost ansible_become=True
|
||||
container1 ansible_host=10.100.100.2 ansible_become=True ansible_user=root
|
||||
container2 ansible_host=10.100.100.3 ansible_become=True ansible_user=root
|
||||
container3 ansible_host=10.100.100.4 ansible_become=True ansible_user=root
|
||||
|
@ -80,8 +80,6 @@
|
||||
assert:
|
||||
that:
|
||||
- "'/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games' in environment_content"
|
||||
- "'http_proxy=http://someproxy.example.com' in environment_content"
|
||||
- "'https_proxy=https://someproxy.example.com' in environment_content"
|
||||
- name: Test connectivity to external address
|
||||
shell: ping -c 3 8.8.8.8
|
||||
register: ping_external_address
|
||||
|
@ -1,54 +0,0 @@
|
||||
---
|
||||
# Copyright 2015, 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: Playbook for creating containers
|
||||
hosts: all_containers
|
||||
gather_facts: false
|
||||
pre_tasks:
|
||||
- name: Destroy test containers
|
||||
lxc_container:
|
||||
name: "{{ container_name }}"
|
||||
state: "absent"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- container-destroy
|
||||
- name: Destroy container service directories
|
||||
file:
|
||||
path: "{{ item }}"
|
||||
state: "absent"
|
||||
with_items:
|
||||
- "/openstack/{{ container_name }}"
|
||||
- "/openstack/backup/{{ container_name }}"
|
||||
- "/openstack/log/{{ container_name }}"
|
||||
- "/var/lib/lxc/{{ container_name }}"
|
||||
- "{{ lxc_container_directory|default('/var/lib/lxc') }}/{{ container_name }}"
|
||||
delegate_to: "{{ physical_host }}"
|
||||
tags:
|
||||
- container-directories
|
||||
roles:
|
||||
- role: "{{ rolename | basename }}"
|
||||
lxc_container_release: trusty
|
||||
lxc_container_backing_store: dir
|
||||
global_environment_variables:
|
||||
http_proxy: "http://someproxy.example.com"
|
||||
https_proxy: "https://someproxy.example.com"
|
||||
post_tasks:
|
||||
- name: Wait for ssh to be available
|
||||
local_action:
|
||||
module: wait_for
|
||||
port: "{{ ansible_ssh_port | default('22') }}"
|
||||
host: "{{ ansible_ssh_host | default(inventory_hostname) }}"
|
||||
search_regex: OpenSSH
|
||||
delay: 1
|
@ -1,48 +0,0 @@
|
||||
---
|
||||
# Copyright 2015, 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: Playbook for configuring LXC host
|
||||
hosts: localhost
|
||||
connection: local
|
||||
pre_tasks:
|
||||
# Make sure OS does not have a stale package cache.
|
||||
- name: Update apt cache
|
||||
apt:
|
||||
update_cache: yes
|
||||
when: ansible_os_family == 'Debian'
|
||||
- name: Ensure root's new public ssh key is in authorized_keys
|
||||
authorized_key:
|
||||
user: root
|
||||
key: "{{ hostvars['localhost']['lxc_container_ssh_key'] }}"
|
||||
manage_dir: no
|
||||
- set_fact:
|
||||
lxc_container_ssh_key: "{{ hostvars['localhost']['lxc_container_ssh_key'] }}"
|
||||
- name: Check if this is an OpenStack-CI nodepool instance
|
||||
stat:
|
||||
path: /etc/nodepool/provider
|
||||
register: nodepool
|
||||
- name: Set the files to copy into the container cache for OpenStack-CI instances
|
||||
set_fact:
|
||||
lxc_container_cache_files:
|
||||
- { src: '/etc/pip.conf', dest: '/etc/pip.conf' }
|
||||
when:
|
||||
- nodepool.stat.exists | bool
|
||||
roles:
|
||||
- role: "lxc_hosts"
|
||||
lxc_net_address: 10.100.100.1
|
||||
lxc_net_dhcp_range: 10.100.100.8,10.100.100.253
|
||||
lxc_net_bridge: lxcbr0
|
||||
lxc_kernel_options:
|
||||
- { key: 'fs.inotify.max_user_instances', value: 1024 }
|
@ -1,33 +0,0 @@
|
||||
---
|
||||
# Copyright 2015, 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.
|
||||
|
||||
# NOTE: we use become_user because setting become: no or become: false
|
||||
# doesn't seem to override the ansible_become=true in the
|
||||
# inventory
|
||||
- name: Playbook for establishing ssh keys
|
||||
hosts: localhost
|
||||
become_user: "{{ ansible_ssh_user }}"
|
||||
pre_tasks:
|
||||
- name: Create ssh key pair for root
|
||||
user:
|
||||
name: "{{ ansible_ssh_user }}"
|
||||
generate_ssh_key: "yes"
|
||||
ssh_key_bits: 2048
|
||||
ssh_key_file: ".ssh/id_rsa"
|
||||
- name: Get the calling user's key
|
||||
command: cat ~/.ssh/id_rsa.pub
|
||||
register: key_get
|
||||
- set_fact:
|
||||
lxc_container_ssh_key: "{{ key_get.stdout }}"
|
@ -13,14 +13,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
# Prepare the user ssh keys
|
||||
- include: test-prepare-keys.yml
|
||||
|
||||
# Prepare the host
|
||||
- include: test-prepare-host.yml
|
||||
|
||||
# Prepare the containers
|
||||
- include: test-prepare-containers.yml
|
||||
# Setup the host
|
||||
- include: playbooks/test-setup-host.yml
|
||||
|
||||
# Test container creation
|
||||
- include: test-containers-functional.yml
|
||||
|
8
tox.ini
8
tox.ini
@ -94,7 +94,7 @@ commands =
|
||||
[testenv:ansible]
|
||||
deps =
|
||||
{[testenv]deps}
|
||||
ansible==1.9.4
|
||||
ansible==2.1.1.0
|
||||
ansible-lint>=2.7.0,<3.0.0
|
||||
setenv =
|
||||
{[testenv]setenv}
|
||||
@ -113,6 +113,7 @@ setenv =
|
||||
# This is required as the default is '/etc/ansible/roles' or a path
|
||||
# specified in ansible.cfg
|
||||
ANSIBLE_ROLES_PATH = {homedir}/.ansible/roles:{toxinidir}/..
|
||||
ANSIBLE_TRANSPORT = ssh
|
||||
commands =
|
||||
rm -rf {homedir}/.ansible/plugins
|
||||
git clone https://git.openstack.org/openstack/openstack-ansible-plugins \
|
||||
@ -121,6 +122,11 @@ commands =
|
||||
ansible-galaxy install \
|
||||
--role-file={toxinidir}/tests/ansible-role-requirements.yml \
|
||||
--force
|
||||
rm -rf {homedir}/.ansible/roles/lxc_container_create
|
||||
bash -c "ln -s {toxinidir} {homedir}/.ansible/roles/lxc_container_create"
|
||||
rm -rf {toxinidir}/tests/playbooks
|
||||
git clone https://git.openstack.org/openstack/openstack-ansible-tests \
|
||||
{toxinidir}/tests/playbooks
|
||||
|
||||
|
||||
[testenv:ansible-syntax]
|
||||
|
Loading…
Reference in New Issue
Block a user