From 0e3a6bb46326254402da0681fd197f94aa788ade Mon Sep 17 00:00:00 2001 From: Jeff Geerling Date: Tue, 22 Apr 2014 08:47:05 -0500 Subject: [PATCH] Added idempotence test and integration test via Travis. --- .travis.yml | 5 ++++- tests/idempotence.sh | 16 ++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 tests/idempotence.sh diff --git a/.travis.yml b/.travis.yml index c4f2155..7449036 100644 --- a/.travis.yml +++ b/.travis.yml @@ -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 \ No newline at end of file + - ansible-playbook -i tests/inventory tests/$SITE --connection=local --sudo + - ./tests/idempotence.sh + - curl http://localhost/ diff --git a/tests/idempotence.sh b/tests/idempotence.sh new file mode 100644 index 0000000..68d5dee --- /dev/null +++ b/tests/idempotence.sh @@ -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