Skip to content

Commit f85d199

Browse files
committed
- v3.7.0 : 10 Jul 2015
- 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
1 parent 6d1beec commit f85d199

File tree

11 files changed

+97
-35
lines changed

11 files changed

+97
-35
lines changed

README.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,30 @@
1010

1111
An [Ansible](http://www.ansible.com) role to setup the [webupd8](http://www.webupd8.org/) launchpad apt repository.
1212

13+
## Tests
14+
15+
| Family | Distribution | Version | Test Status |
16+
|:-:|:-:|:-:|:-:|
17+
| Debian | Debian | Jessie | [![x86](http://img.shields.io/badge/x86-n/a-cccccc.svg?style=flat)](#) [![x86_64](http://img.shields.io/badge/x86_64-n/a-cccccc.svg?style=flat)](#) |
18+
| Debian | Debian | Wheezy | [![x86](http://img.shields.io/badge/x86-n/a-cccccc.svg?style=flat)](#) [![x86_64](http://img.shields.io/badge/x86_64-n/a-cccccc.svg?style=flat)](#) |
19+
| Debian | Ubuntu | Precise | [![x86](http://img.shields.io/badge/x86-n/a-cccccc.svg?style=flat)](#) [![x86_64](http://img.shields.io/badge/x86_64-passed-006400.svg?style=flat)](#) |
20+
| Debian | Ubuntu | Trusty | [![x86](http://img.shields.io/badge/x86-n/a-cccccc.svg?style=flat)](#) [![x86_64](http://img.shields.io/badge/x86_64-n/a-cccccc.svg?style=flat)](#) |
21+
| Debian | Ubuntu | Vivid | [![x86](http://img.shields.io/badge/x86-n/a-cccccc.svg?style=flat)](#) [![x86_64](http://img.shields.io/badge/x86_64-n/a-cccccc.svg?style=flat)](#) |
22+
| RedHat | CentOS | 6.4 | [![x86](http://img.shields.io/badge/x86-n/a-cccccc.svg?style=flat)](#) [![x86_64](http://img.shields.io/badge/x86_64-n/a-cccccc.svg?style=flat)](#) |
23+
| RedHat | CentOS | 6.6 | [![x86](http://img.shields.io/badge/x86-n/a-cccccc.svg?style=flat)](#) [![x86_64](http://img.shields.io/badge/x86_64-n/a-cccccc.svg?style=flat)](#) |
24+
| RedHat | Centos | 7 | [![x86](http://img.shields.io/badge/x86-n/a-cccccc.svg?style=flat)](#) [![x86_64](http://img.shields.io/badge/x86_64-n/a-cccccc.svg?style=flat)](#) |
25+
| RedHat | Fedora | 20 | [![x86](http://img.shields.io/badge/x86-n/a-cccccc.svg?style=flat)](#) [![x86_64](http://img.shields.io/badge/x86_64-n/a-cccccc.svg?style=flat)](#) |
26+
| RedHat | Fedora | 21 | [![x86](http://img.shields.io/badge/x86-n/a-cccccc.svg?style=flat)](#) [![x86_64](http://img.shields.io/badge/x86_64-n/a-cccccc.svg?style=flat)](#) |
27+
1328
## Requirements
1429

1530
- ansible >= 1.8.4
1631

32+
# Facts
33+
| variable | description |
34+
|:-:|:--|
35+
| launchpad_ppa_webupd8_os_supported | fact set by this role to determine if the host OS is supported. |
36+
1737
## Role Variables
1838

1939
| variable | description |
@@ -36,6 +56,14 @@ is always nice for users too:
3656

3757
## Changelog
3858

59+
- v3.7.0 : 10 Jul 2015
60+
- don't update the apt repositories cache when you're just adding new repos since it will get updated in the end
61+
- minor version number will now match primogen major version number
62+
- merge with ansiblebit.primogen v7
63+
- upgrade tests to use ansible v1.9.2 instead of v1.9.1
64+
- pass ANSIBLE_ASK_SUDO_PASS environment variable to the tox test environment
65+
- improved idempotence test
66+
- renamed fact os_supported to launchpad_ppa_webupd8_os_supported
3967
- v3.0.0 : 7 May 2015
4068
- synchronized major version with primogen for easier reference
4169
- v1.1.2 : 5 May 2015
@@ -55,6 +83,7 @@ is always nice for users too:
5583

5684
## Links
5785

86+
- [WebUpd8 team : Oracle Java (JDK) 7 / 8 / 9 Installer PPA](https://launchpad.net/~webupd8team/+archive/ubuntu/java)
5887

5988
## License
6089

@@ -63,7 +92,3 @@ BSD
6392
## Author Information
6493

6594
- [steenzout](http://github.com/steenzout)
66-
67-
## Links
68-
69-
- [WebUpd8 team : Oracle Java (JDK) 7 / 8 / 9 Installer PPA](https://launchpad.net/~webupd8team/+archive/ubuntu/java)

tasks/main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
- name: check if operating system is suported
1818
fail:
1919
msg: "The operating system ({{ ansible_os_family }}) of the target machine ({{ inventory_hostname }}) is not currently supported."
20-
when: os_supported is not defined
20+
when: launchpad_ppa_webupd8_os_supported is not defined
2121

2222

2323
## generic tasks

tasks/os_distribution/debian.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
- name: debian is supported
55
set_fact:
6-
os_supported: yes
6+
launchpad_ppa_webupd8_os_supported: yes
77

88
- name: ensure the webupd8 launchpad apt repository key is present
99
apt_key:
@@ -15,13 +15,13 @@
1515
- name: ensure the webupd8 launchpad apt repository is present
1616
apt_repository:
1717
repo="deb http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main"
18-
update_cache=yes
18+
update_cache=no
1919
state=present
2020
sudo: yes
2121

22-
- name: ensure the webupd8 launchpad apt repository is present
22+
- name: ensure the webupd8 launchpad source apt repository is present
2323
apt_repository:
2424
repo="deb-src http://ppa.launchpad.net/webupd8team/java/ubuntu trusty main"
25-
update_cache=yes
25+
update_cache=no
2626
state=present
2727
sudo: yes

tasks/os_distribution/ubuntu.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33

44
- name: ubuntu is supported
55
set_fact:
6-
os_supported: yes
6+
launchpad_ppa_webupd8_os_supported: yes
77

88
- name: ensure the webupd8 launchpad apt repository is present
99
apt_repository:
1010
repo=ppa:webupd8team/java
11-
update_cache=yes
11+
update_cache=no
1212
state=present
1313
sudo: yes

tests/Vagrantfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Vagrant.configure('2') do |config|
3838
host.vm.provision 'ansible' do |ansible|
3939
ansible.playbook = PLAYBOOK
4040
ansible.verbose = 'v'
41+
ansible.skip_tags = 'test'
4142
end
4243
end
4344
end

tests/defaults/main.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
---
2+
# file: primogen/tests/tasks
Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,29 @@
11
import sys
22
import os
33

4+
VAR_IDEMPOTENCE = u'idempotence'
5+
46

57
class CallbackModule(object):
68
"""
7-
This callback module tells you how long your plays ran for.
9+
This callback module performs the idempotence test whenever the 'idempotence' variable is set to True.
810
"""
911

1012
def __init__(self):
1113
pass
1214

1315
def playbook_on_stats(self, stats):
1416

15-
if u'idempotence' in self.playbook.extra_vars.keys():
17+
if (u'%s' % VAR_IDEMPOTENCE) in self.playbook.extra_vars.keys() and self.playbook.extra_vars[VAR_IDEMPOTENCE]:
18+
19+
if len(stats.dark) > 0:
20+
print ('idempotence test failed! unreachable=%s > 0') % stats.dark
21+
sys.exit(os.EX_SOFTWARE)
1622

17-
if (len(stats.changed) > 0):
18-
print 'idempotence test failed! changed=%s > 0' % stats.changed
23+
if len(stats.changed) > 0:
24+
print ('idempotence test failed! changed=%s > 0') % stats.changed
1925
sys.exit(os.EX_SOFTWARE)
2026

21-
if (len(stats.failures) > 0):
22-
print 'idempotence test failed! failures=%s > 0' % stats.failures
27+
if len(stats.failures) > 0:
28+
print ('idempotence test failed! failures=%s > 0') % stats.failures
2329
sys.exit(os.EX_SOFTWARE)

tests/test.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,18 @@
11
---
2-
# file: launchpad-ppa-webupd8/tests/vagrant.yml
2+
# file: launchpad-ppa-webupd8/tests/test.yml
33

4-
- name: tests play
4+
- name: provisioning play
55
hosts: all
66
gather_facts: yes
77

88
roles:
99
- launchpad-ppa-webupd8
10-
- tests
10+
11+
- name: tests play
12+
hosts: all
13+
gather_facts: yes
14+
tags: test
15+
16+
roles:
17+
- { role: tests,
18+
when: idempotence is defined and idempotence }

tests/test_idempotence.sh

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44
# Bash script to run idempotence tests.
55
#
6-
# version: 1.2
6+
# version: 1.4
77
#
88
# usage:
99
#
@@ -12,6 +12,7 @@
1212
# options:
1313
#
1414
# --box The name of the Vagrant box or host name
15+
# --env The name of the test environment
1516
# --inventory The Ansible inventory in the form of a file or string "host,"
1617
# --playbook The path to the Ansible test playbook
1718
#
@@ -22,10 +23,17 @@
2223
#
2324
# # on a Vagrant box
2425
# bash test_idempotence.sh \
25-
# --box precise64
26+
# --box precise64.vagrant.dev
2627
# --inventory .vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory
2728
#
2829
#
30+
# changelog:
31+
#
32+
# v1.4 : 10 Jul 2015
33+
# - added extra variables to force running idempotence tests on vagrant
34+
# v1.2
35+
# - added env option
36+
#
2937
# author(s):
3038
# - Pedro Salgado <[email protected]>
3139
#
@@ -56,6 +64,11 @@ key="$1"
5664
BOX="$2"
5765
shift;;
5866

67+
--env)
68+
# the test environment
69+
ENV="$2"
70+
shift;;
71+
5972
--inventory)
6073
# the Ansible inventory in the form of a file or string "host,"
6174
INVENTORY="$2"
@@ -85,13 +98,13 @@ LOGFILE="log/${BOX}_${VIRTUALENV_NAME}.log"
8598

8699
EXTRA_ARGS=''
87100
if [ $BOX == "localhost" ]; then
88-
EXTRA_ARGS="--connection=local --extra-vars idempotence=yes"
101+
EXTRA_ARGS="--connection=local --extra-vars idempotence=yes --extra-vars env=${ENV}"
89102
else
90-
EXTRA_ARGS="--u vagrant"
103+
EXTRA_ARGS="--u vagrant --extra-vars idempotence=yes --extra-vars env=vagrant"
91104
fi
92105

93106
echo "[INFO] ${BOX} ${VIRTUALENV_NAME} running idempotence test..."
94-
ansible-playbook -i ${INVENTORY} --limit ${BOX}, ${PLAYBOOK} ${EXTRA_ARGS} 2>&1 | tee ${LOGFILE} | \
107+
ansible-playbook -i ${INVENTORY} --limit ${BOX}, ${EXTRA_ARGS} ${PLAYBOOK} 2>&1 | tee ${LOGFILE} | \
95108
grep "${BOX}" | grep -q "${PASS_CRITERIA}" && \
96109
echo -ne "[TEST] ${BOX} ${VIRTUALENV_NAME} idempotence : ${GREEN}PASS${NC}\n" || \
97-
(echo -ne "[TEST] ${BOX} ${VIRTUALENV_NAME} idempotence : ${RED}FAILED${NC} ${PASS_CRITERIA}\n" && exit 1)
110+
(echo -ne "[TEST] ${BOX} ${VIRTUALENV_NAME} idempotence : ${RED}FAILED${NC} ${PASS_CRITERIA}\n" && cat ${LOGFILE} && exit 1)

tests/vagrant.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
# $ bash vagrant.sh --box precise64.vagrant.dev
1515
#
1616
#
17+
# changelog:
18+
#
19+
# v1.4 : 10 Jul 2015
20+
# - remove environment variable ANSIBLE_ASK_SUDO_PASS
21+
#
1722
# author(s):
1823
# - Pedro Salgado <[email protected]>
1924
#
@@ -23,9 +28,6 @@ DIR="$(dirname "$0")"
2328

2429
cd $DIR
2530

26-
# force Ansible to ask for sudo password when running tests against Vagrant
27-
ANSIBLE_ASK_SUDO_PASS=True
28-
2931
# the path to the Ansible inventory generated by Vagrant
3032
INVENTORY=${DIR}/.vagrant/provisioners/ansible/inventory/vagrant_ansible_inventory
3133

0 commit comments

Comments
 (0)