Add ansible-syntax to tox -eansible-lint

Here we are using ansible-playbook to validate the syntax of our role.

Change-Id: I751392769774b44b9cf8d6f0cddf60b591c345cd
Signed-off-by: Paul Belanger <pabelanger@redhat.com>
This commit is contained in:
Paul Belanger 2015-11-12 12:54:17 -05:00
parent 98ffeca217
commit bbffbc01d9
5 changed files with 42 additions and 0 deletions

2
tests/ansible.cfg Normal file
View File

@ -0,0 +1,2 @@
[defaults]
roles_path = ..

1
tests/inventory Normal file
View File

@ -0,0 +1 @@
localhost

17
tests/test001.yaml Normal file
View File

@ -0,0 +1,17 @@
# Copyright 2015 Red Hat, 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.
---
- hosts: localhost
roles:
- "{{ rolename }}"

17
tests/test002.yaml Normal file
View File

@ -0,0 +1,17 @@
# Copyright 2015 Red Hat, 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.
---
- hosts: localhost
roles:
- { role: "{{ rolename }}", nodepool_install_method: 'pip' }

View File

@ -8,9 +8,14 @@ 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' -execdir ansible-lint \{\} \;"
bash -c "find tests -type f -regex '.*.y[a]?ml' | xargs -n1 \
ansible-playbook --syntax-check -i tests/inventory \
-e rolename=$(basename $(pwd))"
[testenv:venv]
commands = {posargs}