-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy path.travis.yml
77 lines (66 loc) · 2.95 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
language: python
services: docker
env:
- distribution: Ubuntu
distribution_version: bionic
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distribution: Ubuntu
distribution_version: xenial
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distribution: EL
distribution_version: "7"
init: /usr/lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distribution: EL
distribution_version: "6"
init: /sbin/init
run_opts: ""
- distribution: Debian
distribution_version: buster
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distribution: Debian
distribution_version: stretch
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
- distribution: Debian
distribution_version: jessie
init: /lib/systemd/systemd
run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
# You Can Comment Out Any Operating Systems
# - distribution: Fedora
# distribution_version: "24"
# init: /usr/lib/systemd/systemd
# run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
# - distribution: Fedora
# distribution_version: "23"
# init: /usr/lib/systemd/systemd
# run_opts: "--privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup:ro"
before_install:
# Pull container from Docker Hub.
- 'docker pull ansiblecheck/ansiblecheck:${distribution,,}-${distribution_version}'
script:
- container_id=$(mktemp)
# Start The Built Container In The Background
- 'docker run --detach --volume="${PWD}":/etc/ansible/playbooks:ro ${run_opts} ansiblecheck/ansiblecheck:"${distribution,,}"-"${distribution_version}" "${init}" > "${container_id}"'
# Install requirements, Uncomment if needed
# - 'docker exec "$(cat ${container_id})" env ANSIBLE_FORCE_COLOR=true ansible-galaxy install -v -r /etc/ansible/roles/role_under_test/requirements.yml'
# Ansible syntax check.
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-playbook /etc/ansible/playbooks/tests/test.yml --syntax-check'
# Run linters
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm ansible-lint /etc/ansible/roles/role_under_test/tasks/main.yml'
- 'docker exec --tty "$(cat ${container_id})" env TERM=xterm yamllint /etc/ansible/roles/role_under_test/'
# Test role.
- 'docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/playbooks/tests/test.yml'
# Test Idempotence
- idempotence=$(mktemp)
- docker exec "$(cat ${container_id})" ansible-playbook /etc/ansible/playbooks/tests/test.yml | tee -a ${idempotence}
- >
tail ${idempotence}
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
notifications:
webhooks: https://galaxy.ansible.com/api/v1/notifications/