Fix ansible-lint.sh script for roles and playbooks

- According to the ansible-lint documentation, we can pass a role directory as
  an argument. But due to https://github.com/willthames/ansible-lint/issues/210,
  the role directory has to contain a trailing slash!

- This patch fixes the following ansible-lint rules:
  * ANSIBLE0013: Use Shell only when shell functionality is required

- It enables the ansible-lint verbose mode.

Change-Id: I9a34fcb36758b6ec6019c50ea4633ab35ce21f8c
Signed-off-by: Gael Chamoulaud <gchamoul@redhat.com>
This commit is contained in:
Gael Chamoulaud 2017-02-09 12:33:14 +01:00
parent 7a573c2f9d
commit bb0324552e
2 changed files with 11 additions and 5 deletions

View File

@ -8,13 +8,20 @@ SKIPLIST="ANSIBLE0006,ANSIBLE0016"
# lint the playbooks separately to avoid linting the roles multiple times
pushd playbooks
find . -type f -regex '.*\.y[a]?ml' -print0 | xargs -0 ansible-lint -x $SKIPLIST || lint_error=1
for playbook in `find . -type f -regex '.*\.y[a]?ml'`; do
ansible-lint -vvv -x $SKIPLIST $playbook || lint_error=1
done
popd
# lint all the possible roles
find ./roles -type d -print0 | xargs -0 ansible-lint -x $SKIPLIST || lint_error=1
# Due to https://github.com/willthames/ansible-lint/issues/210, the roles
# directories need to contain a trailing slash at the end of the path.
for rolesdir in `find ./roles -maxdepth 1 -type d`; do
ansible-lint -vvv -x $SKIPLIST $rolesdir/ || lint_error=1
done
# exit with 1 if we had any error so far
# exit with 1 if we had a least an error or warning.
if [[ -n "$lint_error" ]]; then
exit 1;
fi

View File

@ -48,8 +48,7 @@
- when: inventory == 'multinode'
block:
- name: Get subnodes
shell: >-
cat /etc/nodepool/sub_nodes_private
command: cat /etc/nodepool/sub_nodes_private
register: nodes
- name: Add subnode to ansible inventory