Zack Williams | 1aaa3b1 | 2016-09-01 09:55:17 -0700 | [diff] [blame] | 1 | #!/usr/bin/env bash |
| 2 | set +e |
| 3 | fail_ansible=0 |
| 4 | |
| 5 | # verify that we have ansible-lint installed |
| 6 | command -v ansible-lint >/dev/null 2>&1 || { echo "ansible-lint not found, please install it" >&2; exit 1; } |
| 7 | |
| 8 | # when not running under Jenkins, use current dir as workspace |
| 9 | WORKSPACE=${WORKSPACE:-.} |
| 10 | |
| 11 | echo "=> Linting Ansible Code with" `ansible-lint --version` |
| 12 | for f in `find $WORKSPACE -name "*.yml"`; do |
| 13 | echo "==> CHECKING: $f" |
| 14 | ansible-lint -p $f |
| 15 | rc=$? |
| 16 | if [[ $rc != 0 ]]; then |
| 17 | echo "==> LINTING FAIL: $f" |
| 18 | fail_ansible=1 |
| 19 | fi |
| 20 | done |
| 21 | |
| 22 | exit 0 |