summaryrefslogtreecommitdiff
path: root/tests/ansible-lint-test.sh
blob: d95d45ecbbff711ea6fc2c0e515ee315fd09aa8e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#!/bin/bash -x

echo "=> Linting Ansible Code"
fail_ansible=0
for f in `find ../ -name "*.yml"`; do
    echo "==> LINTING $f"
    ansible-lint -x 504 -x metadata -x reliability -x idiom -x formatting -x ANSIBLE0004 $f # Ignore GIT check
    rc=$?
    if [[ $rc != 0 ]]; then
        echo "==> LINTING FAIL: $f"
        fail_ansible=1
    fi
done

for f in `find ../ -maxdepth 1 -name "*.yml"`; do
    echo "==> SYNTAX CHECK $f"
    ansible-playbook --syntax-check $f
    rc=$?
    if [[ $rc != 0 ]]; then
        echo "==> SYNTAX CHECK FAIL: $f"
        fail_ansible=1
    fi
done

if [[ $fail_ansible == 1 ]]; then
    echo "=> FAIL"
    exit 1
else
    echo "=> SUCCESS"
fi