@@ -3,65 +3,40 @@ services: docker
33
44env :
55 - distro : centos7
6- init : /usr/lib/systemd/systemd
7- run_opts : " --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
86 postgresql_bin_dir : /usr/bin
97 postgresql_data_dir : /var/lib/pgsql/data
108 - distro : centos6
11- init : /sbin/init
12- run_opts : " "
139 postgresql_bin_dir : /usr/bin
1410 postgresql_data_dir : /var/lib/pgsql/data
1511 - distro : ubuntu1604
16- init : /lib/systemd/systemd
17- run_opts : " --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
1812 postgresql_bin_dir : /usr/lib/postgresql/9.5/bin
1913 postgresql_data_dir : /var/lib/postgresql/9.5/main
2014 - distro : ubuntu1404
21- init : /sbin/init
22- run_opts : " "
2315 postgresql_bin_dir : /usr/lib/postgresql/9.3/bin
2416 postgresql_data_dir : /var/lib/postgresql/9.3/main
2517 - distro : debian8
26- init : /lib/systemd/systemd
27- run_opts : " --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
2818 postgresql_bin_dir : /usr/lib/postgresql/9.4/bin
2919 postgresql_data_dir : /var/lib/postgresql/9.4/main
3020
31- services :
32- - docker
33-
34- before_install :
35- # Pull container
36- - ' docker pull geerlingguy/docker-${distro}-ansible:latest'
37-
3821script :
39- - container_id=$(mktemp)
40- # Run container in detached state.
41- - ' docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro ${run_opts} geerlingguy/docker-${distro}-ansible:latest "${init}" > "${container_id}"'
42-
43- # Ansible syntax check.
44- - ' docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml --syntax-check'
22+ # Configure test script so we can run extra tests after playbook is run.
23+ - export container_id=$(date +%s)
24+ - export cleanup=false
4525
46- # Test role.
47- - ' docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml'
26+ # Download test shim.
27+ - wget -O ${PWD}/tests/test.sh https://gist.githubusercontent.com/geerlingguy/73ef1e5ee45d8694570f334be385e181/raw/
28+ - chmod +x ${PWD}/tests/test.sh
4829
49- # Test role idempotence.
50- - idempotence=$(mktemp)
51- - docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml | tee -a ${idempotence}
52- - >
53- tail ${idempotence}
54- | grep -q 'changed=0.*failed=0'
55- && (echo 'Idempotence test: pass' && exit 0)
56- || (echo 'Idempotence test: fail' && exit 1)
30+ # Run tests.
31+ - ${PWD}/tests/test.sh
5732
5833 # Check PostgreSQL status.
59- - ' docker exec -u postgres "$(cat $ {container_id})" ${postgresql_bin_dir}/pg_ctl -D ${postgresql_data_dir} status'
34+ - ' docker exec -u postgres $ {container_id} ${postgresql_bin_dir}/pg_ctl -D ${postgresql_data_dir} status'
6035
6136after_failure :
6237 # Check what happened on systemd systems.
63- - ' docker exec --tty "$(cat $ {container_id})" env TERM=xterm systemctl -l status postgresql.service'
64- - ' docker exec --tty "$(cat $ {container_id})" env TERM=xterm journalctl -xe --no-pager'
38+ - ' docker exec --tty $ {container_id} env TERM=xterm systemctl -l status postgresql.service'
39+ - ' docker exec --tty $ {container_id} env TERM=xterm journalctl -xe --no-pager'
6540
6641notifications :
6742 webhooks : https://galaxy.ansible.com/api/v1/notifications/
0 commit comments