ansible-php/tests/test.sh

24 lines
603 B
Bash
Raw Permalink Normal View History

2015-07-23 21:35:25 +07:00
#!/bin/sh
# Thanks to https://servercheck.in/blog/testing-ansible-roles-travis-ci-github
DIR=$( dirname $0 )
PLAYBOOK="$DIR/test.yml"
ANSIBLE_ARG="localhost"
2015-07-23 21:35:25 +07:00
set -ev
2016-01-22 22:29:43 +07:00
ansible --version
2015-07-23 21:35:25 +07:00
# Check syntax
ansible-playbook -i localhost, -c local --syntax-check -vv $PLAYBOOK
2015-07-23 21:35:25 +07:00
# Check role
ansible-playbook -i localhost, -c local -e "php_version=$1" --become -vv $PLAYBOOK
2015-07-23 21:35:25 +07:00
# Check indempotence
ansible-playbook -i localhost, -c local -e "php_version=$1" --become -vv $PLAYBOOK \
2015-07-23 21:35:25 +07:00
| grep -q 'changed=0.*failed=0' \
&& (echo 'Idempotence test: pass' && exit 0) \
|| (echo 'Idempotence test: fail' && exit 1)