From 7284ca30ac767a5d02b7fd1a45e1430a9534a7c1 Mon Sep 17 00:00:00 2001 From: Paul Belanger Date: Fri, 20 Nov 2015 17:00:24 -0500 Subject: [PATCH] Add tox.ini and ansible-lint cleanup Signed-off-by: Paul Belanger --- .gitignore | 1 + requirements.txt | 1 + tasks/config.yaml | 8 ++++---- tasks/install/pip.yaml | 4 ++-- test-requirements.txt | 2 ++ tox.ini | 33 +++++++++++++++++++++++++++++++++ 6 files changed, 43 insertions(+), 6 deletions(-) create mode 100644 .gitignore create mode 100644 requirements.txt create mode 100644 test-requirements.txt create mode 100644 tox.ini diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..33defe4 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.tox/ diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..90d4055 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +ansible diff --git a/tasks/config.yaml b/tasks/config.yaml index aafad39..49ad600 100644 --- a/tasks/config.yaml +++ b/tasks/config.yaml @@ -10,7 +10,7 @@ dest: /var/lib/zuul/.ssh group: zuul mode: 0700 - owner: zuul + owner: zuul state: directory - name: Create ssh known hosts. @@ -19,7 +19,7 @@ dest: /var/lib/zuul/.ssh/known_hosts group: zuul mode: 0600 - owner: zuul + owner: zuul - name: Create ssh private key. copy: @@ -27,12 +27,12 @@ dest: /var/lib/zuul/.ssh/id_rsa group: zuul mode: 0600 - owner: zuul + owner: zuul - name: Create required directories. file: group: zuul - owner: zuul + owner: zuul path: "{{ item }}" state: directory with_items: diff --git a/tasks/install/pip.yaml b/tasks/install/pip.yaml index 8097496..b88d947 100644 --- a/tasks/install/pip.yaml +++ b/tasks/install/pip.yaml @@ -1,11 +1,11 @@ --- - name: Install zuul using pip. pip: - name: zuul + name: zuul when: zuul_pip_version is none - name: Install zuul using pip. pip: - name: zuul + name: zuul version: "{{ zuul_pip_version }}" when: zuul_pip_version is not none diff --git a/test-requirements.txt b/test-requirements.txt new file mode 100644 index 0000000..4c4414f --- /dev/null +++ b/test-requirements.txt @@ -0,0 +1,2 @@ +ansible-lint +hacking<0.11,>=0.10 diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..a363304 --- /dev/null +++ b/tox.ini @@ -0,0 +1,33 @@ +[tox] +minversion = 1.6 +envlist = ansible-lint,pep8 +skipsdist = True + +[testenv] +deps = -r{toxinidir}/requirements.txt + -r{toxinidir}/test-requirements.txt + +[testenv:ansible-lint] +setenv = + ANSIBLE_CONFIG = tests/ansible.cfg +whitelist_externals = bash +commands = + bash -c "find . -type f -regex '.*.y[a]?ml' -print0 | xargs -t -n1 -0 \ + ansible-lint" + bash -c "find tests -type f -regex '.*.y[a]?ml' -print | xargs -t -n1 \ + ansible-playbook --syntax-check -i tests/inventory \ + -e rolename=$(basename $(pwd)) > /dev/null" + +[testenv:ansible-functional] +commands = + ansible-playbook -i tests/inventory tests/test.yaml +passenv = HOME +setenv = + ANSIBLE_CONFIG = {toxinidir}/tests/ansible.cfg + PYTHONUNBUFFERED = 1 + +[testenv:pep8] +commands = flake8 + +[testenv:venv] +commands = {posargs}