From bd142ffa4b143ee99aaa595fd6c699bc3f9f7675 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Tue, 27 Mar 2018 22:11:27 -0400 Subject: [PATCH] Add tox deploy job to validate bootstrap process When a user tries windmill, they have a multiple options to actually run ansible. However, we can atleast provide a basic way to bootstrap a host and validate our playbooks and roles are in working order. This could also be a simple way to try newer version of ansible, under zuul gains the ability to support that. Change-Id: I4e97b0f10437adf7a153148cc7fa5ae45e81d4de Signed-off-by: Paul Belanger --- .zuul.d/jobs-tox.yaml | 19 +++++++++++++++++++ .zuul.d/projects.yaml | 6 ++++++ requirements.txt | 1 + tests/extra-vars.yaml | 5 +++++ tests/playbooks/tox/run.yaml | 3 +++ tools/install_roles.sh | 6 ++++++ tox.ini | 34 ++-------------------------------- 7 files changed, 42 insertions(+), 32 deletions(-) create mode 100644 .zuul.d/jobs-tox.yaml create mode 100644 tests/extra-vars.yaml create mode 100644 tests/playbooks/tox/run.yaml diff --git a/.zuul.d/jobs-tox.yaml b/.zuul.d/jobs-tox.yaml new file mode 100644 index 0000000..a37fa18 --- /dev/null +++ b/.zuul.d/jobs-tox.yaml @@ -0,0 +1,19 @@ +- job: + name: windmill-tox-deploy + parent: tox + run: tests/playbooks/tox/run.yaml + nodeset: ubuntu-xenial + required-projects: + - openstack/ansible-role-diskimage-builder + - openstack/ansible-role-gearman + - openstack/ansible-role-logrotate + - openstack/ansible-role-nodepool + - openstack/ansible-role-shade + - openstack/ansible-role-ssh + - openstack/ansible-role-sudoers + - openstack/ansible-role-virtualenv + - openstack/ansible-role-zookeeper + - openstack/ansible-role-zuul + vars: + tox_envlist: deploy + tox_extra_args: '-vv -- --extra-vars "@tests/extra-vars.yaml"' diff --git a/.zuul.d/projects.yaml b/.zuul.d/projects.yaml index 9642ef3..250eab6 100644 --- a/.zuul.d/projects.yaml +++ b/.zuul.d/projects.yaml @@ -4,3 +4,9 @@ - windmill-jobs-fedora-27 - windmill-jobs-bionic - windmill-jobs-xenial + check: + jobs: + - windmill-tox-deploy + gate: + jobs: + - windmill-tox-deploy diff --git a/requirements.txt b/requirements.txt index 4de76b1..967b03d 100644 --- a/requirements.txt +++ b/requirements.txt @@ -3,3 +3,4 @@ paramiko<2.0.0 ansible>=2.0.0,<2.4.0 bindep +netaddr diff --git a/tests/extra-vars.yaml b/tests/extra-vars.yaml new file mode 100644 index 0000000..0c5f287 --- /dev/null +++ b/tests/extra-vars.yaml @@ -0,0 +1,5 @@ +# NOTE(pabelanger): In the gate, we want to create a zuul-test user / +# group as zuul already exists on our images. +zuul_user_name: zuul-test +zuul_user_group: zuul-test +zuul_user_home: /var/lib/zuul diff --git a/tests/playbooks/tox/run.yaml b/tests/playbooks/tox/run.yaml new file mode 100644 index 0000000..22f8209 --- /dev/null +++ b/tests/playbooks/tox/run.yaml @@ -0,0 +1,3 @@ +- hosts: all + roles: + - tox diff --git a/tools/install_roles.sh b/tools/install_roles.sh index c88d3af..df4f0ab 100755 --- a/tools/install_roles.sh +++ b/tools/install_roles.sh @@ -15,4 +15,10 @@ TOOLSDIR=$(dirname $0) +# NOTE(pabelanger): Check if we are running in the gate, if so use cached repos +# to avoid hitting the network. +if [ -f /etc/ci/mirror_info.sh ]; then + sed -e "s|https://|file://${HOME}/src/|g" -i $TOOLSDIR/requirements.yaml +fi + ansible-galaxy install -v -r $TOOLSDIR/requirements.yaml -p playbooks/roles diff --git a/tox.ini b/tox.ini index 3a7dc8b..da8ed92 100644 --- a/tox.ini +++ b/tox.ini @@ -15,28 +15,14 @@ deps = -r{toxinidir}/requirements.txt deps = bindep commands = bindep test -[testenv:buildimages] -deps = -r{toxinidir}/requirements.txt -commands = - {toxinidir}/tools/install_bindep.sh - {toxinidir}/tools/install_roles.sh - # NOTE(pabelanger): Because ansible default ansible_user to null now, we need to pass it via CLI. - ansible-playbook -i playbooks/inventory playbooks/build-images.yaml -e ansible_user={env:USER} {posargs} -passenv = - HOME - SSH_AUTH_SOCK - USER -setenv = - ANSIBLE_CONFIG = {toxinidir}/playbooks/ansible.cfg - PYTHONUNBUFFERED = 1 - [testenv:deploy] deps = -r{toxinidir}/requirements.txt commands = {toxinidir}/tools/install_bindep.sh {toxinidir}/tools/install_roles.sh # NOTE(pabelanger): Because ansible default ansible_user to null now, we need to pass it via CLI. - ansible-playbook -i inventory/single-node playbooks/site.yaml -e ansible_user={env:USER} {posargs} + ansible-playbook -i inventory/single-node playbooks/bastion.yaml {posargs} + ansible-playbook -i inventory/single-node playbooks/site.yaml {posargs} passenv = HOME SSH_AUTH_SOCK @@ -45,22 +31,6 @@ setenv = ANSIBLE_CONFIG = {toxinidir}/playbooks/ansible.cfg PYTHONUNBUFFERED = 1 -[testenv:publish-images] -deps = -r{toxinidir}/requirements.txt -commands = - {toxinidir}/tools/install_bindep.sh - {toxinidir}/tools/install_roles.sh - # NOTE(pabelanger): Because ansible default ansible_user to null now, we need to pass it via CLI. - ansible-playbook -i playbooks/inventory playbooks/build-images.yaml -e ansible_user={env:USER} {posargs} -passenv = - HOME - SSH_AUTH_SOCK - USER - WORKSPACE -setenv = - ANSIBLE_CONFIG = {toxinidir}/playbooks/ansible.cfg - PYTHONUNBUFFERED = 1 - [testenv:docs] commands = python setup.py build_sphinx