forked from BastiPaeltz/ansible-openvpn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.travis.yml
92 lines (75 loc) · 3.11 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
---
language: python
cache: pip
sudo: required
env:
global:
- ANSIBLE_HOST_KEY_CHECKING=false
matrix:
- distribution: centos
version: 7
init: /usr/lib/systemd/systemd
run_opts: "'--detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup'"
ssh: sshd
docker_concurrent_containers: 1
- distribution: ubuntu
version: 16.04
init: /sbin/init
run_opts: "'--detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup'"
ssh: ssh
docker_concurrent_containers: 1
- distribution: debian
version: 8.7
init: /bin/systemd
run_opts: "'--detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup'"
ssh: ssh
docker_concurrent_containers: 1
- distribution: ubuntu
version: 16.04
init: /sbin/init
run_opts: "'--detach --privileged --volume=/sys/fs/cgroup:/sys/fs/cgroup'"
ssh: ssh
docker_concurrent_containers: 2
services:
- docker
before_install:
# Pull container
- sudo docker pull ${distribution}:${version}
- ssh-keygen -t rsa -f /home/travis/.ssh/id_rsa -q -N ""
- cp /home/travis/.ssh/id_rsa.pub test/id_rsa.pub
# Build container
- sudo docker build --rm=true --file=test/Dockerfile.${distribution}-${version} --tag=${distribution}-${version}:ansible .
install:
- sudo -H pip install ansible ansible-lint
- sudo apt-get -y install openssl
script:
# Ansible syntax check.
- ansible-lint playbooks/install.yml
- ansible-lint playbooks/sync_clients.yml
- ansible-lint playbooks/add_clients.yml
- ansible-lint playbooks/revoke_clients.yml
- sudo test/docker-setup.sh
# Create ansible vars directories
- mkdir test/host_vars test/group_vars
# Copy default all.yml in group_vars
- cp inventories/sample/group_vars/all.yml test/group_vars/all.yml
# Test role
- ansible-playbook -i test/docker-inventory -e "@test/ansible-vars/01_install_${distribution}.yml" --diff playbooks/install.yml
# Test role idempotence
- >
ansible-playbook -i test/docker-inventory -e "@test/ansible-vars/01_install_${distribution}.yml" playbooks/install.yml
| grep -q 'changed=0.*failed=0'
&& (echo 'Idempotence test: pass' && exit 0)
|| (echo 'Idempotence test: fail' && exit 1)
# Check if ca_password(s) got written to host_vars
- if [ $(ls -l test/host_vars/*.yml | wc -l) -ne $docker_concurrent_containers ];then echo "Not all ca passwords written to host_vars" && exit 1;fi
# Test adding clients
- ansible-playbook -i test/docker-inventory -e "@test/ansible-vars/02_add_clients.yml" playbooks/add_clients.yml
# Test revoking a client
- ansible-playbook -i test/docker-inventory -e "@test/ansible-vars/03_revoke_clients.yml" playbooks/revoke_clients.yml
# Test syncing clients
- ansible-playbook -i test/docker-inventory -e "@test/ansible-vars/04_sync_clients.yml" playbooks/sync_clients.yml
# Test adding a client using a CSR
- openssl genrsa -out ~/test.key 2048
- openssl req -new -sha256 -key ~/test.key -out ~/test.csr -batch -subj "/[email protected]"
- ansible-playbook -i test/docker-inventory -e "csr_path=~/test.csr [email protected]" playbooks/add_clients.yml