-
Notifications
You must be signed in to change notification settings - Fork 1
/
test_deploy_openvpn.sh
executable file
·47 lines (39 loc) · 1.21 KB
/
test_deploy_openvpn.sh
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
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
source $DIR/base.sh
# create sandbox
vagrant up
# cleanup
if [[ -e $DIR/.vpnkeys/test ]]; then
rm -rf $DIR/.vpnkeys/test
fi
# run playbook in vagrant sandbox
ansible-playbook -i environments/test/inventory playbooks/openvpn-server.yml
# TODO FIXME openvpn service not starting until reboot
ssh -o StrictHostKeyChecking=no vagrant@$vmbox1 "bash -c 'sleep 2; sudo reboot' &"
sleep 20
# expect vpn keys downloaded
# see openvpn_clients_active in environments/test/group_vars/openvpn.yaml
for vpnusername in vpnhost_static vpnuser_laptop
do
vpn_key_zip=$DIR/../.vpnkeys/test/${vpnusername}.zip
if [[ ! -f $vpn_key_zip ]]; then
echo "FAILED: not found $vpn_key_zip"
exit 1
fi
done
# deploy vpn keys
ansible-playbook -i environments/test/inventory playbooks/openvpn-client.yml
# check
# wait network bootstrap
sleep 3
ssh -o StrictHostKeyChecking=no vagrant@$vmbox2 "ping -c 3 -w 3 10.3.0.1"
if [ $? -ne 0 ]; then
echo 'FAILED ping vpnhost_static -> vpnserver'
exit 1
fi
ssh -o StrictHostKeyChecking=no vagrant@$vmbox1 "ping -c 3 -w 3 10.3.0.2"
if [ $? -ne 0 ]; then
echo 'FAILED ping vpnserver -> vpnhost_static'
exit 1
fi