-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
145 lines (122 loc) · 3.71 KB
/
.gitlab-ci.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
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
image: docker:latest
cache:
untracked: true
paths:
- .cache/
stages:
- lint
- test
variables:
XDG_CACHE_HOME: "$CI_PROJECT_DIR/.cache"
_ANSIBLE_CONNECTION: local
_ANSIBLE_PLAYBOOK: tests/docker_playbook.yml
.local_ssh: &local_ssh
variables:
_ANSIBLE_CONNECTION: ssh
_ANSIBLE_PLAYBOOK: tests/test.yml
_DOCKER_NAME: alpine
_DOCKER_IMAGE: alpine
.docker_centos7: &docker_centos7
variables:
_DOCKER_NAME: centos7
_DOCKER_IMAGE: ansiblecheck/ansiblecheck:centos-7
_DOCKER_IMAGE_INIT: /usr/lib/systemd/systemd
.docker_centos6: &docker_centos6
variables:
_DOCKER_NAME: centos6
_DOCKER_IMAGE: ansiblecheck/ansiblecheck:centos-6
_DOCKER_IMAGE_INIT: /sbin/init
.docker_debian9: &docker_debian9
variables:
_DOCKER_NAME: debian9
_DOCKER_IMAGE: ansiblecheck/ansiblecheck:debian-9
_DOCKER_IMAGE_INIT: /lib/systemd/systemd
.docker_debian8: &docker_debian8
variables:
_DOCKER_NAME: debian8
_DOCKER_IMAGE: ansiblecheck/ansiblecheck:debian-8
_DOCKER_IMAGE_INIT: /lib/systemd/systemd
.docker_ubuntu16: &docker_ubuntu16
variables:
_DOCKER_NAME: ubuntu16
_DOCKER_IMAGE: ansiblecheck/ansiblecheck:ubuntu-16.04
_DOCKER_IMAGE_INIT: /lib/systemd/systemd
.docker_ubuntu14: &docker_ubuntu14
variables:
_DOCKER_NAME: ubuntu14
_DOCKER_IMAGE: ansiblecheck/ansiblecheck:ubuntu-14.04
_DOCKER_IMAGE_INIT: /sbin/init
.debug_after: &debug_after
after_script:
- docker ps -a
- docker images -a
when: always
.tags_list: &tags_list
tags:
- docker
- dind
- privileged
.prepare_env: &prepare_env
before_script:
- mkdir -p "$XDG_CACHE_HOME/apk_cache" && ln -sf "$XDG_CACHE_HOME/apk_cache" /etc/apk/cache
- apk add --update sudo git libffi libffi-dev openssl openssl-dev ca-certificates python python-dev py-pip build-base
- pip install --upgrade ansible ansible-lint
- printf '[defaults]\nroles_path=../\nhost_key_checking = False\nretry_files_enabled = False\n\n[ssh_connection]\npipelining = True\n' > ansible.cfg
- printf 'localhost' > inventory
- docker info
- ansible --version
- test -f requirements.yml && ansible-galaxy install -r requirements.yml || true
- docker pull ${_DOCKER_IMAGE} || true
.ansible_playbook: &ansible_playbook
script:
- >
ansible-playbook -i inventory ${_ANSIBLE_PLAYBOOK}
--connection=${_ANSIBLE_CONNECTION}
--extra-vars "DOCKER_NAME=${_DOCKER_NAME} DOCKER_IMAGE=${_DOCKER_IMAGE} DOCKER_IMAGE_INIT=${_DOCKER_IMAGE_INIT}"
--skip-tags "destroy"
-v
- >
ANSIBLE_LOG_PATH=/tmp/idempotence.log
ansible-playbook -i inventory ${_ANSIBLE_PLAYBOOK}
--connection=${_ANSIBLE_CONNECTION}
--extra-vars "DOCKER_NAME=${_DOCKER_NAME} DOCKER_IMAGE=${_DOCKER_IMAGE} DOCKER_IMAGE_INIT=${_DOCKER_IMAGE_INIT}"
- >
awk '/PLAY RECAP/,/EOF/
{if (NF && $6 !~ "PLAY" && $9$10$11 !~ "changed=0unreachable=0failed=0" ) status=1 } END
{ print (status)? "Idempotence test: FAIL" : "Idempotence test: PASS"; exit status }'
/tmp/idempotence.log
.prepare: &prepare
<<: *prepare_env
<<: *tags_list
.run_playbook: &run_playbook
<<: *prepare
<<: *ansible_playbook
<<: *debug_after
stage: test
lint:
<<: *prepare
stage: lint
script:
- ansible-lint -v ${_ANSIBLE_PLAYBOOK}
docker:centos:7:
<<: *run_playbook
<<: *docker_centos7
docker:centos:6:
<<: *run_playbook
<<: *docker_centos6
allow_failure: true
docker:debian:9:
<<: *run_playbook
<<: *docker_debian9
docker:debian:8:
<<: *run_playbook
<<: *docker_debian8
allow_failure: true
docker:ubuntu:16:
<<: *run_playbook
<<: *docker_ubuntu16
allow_failure: true
docker:ubuntu:14:
<<: *run_playbook
<<: *docker_ubuntu14
allow_failure: true