-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (56 loc) · 2.09 KB
/
ansible-install.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
name: Ansible Installation
on:
push:
branches:
- main
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Check out the codebase.
uses: actions/checkout@v2
# Taken here: https://github.com/dbritto-dev/openvpn3-action/blob/main/action.yml#L25
- name: Install OpenVPN
run: |
export DISTRO=$(lsb_release --codename | cut -f2)
sudo apt-get install -y apt-transport-https
sudo wget https://swupdate.openvpn.net/repos/openvpn-repo-pkg-key.pub
sudo apt-key add openvpn-repo-pkg-key.pub
sudo wget -O /etc/apt/sources.list.d/openvpn3.list https://swupdate.openvpn.net/community/openvpn3/repos/openvpn3-$DISTRO.list
sudo apt-get update -y && sudo apt-get install -y openvpn3
- name: Setup VPN config
run: |
echo -n "${{ secrets.VPN_CONFIG }}" | base64 -d > config.ovpn
- name: Connect VPN
run: sudo openvpn3 session-start --dco true --config config.ovpn --background
- name: Wait for a VPN connection
timeout-minutes: 1
run: until ping -c1 192.168.0.2; do sleep 2; done
- name: Ping local servers (test)
run: |
ping 192.168.0.2 -c5
ping 192.168.0.3 -c5
ping 192.168.0.4 -c5
ping 192.168.0.5 -c5
ping 192.168.0.6 -c5
ping 192.168.0.7 -c5
ping 192.168.0.8 -c5
ping 192.168.0.9 -c5
ping 192.168.0.10 -c5
- name: Run playbook
uses: dawidd6/action-ansible-playbook@v2
with:
# Required, playbook filepath
playbook: install.yml
# Directory where playbooks live
directory: playbooks/
# SSH private key
key: ${{ secrets.SSH_PRIVATE_KEY }}
# Additional flags to pass to ansible-playbook
options: |
--inventory inventory/cluster/hosts.ini
--extra-vars ansible_sudo_pass=${{ secrets.PASSWORD }}
--verbose
- name: Kill VPN connection
if: always()
run: sudo openvpn3 session-manage --config config.ovpn --disconnect