ansible-nginx/tests/test.sh

21 lines
516 B
Bash
Raw Normal View History

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
ansible-playbook -i localhost, -c local --syntax-check -vv $PLAYBOOK
2015-07-15 17:14:39 +07:00
# Check role
ansible-playbook -i localhost, -c local --sudo -vv $PLAYBOOK
2015-07-15 17:14:39 +07:00
# Check indempotence
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)