From bb0324552eb535831d9361b8b2805a3764aaf2a5 Mon Sep 17 00:00:00 2001 From: Gael Chamoulaud Date: Thu, 9 Feb 2017 12:33:14 +0100 Subject: [PATCH] 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 --- ci-scripts/ansible-lint.sh | 13 ++++++++++--- roles/tripleo-inventory/tasks/main.yml | 3 +-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/ci-scripts/ansible-lint.sh b/ci-scripts/ansible-lint.sh index f03f5b4f8..e5c0ba694 100644 --- a/ci-scripts/ansible-lint.sh +++ b/ci-scripts/ansible-lint.sh @@ -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 + diff --git a/roles/tripleo-inventory/tasks/main.yml b/roles/tripleo-inventory/tasks/main.yml index 194e61bbd..ec11477cd 100644 --- a/roles/tripleo-inventory/tasks/main.yml +++ b/roles/tripleo-inventory/tasks/main.yml @@ -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