Add Ansible testing infrastructure
The keypair test needed adjusting so that it would work in the gating environment, and anywhere an SSH key may not be available. Change-Id: Ic9bf41c2b4041911d05217ad3748e097326bac3a
This commit is contained in:
parent
ef0ccaaef4
commit
cb0e9130f5
|
@ -0,0 +1,35 @@
|
|||
#!/bin/bash
|
||||
#############################################################################
|
||||
# run-ansible-tests.sh
|
||||
#
|
||||
# Script used to setup a tox environment for running Ansible. This is meant
|
||||
# to be called by tox (via tox.ini). To run the Ansible tests, use:
|
||||
#
|
||||
# tox -e ansible
|
||||
#
|
||||
# USAGE:
|
||||
# run-ansible-tests.sh <envdir>
|
||||
#
|
||||
# PARAMETERS:
|
||||
# <envdir> Directory of the tox environment to use for testing.
|
||||
#############################################################################
|
||||
|
||||
ENVDIR=$1
|
||||
|
||||
if [ -d ${ENVDIR}/ansible ]
|
||||
then
|
||||
echo "Using existing Ansible install"
|
||||
else
|
||||
echo "Installing Ansible at $ENVDIR"
|
||||
git clone --recursive git://github.com/ansible/ansible.git ${ENVDIR}/ansible
|
||||
fi
|
||||
|
||||
# We need to source the current tox environment so that Ansible will
|
||||
# be setup for the correct python environment.
|
||||
source $ENVDIR/bin/activate
|
||||
|
||||
# Setup Ansible
|
||||
source $ENVDIR/ansible/hacking/env-setup
|
||||
|
||||
# Run the shade Ansible tests
|
||||
ansible-playbook -vvv ./shade/tests/ansible/run.yml -e "cloud=devstack-admin"
|
|
@ -0,0 +1,26 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
# 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.
|
||||
|
||||
export SHADE_DIR="$BASE/new/shade"
|
||||
|
||||
cd $SHADE_DIR
|
||||
sudo chown -R jenkins:stack $SHADE_DIR
|
||||
|
||||
echo "Running shade Ansible test suite"
|
||||
set +e
|
||||
sudo -E -H -u jenkins tox -eansible
|
||||
EXIT_CODE=$?
|
||||
set -e
|
||||
|
||||
exit $EXIT_CODE
|
|
@ -11,12 +11,18 @@
|
|||
name: "{{ keypair_name }}"
|
||||
state: absent
|
||||
|
||||
- name: Generate test key file
|
||||
user:
|
||||
name: "{{ ansible_env.USER }}"
|
||||
generate_ssh_key: yes
|
||||
ssh_key_file: .ssh/shade_id_rsa
|
||||
|
||||
- name: Create keypair (file)
|
||||
os_keypair:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ keypair_name }}"
|
||||
state: present
|
||||
public_key_file: "{{ ansible_env.HOME }}/.ssh/id_rsa.pub"
|
||||
public_key_file: "{{ ansible_env.HOME }}/.ssh/shade_id_rsa.pub"
|
||||
|
||||
- name: Delete keypair (file)
|
||||
os_keypair:
|
||||
|
@ -29,10 +35,20 @@
|
|||
cloud: "{{ cloud }}"
|
||||
name: "{{ keypair_name }}"
|
||||
state: present
|
||||
public_key: "{{ lookup('file', '~/.ssh/id_rsa.pub') }}"
|
||||
public_key: "{{ lookup('file', '~/.ssh/shade_id_rsa.pub') }}"
|
||||
|
||||
- name: Delete keypair (key)
|
||||
os_keypair:
|
||||
cloud: "{{ cloud }}"
|
||||
name: "{{ keypair_name }}"
|
||||
state: absent
|
||||
|
||||
- name: Delete test key pub file
|
||||
file:
|
||||
name: "{{ ansible_env.HOME }}/.ssh/shade_id_rsa.pub"
|
||||
state: absent
|
||||
|
||||
- name: Delete test key pvt file
|
||||
file:
|
||||
name: "{{ ansible_env.HOME }}/.ssh/shade_id_rsa"
|
||||
state: absent
|
||||
|
|
5
tox.ini
5
tox.ini
|
@ -30,6 +30,11 @@ commands = {posargs}
|
|||
[testenv:cover]
|
||||
commands = python setup.py testr --coverage --testr-args='{posargs}'
|
||||
|
||||
[testenv:ansible]
|
||||
# Need to pass some env vars for the Ansible playbooks
|
||||
passenv = HOME USER
|
||||
commands = {toxinidir}/extras/run-ansible-tests.sh {envdir}
|
||||
|
||||
[flake8]
|
||||
# Infra does not follow hacking, nor the broken E12* things
|
||||
ignore = E123,E125,E129,H
|
||||
|
|
Loading…
Reference in New Issue