-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- don't update the apt repositories cache when you're just adding new repos since it will get updated in the end - minor version number will now match primogen major version number - merge with ansiblebit.primogen v7 - upgrade tests to use ansible v1.9.2 instead of v1.9.1 - pass ANSIBLE_ASK_SUDO_PASS environment variable to the tox test environment - improved idempotence test - renamed fact os_supported to launchpad_ppa_webupd8_os_supported
- Loading branch information
Showing
11 changed files
with
97 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
--- | ||
# file: primogen/tests/tasks |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,29 @@ | ||
import sys | ||
import os | ||
|
||
VAR_IDEMPOTENCE = u'idempotence' | ||
|
||
|
||
class CallbackModule(object): | ||
""" | ||
This callback module tells you how long your plays ran for. | ||
This callback module performs the idempotence test whenever the 'idempotence' variable is set to True. | ||
""" | ||
|
||
def __init__(self): | ||
pass | ||
|
||
def playbook_on_stats(self, stats): | ||
|
||
if u'idempotence' in self.playbook.extra_vars.keys(): | ||
if (u'%s' % VAR_IDEMPOTENCE) in self.playbook.extra_vars.keys() and self.playbook.extra_vars[VAR_IDEMPOTENCE]: | ||
|
||
if len(stats.dark) > 0: | ||
print ('idempotence test failed! unreachable=%s > 0') % stats.dark | ||
sys.exit(os.EX_SOFTWARE) | ||
|
||
if (len(stats.changed) > 0): | ||
print 'idempotence test failed! changed=%s > 0' % stats.changed | ||
if len(stats.changed) > 0: | ||
print ('idempotence test failed! changed=%s > 0') % stats.changed | ||
sys.exit(os.EX_SOFTWARE) | ||
|
||
if (len(stats.failures) > 0): | ||
print 'idempotence test failed! failures=%s > 0' % stats.failures | ||
if len(stats.failures) > 0: | ||
print ('idempotence test failed! failures=%s > 0') % stats.failures | ||
sys.exit(os.EX_SOFTWARE) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,18 @@ | ||
--- | ||
# file: launchpad-ppa-webupd8/tests/vagrant.yml | ||
# file: launchpad-ppa-webupd8/tests/test.yml | ||
|
||
- name: tests play | ||
- name: provisioning play | ||
hosts: all | ||
gather_facts: yes | ||
|
||
roles: | ||
- launchpad-ppa-webupd8 | ||
- tests | ||
|
||
- name: tests play | ||
hosts: all | ||
gather_facts: yes | ||
tags: test | ||
|
||
roles: | ||
- { role: tests, | ||
when: idempotence is defined and idempotence } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,7 @@ | |
# | ||
# Bash script to run idempotence tests. | ||
# | ||
# version: 1.2 | ||
# version: 1.4 | ||
# | ||
# usage: | ||
# | ||
|
@@ -12,6 +12,7 @@ | |
# options: | ||
# | ||
# --box The name of the Vagrant box or host name | ||
# --env The name of the test environment | ||
# --inventory The Ansible inventory in the form of a file or string "host," | ||
# --playbook The path to the Ansible test playbook | ||
# | ||
|
@@ -22,10 +23,17 @@ | |
# | ||
# # on a Vagrant box | ||
# bash test_idempotence.sh \ | ||
# --box precise64 | ||
# --box precise64.vagrant.dev | ||
# --inventory .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory | ||
# | ||
# | ||
# changelog: | ||
# | ||
# v1.4 : 10 Jul 2015 | ||
# - added extra variables to force running idempotence tests on vagrant | ||
# v1.2 | ||
# - added env option | ||
# | ||
# author(s): | ||
# - Pedro Salgado <[email protected]> | ||
# | ||
|
@@ -56,6 +64,11 @@ key="$1" | |
BOX="$2" | ||
shift;; | ||
|
||
--env) | ||
# the test environment | ||
ENV="$2" | ||
shift;; | ||
|
||
--inventory) | ||
# the Ansible inventory in the form of a file or string "host," | ||
INVENTORY="$2" | ||
|
@@ -85,13 +98,13 @@ LOGFILE="log/${BOX}_${VIRTUALENV_NAME}.log" | |
|
||
EXTRA_ARGS='' | ||
if [ $BOX == "localhost" ]; then | ||
EXTRA_ARGS="--connection=local --extra-vars idempotence=yes" | ||
EXTRA_ARGS="--connection=local --extra-vars idempotence=yes --extra-vars env=${ENV}" | ||
else | ||
EXTRA_ARGS="--u vagrant" | ||
EXTRA_ARGS="--u vagrant --extra-vars idempotence=yes --extra-vars env=vagrant" | ||
fi | ||
|
||
echo "[INFO] ${BOX} ${VIRTUALENV_NAME} running idempotence test..." | ||
ansible-playbook -i ${INVENTORY} --limit ${BOX}, ${PLAYBOOK} ${EXTRA_ARGS} 2>&1 | tee ${LOGFILE} | \ | ||
ansible-playbook -i ${INVENTORY} --limit ${BOX}, ${EXTRA_ARGS} ${PLAYBOOK} 2>&1 | tee ${LOGFILE} | \ | ||
grep "${BOX}" | grep -q "${PASS_CRITERIA}" && \ | ||
echo -ne "[TEST] ${BOX} ${VIRTUALENV_NAME} idempotence : ${GREEN}PASS${NC}\n" || \ | ||
(echo -ne "[TEST] ${BOX} ${VIRTUALENV_NAME} idempotence : ${RED}FAILED${NC} ${PASS_CRITERIA}\n" && exit 1) | ||
(echo -ne "[TEST] ${BOX} ${VIRTUALENV_NAME} idempotence : ${RED}FAILED${NC} ${PASS_CRITERIA}\n" && cat ${LOGFILE} && exit 1) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,6 +14,11 @@ | |
# $ bash vagrant.sh --box precise64.vagrant.dev | ||
# | ||
# | ||
# changelog: | ||
# | ||
# v1.4 : 10 Jul 2015 | ||
# - remove environment variable ANSIBLE_ASK_SUDO_PASS | ||
# | ||
# author(s): | ||
# - Pedro Salgado <[email protected]> | ||
# | ||
|
@@ -23,9 +28,6 @@ DIR="$(dirname "$0")" | |
|
||
cd $DIR | ||
|
||
# force Ansible to ask for sudo password when running tests against Vagrant | ||
ANSIBLE_ASK_SUDO_PASS=True | ||
|
||
# the path to the Ansible inventory generated by Vagrant | ||
INVENTORY=${DIR}/.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters