2015-07-15 17:14:39 +07:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
# Thanks to https://servercheck.in/blog/testing-ansible-roles-travis-ci-github
|
|
|
|
|
|
|
|
DIR=$( dirname $0 )
|
|
|
|
PLAYBOOK="$DIR/test.yml"
|
|
|
|
|
|
|
|
set -ev
|
|
|
|
|
|
|
|
# Check syntax
|
2016-03-23 23:27:59 +07:00
|
|
|
ansible-playbook -i localhost, -c local --syntax-check -vv $PLAYBOOK
|
2015-07-15 17:14:39 +07:00
|
|
|
|
|
|
|
# Check role
|
2016-03-23 23:27:59 +07:00
|
|
|
ansible-playbook -i localhost, -c local --sudo -vv $PLAYBOOK
|
2015-07-15 17:14:39 +07:00
|
|
|
|
|
|
|
# Check indempotence
|
2016-03-23 23:27:59 +07:00
|
|
|
ansible-playbook -i localhost, -c local --sudo -vv $PLAYBOOK \
|
2015-07-15 17:14:39 +07:00
|
|
|
| grep -q 'changed=0.*failed=0' \
|
|
|
|
&& (echo 'Idempotence test: pass' && exit 0) \
|
|
|
|
|| (echo 'Idempotence test: fail' && exit 1)
|