Skip to content

Commit

Permalink
WIP: Add ansible-role-functional-centos-7 job
Browse files Browse the repository at this point in the history
Add an example ansible functional jobs using tests from the test
folder. This leverages tox to allow a user to run these locally if
needed.

Signed-off-by: Paul Belanger <pabelanger@redhat.com>
  • Loading branch information
pabelanger committed Mar 27, 2018
1 parent c783cbb commit 94fb6be
Show file tree
Hide file tree
Showing 7 changed files with 55 additions and 2 deletions.
25 changes: 25 additions & 0 deletions .zuul.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,31 @@
- nodeset:
name: centos-7
nodes:
- name: centos-7
label: dib-centos-7

- job:
name: ansible-role-functional-base
abstract: true
parent: tox
description: |
Run functional functional tests for ansible-role projects.
Uses tox with the ``functional`` environment.
pre-run: playbooks/ansible-role-functional/pre.yaml
run: playbooks/tox-with-sudo/run.yaml
vars:
tox_envlist: functional

- job:
name: ansible-role-functional-centos-7
parent: ansible-role-functional-base
nodeset: centos-7

- project:
check:
jobs:
- ansible-role-functional-centos-7
- tox-linters
gate:
jobs:
Expand Down
11 changes: 11 additions & 0 deletions playbooks/ansible-role-functional/pre.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
- hosts: all
name: Set up SSH login
tasks:
- name: Allow ssh login into localhost
shell:
cmd: |
# Allow user to ssh into localhost
ssh-keygen -f ~/.ssh/id_rsa -N ""
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
ssh-keyscan localhost >> ~/.ssh/known_hosts
ssh-keyscan 127.0.0.1 >> ~/.ssh/known_hosts
3 changes: 3 additions & 0 deletions playbooks/tox-with-sudo/run.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- hosts: all
roles:
- tox
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
flake8
ansible
2 changes: 2 additions & 0 deletions tests/ansible.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
[defaults]
roles_path = ../..
5 changes: 3 additions & 2 deletions tests/test.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
---
- hosts: localhost
remote_user: root
vars:
rolename: "{{ lookup('pipe', 'pwd') | dirname | basename }}"
roles:
- network-engine
- "{{ rolename }}"
10 changes: 10 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@ skipsdist = True
[testenv]
deps = -r{toxinidir}/test-requirements.txt

[testenv:functional]
commands =
ansible-playbook -i tests/inventory tests/test.yaml
passenv =
HOME
USER
setenv =
ANSIBLE_CONFIG = {toxinidir}/tests/ansible.cfg
PYTHONUNBUFFERED = 1

[testenv:venv]
commands = {posargs}

Expand Down

0 comments on commit 94fb6be

Please sign in to comment.