ansible-mysql/tests/travis.sh

22 lines
710 B
Bash
Raw Normal View History

2015-07-12 17:15:59 +07:00
#!/bin/sh
# Thanks to https://servercheck.in/blog/testing-ansible-roles-travis-ci-github
DIR=$( dirname $0 )
2016-09-25 17:47:36 +07:00
INVENTORY_FILE="localhost,"
PLAYBOOK="$DIR/travis.yml"
2015-07-12 17:15:59 +07:00
set -ev
# Check syntax
ansible-playbook -i $INVENTORY_FILE -c local --syntax-check -vv $PLAYBOOK
# Check role
2016-09-25 17:47:36 +07:00
ansible-playbook -i $INVENTORY_FILE -c local -e "{ mysql_vendor: $VENDOR, mysql_origin: $ORIGIN }" --sudo -vv $PLAYBOOK
2015-07-12 17:15:59 +07:00
# Check indempotence
ansible-playbook -i $INVENTORY_FILE -c local -e "{ mysql_vendor: $VENDOR, mysql_origin: $ORIGIN }" --sudo -vv $PLAYBOOK > idempot.txt
grep -q 'changed=0.*failed=0' idempot.txt \
2015-07-12 17:15:59 +07:00
&& (echo 'Idempotence test: pass' && exit 0) \
|| (echo 'Idempotence test: FAIL' && cat idempot.txt && exit 1)