Added idempotence test and integration test via Travis.

This commit is contained in:
Jeff Geerling 2014-04-22 08:47:05 -05:00
parent 70e6ecff60
commit 0e3a6bb463
2 changed files with 20 additions and 1 deletions

View file

@ -5,8 +5,11 @@ env:
- SITE=test.yml
before_install:
- sudo apt-get update -qq
- sudo apt-get install -y curl
install:
- pip install ansible==1.5.0
script:
- ansible-playbook -i tests/inventory tests/$SITE --syntax-check
- ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo
- ./tests/idempotence.sh
- curl http://localhost/

16
tests/idempotence.sh Normal file
View file

@ -0,0 +1,16 @@
#!/bin/sh
# Idempotency test for Ansible
#
# Runs an Ansible role/playbook, and makes sure no changes were made.
#
# @author Jeff Geerling, 2014
# Change directory up one level (into project root).
cd ../
# Run playbook, and exit with 0 status if 'changed=0' found (good).
ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo | grep -q 'changed=0' && exit 0
# Exit with a non-zero status if 'changed=0' was not found.
exit 1