Enable ansible lint and syntax tests

This prepares the role for the next stage of testing, enabling role
convergence testing.

Change-Id: I12a9621ce3604fd7d2d3609b0586c894eeea9e9a
This commit is contained in:
Steve Lewis 2016-04-11 16:08:20 -07:00
parent b3a6391503
commit 3610b115bb
4 changed files with 100 additions and 21 deletions

View File

@ -0,0 +1,52 @@
- name: apt_package_pinning
src: https://git.openstack.org/openstack/openstack-ansible-apt_package_pinning
scm: git
version: master
- name: pip_install
src: https://git.openstack.org/openstack/openstack-ansible-pip_install
scm: git
version: master
- name: pip_lock_down
src: https://git.openstack.org/openstack/openstack-ansible-pip_lock_down
scm: git
version: master
- name: lxc_hosts
src: https://git.openstack.org/openstack/openstack-ansible-lxc_hosts
scm: git
version: master
- name: lxc_container_create
src: https://git.openstack.org/openstack/openstack-ansible-lxc_container_create
scm: git
version: master
- name: openstack_hosts
src: https://git.openstack.org/openstack/openstack-ansible-openstack_hosts
scm: git
version: master
- name: memcached_server
src: https://git.openstack.org/openstack/openstack-ansible-memcached_server
scm: git
version: master
- name: galera_client
src: https://git.openstack.org/openstack/openstack-ansible-galera_client
scm: git
version: master
- name: galera_server
src: https://git.openstack.org/openstack/openstack-ansible-galera_server
scm: git
version: master
- name: rabbitmq_server
src: https://git.openstack.org/openstack/openstack-ansible-rabbitmq_server
scm: git
version: master
- name: openstack_openrc
src: https://git.openstack.org/openstack/openstack-ansible-openstack_openrc
scm: git
version: master
- name: os_keystone
src: https://git.openstack.org/openstack/openstack-ansible-os_keystone
scm: git
version: master
- name: os_ceilometer
src: https://git.openstack.org/openstack/openstack-ansible-os_ceilometer
scm: git
version: master

2
tests/inventory Normal file
View File

@ -0,0 +1,2 @@
[all]
localhost ansible_connection=local ansible_become=True

33
tests/test.yml Normal file
View File

@ -0,0 +1,33 @@
---
# 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: Create ssh key pairs for use with containers
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 }}"

34
tox.ini
View File

@ -84,31 +84,23 @@ commands =
[testenv:ansible-syntax]
commands =
echo -e "\n *******************************************************\n" \
"**** Syntax Testing is still to be implemented ****\n" \
"**** TODO: Make these pass ****\n" \
"*******************************************************\n"
# rm -rf {homedir}/.ansible
# git clone https://git.openstack.org/openstack/openstack-ansible-plugins \
# {homedir}/.ansible/plugins
# ansible-galaxy install \
# --role-file={toxinidir}/tests/ansible-role-requirements.yml \
# --ignore-errors \
# --force
# ansible-playbook -i {toxinidir}/tests/inventory \
# --syntax-check \
# --list-tasks \
# -e "rolename={toxinidir}" \
# {toxinidir}/tests/test.yml
rm -rf {homedir}/.ansible
git clone https://git.openstack.org/openstack/openstack-ansible-plugins \
{homedir}/.ansible/plugins
ansible-galaxy install \
--role-file={toxinidir}/tests/ansible-role-requirements.yml \
--ignore-errors \
--force
ansible-playbook -i {toxinidir}/tests/inventory \
--syntax-check \
--list-tasks \
-e "rolename={toxinidir}" \
{toxinidir}/tests/test.yml
[testenv:ansible-lint]
commands =
echo -e "\n *******************************************************\n" \
"**** Syntax Testing is still to be implemented ****\n" \
"**** TODO: Make these pass ****\n" \
"*******************************************************\n"
# ansible-lint {toxinidir}/tests/test.yml
ansible-lint {toxinidir}/tests/test.yml
[testenv:functional]