This repository has been archived by the owner on Jan 26, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.travis.yml
107 lines (96 loc) · 3.22 KB
/
.travis.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
---
sudo: required
dist: trusty
language: python
python:
- "2.7"
services:
- docker
env:
- distro: debian9
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
ansible_version: latest
- distro: debian9
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
ansible_version: 2.4.0.0
- distro: debian9
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
ansible_version: 2.3.0.0
- distro: debian9
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
ansible_version: 2.2.0.0
- distro: debian9
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
ansible_version: 2.1.0.0
- distro: debian9
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
ansible_version: 2.0.0.0
- distro: debian8
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
ansible_version: latest
- distro: ubuntu1604
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
ansible_version: latest
- distro: ubuntu1404
init: /sbin/init
run_opts: ""
ansible_version: latest
before_install:
- 'docker pull geerlingguy/docker-${distro}-ansible:latest'
install: true
before_script:
- container_id=$(mktemp)
- >
docker run --detach --volume="${PWD}":/etc/ansible/roles/role_under_test:ro
${run_opts} geerlingguy/docker-${distro}-ansible:latest
"${init}" > "${container_id}"
- >
if [[ "$ansible_version" != "latest" ]];
then docker exec "$(cat ${container_id})" bash -c "
pip install ansible==$ansible_version";
fi
- >
if [[ "$ansible_version" == "latest" && "$distro" == "debian9" ]];
then docker exec "$(cat ${container_id})" bash -c "
pip install ansible-lint &&
pip install yamllint";
fi
script:
# Check the role/playbook's syntax.
- >
docker exec "$(cat ${container_id})"
ansible-playbook --syntax-check
/etc/ansible/roles/role_under_test/tests/test.yml
# Run the role/playbook with ansible-playbook.
- >
docker exec "$(cat ${container_id})"
ansible-playbook -vvvv /etc/ansible/roles/role_under_test/tests/test.yml
# Run the role/playbook again, checking to make sure it's idempotent.
- >
docker exec "$(cat ${container_id})" bash -c "
ansible-playbook /etc/ansible/roles/role_under_test/tests/test.yml
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)"
- >
if [[ "$ansible_version" == "latest" && "$distro" == "debian9" ]];
then docker exec "$(cat ${container_id})" bash -c "
ansible-lint /etc/ansible/roles/role_under_test/tests/test.yml";
fi
- >
if [[ "$ansible_version" == "latest" && "$distro" == "debian9" ]];
then docker exec "$(cat ${container_id})" bash -c "
yamllint /etc/ansible/roles/role_under_test/";
fi
after_script:
- docker rm -f "$(cat ${container_id})"
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/