Skip to content

Commit

Permalink
Fixup lint.sh: Only one ignore was considered at a time
Browse files Browse the repository at this point in the history
ansible-lint seems to only consider the last `-x` parameter given.
This constructs a single list to pass to `-x`.

Reported upstream as ansible/ansible-lint#279
  • Loading branch information
KellerFuchs committed Sep 7, 2017
1 parent 39dbbf8 commit 6ae24d3
Showing 1 changed file with 15 additions and 7 deletions.
22 changes: 15 additions & 7 deletions lint.sh
Expand Up @@ -3,25 +3,33 @@
set -e

# Global options
declare -a OPTIONS=( -x ANSIBLE0011 --exclude=roles/coreos-bootstrap )
declare -a OPTIONS=( --exclude=roles/coreos-bootstrap )
declare -a IGNORES=( ANSIBLE0011 )

# Per-file options
declare -A F_OPTIONS=(
[shell.yml]="-x ANSIBLE0006"
[ldap_ban.yml]="-x ANSIBLE0012"
# Per-file lint ignores
declare -A F_IGNORES=(
[shell.yml]="ANSIBLE0006"
[ldap_ban.yml]="ANSIBLE0012"
)

exec() {
function exec() {
echo '$' "$@"
"$@"
}

function join {
local IFS="$1"
shift
echo "$*"
}

if ! command -v ansible-lint >/dev/null; then
echo "This script requires ansible-lint"
exit 1
fi

for playbook in *.yml; do
exec ansible-lint "${OPTIONS[@]}" ${F_OPTIONS[$playbook]} $playbook
exec ansible-lint "${OPTIONS[@]}" \
-x "$(join , ${IGNORES[@]} ${F_IGNORES[$playbook]})" \
$playbook
done

0 comments on commit 6ae24d3

Please sign in to comment.