mirror of
https://github.com/iiab/iiab.git
synced 2025-02-15 04:32:11 +00:00
Merge branch 'master' of https://github.com/iiab/iiab
This commit is contained in:
commit
e9322459d4
20 changed files with 112 additions and 85 deletions
|
@ -1,7 +1,9 @@
|
||||||
openvpn_install: True
|
openvpn_install: True
|
||||||
openvpn_enable: False
|
openvpn_enable: False
|
||||||
|
|
||||||
openvpn_handle: UNNAMED
|
# For /etc/iiab/openvpn_handle
|
||||||
|
openvpn_handle: ""
|
||||||
|
|
||||||
# cron seems necessary on CentOS:
|
# cron seems necessary on CentOS:
|
||||||
openvpn_cron_enabled: False
|
openvpn_cron_enabled: False
|
||||||
|
|
||||||
|
|
|
@ -24,18 +24,20 @@
|
||||||
group: root
|
group: root
|
||||||
mode: 0755
|
mode: 0755
|
||||||
|
|
||||||
- name: Create a folder for iiab executable not on path
|
# Comment out in future? Might still be relevant for CentOS but unused for ~2 years as of August 2018:
|
||||||
|
- name: Create folder /usr/lib/iiab (not on path) for iiab executable up_wan
|
||||||
file:
|
file:
|
||||||
path: /usr/lib/iiab
|
path: /usr/lib/iiab
|
||||||
state: directory
|
state: directory
|
||||||
|
|
||||||
- name: Configure OpenVPN
|
- name: Configure OpenVPN (BACKS UP FILES IF CHANGED)
|
||||||
template:
|
template:
|
||||||
src: "{{ item.src }}"
|
src: "{{ item.src }}"
|
||||||
dest: "{{ item.dest }}"
|
dest: "{{ item.dest }}"
|
||||||
owner: root
|
owner: root
|
||||||
group: root
|
group: root
|
||||||
mode: "{{ item.mode }}"
|
mode: "{{ item.mode }}"
|
||||||
|
backup: yes
|
||||||
with_items:
|
with_items:
|
||||||
- { src: 'ca.crt', dest: '/etc/openvpn/keys/ca.crt', mode: '0644' }
|
- { src: 'ca.crt', dest: '/etc/openvpn/keys/ca.crt', mode: '0644' }
|
||||||
- { src: 'client1.crt', dest: '/etc/openvpn/keys/client1.crt', mode: '0644' }
|
- { src: 'client1.crt', dest: '/etc/openvpn/keys/client1.crt', mode: '0644' }
|
||||||
|
@ -44,39 +46,52 @@
|
||||||
- { src: 'announcer.j2', dest: '/etc/openvpn/scripts/announcer', mode: '0755' }
|
- { src: 'announcer.j2', dest: '/etc/openvpn/scripts/announcer', mode: '0755' }
|
||||||
- { src: 'silence', dest: '/etc/openvpn/scripts/silence', mode: '0755' }
|
- { src: 'silence', dest: '/etc/openvpn/scripts/silence', mode: '0755' }
|
||||||
- { src: 'xscenet.conf.j2', dest: '/etc/openvpn/xscenet.conf', mode: '0644' }
|
- { src: 'xscenet.conf.j2', dest: '/etc/openvpn/xscenet.conf', mode: '0644' }
|
||||||
- { src: 'iiab-vpn.conf.in', dest: '/etc/openvpn/iiab-vpn.conf.in', mode: '0644' }
|
- { src: 'iiab-remote-on.j2', dest: '/usr/bin/iiab-remote-on', mode: '0755' }
|
||||||
- { src: 'iiab-vpn.j2', dest: '/usr/bin/iiab-vpn', mode: '0755' }
|
|
||||||
- { src: 'iiab-handle.j2', dest: '/usr/bin/iiab-handle', mode: '0755' }
|
|
||||||
- { src: 'up_wan', dest: '/usr/lib/iiab/up_wan', mode: '0755' }
|
|
||||||
- { src: 'start.j2', dest: '/usr/lib/iiab/start', mode: '0755' }
|
|
||||||
- { src: 'iiab-remote-on', dest: '/usr/bin/iiab-remote-on', mode: '0755' }
|
|
||||||
- { src: 'iiab-remote-off', dest: '/usr/bin/iiab-remote-off', mode: '0755' }
|
- { src: 'iiab-remote-off', dest: '/usr/bin/iiab-remote-off', mode: '0755' }
|
||||||
|
- { src: 'openvpn_handle.j2', dest: '/etc/iiab/openvpn_handle', mode: '0644' }
|
||||||
|
# Comment out in future? Not recommended as of August 2018:
|
||||||
|
- { src: 'iiab-handle.j2', dest: '/usr/bin/iiab-handle', mode: '0755' }
|
||||||
|
# Comment out in future? Might still be relevant for CentOS but unused for ~2 years as of August 2018:
|
||||||
|
- { src: 'up_wan', dest: '/usr/lib/iiab/up_wan', mode: '0755' }
|
||||||
|
# Unused for ~2 years as of August 2018:
|
||||||
|
#- { src: 'start.j2', dest: '/usr/lib/iiab/start', mode: '0755' }
|
||||||
|
# Buggy & rarely used as of August 2018:
|
||||||
|
#- { src: 'iiab-vpn.conf.in', dest: '/etc/openvpn/iiab-vpn.conf.in', mode: '0644' }
|
||||||
|
# Buggy & rarely used as of August 2018:
|
||||||
|
#- { src: 'iiab-vpn.j2', dest: '/usr/bin/iiab-vpn', mode: '0755' }
|
||||||
|
|
||||||
- name: Save openvpn_handle variable into /etc/iiab/openvpn_handle (BACKS UP FILE IF CHANGED)
|
#- name: Save openvpn_handle variable into /etc/iiab/openvpn_handle (BACKS UP FILE IF CHANGED)
|
||||||
template:
|
# template:
|
||||||
src: openvpn_handle.j2
|
# src: openvpn_handle.j2
|
||||||
dest: /etc/iiab/openvpn_handle
|
# dest: /etc/iiab/openvpn_handle
|
||||||
owner: root
|
# owner: root
|
||||||
group: root
|
# group: root
|
||||||
mode: 0644
|
# mode: 0644
|
||||||
backup: yes
|
# backup: yes
|
||||||
|
# when: openvpn_handle is defined
|
||||||
|
|
||||||
- name: Put up_wan in place (debuntu)
|
# Comment out in future? up_wan was being installed twice (also above) and
|
||||||
template:
|
# was unused for ~2 years as of August 2018: (see 15-openvpn below)
|
||||||
src: up_wan
|
#- name: Put up_wan in place (debuntu)
|
||||||
dest: /usr/lib/iiab/up_wan
|
# template:
|
||||||
when: is_debuntu
|
# src: up_wan
|
||||||
|
# dest: /usr/lib/iiab/up_wan
|
||||||
|
# when: is_debuntu
|
||||||
|
|
||||||
|
# Comment out in future? Contained serious bug (15-openvpn called
|
||||||
|
# up-wan instead of up_wan in /usr/lib/iiab/) so evidently unused
|
||||||
|
# for ~2 years, as of Aug 2018:
|
||||||
- name: Put dispatcher up for NM (not debuntu)
|
- name: Put dispatcher up for NM (not debuntu)
|
||||||
template:
|
template:
|
||||||
src: 15-openvpn
|
src: 15-openvpn
|
||||||
dest: /etc/NetworkManager/dispatcher.d/
|
dest: /etc/NetworkManager/dispatcher.d/
|
||||||
when: not is_debuntu
|
when: not is_debuntu
|
||||||
|
|
||||||
- name: Check for manually configured OpenVPN tunnel
|
# Was buggy & unused for ~2 years as of August 2018:
|
||||||
stat:
|
#- name: Check for manually configured OpenVPN tunnel
|
||||||
path: /etc/openvpn/iiab-vpn.conf
|
# stat:
|
||||||
register: stat
|
# path: /etc/openvpn/iiab-vpn.conf
|
||||||
|
# register: stat
|
||||||
|
|
||||||
|
|
||||||
# FIXED SOMETIME PRIOR TO AUGUST 2018: earlier versions of Ansible had not
|
# FIXED SOMETIME PRIOR TO AUGUST 2018: earlier versions of Ansible had not
|
||||||
|
@ -108,13 +123,13 @@
|
||||||
name: openvpn@xscenet.service
|
name: openvpn@xscenet.service
|
||||||
enabled: yes
|
enabled: yes
|
||||||
state: restarted
|
state: restarted
|
||||||
when: openvpn_enabled and not stat.exists is defined
|
when: openvpn_enabled
|
||||||
|
|
||||||
- name: Enable hourly cron job for OpenVPN
|
- name: Enable hourly cron job for OpenVPN
|
||||||
lineinfile:
|
lineinfile:
|
||||||
path: /etc/crontab
|
path: /etc/crontab
|
||||||
line: "25 * * * * root (/usr/bin/systemctl start openvpn@xscenet.service) > /dev/null"
|
line: "25 * * * * root (/usr/bin/systemctl start openvpn@xscenet.service) > /dev/null"
|
||||||
when: openvpn_enabled and openvpn_cron_enabled and not stat.exists is defined
|
when: openvpn_enabled and openvpn_cron_enabled
|
||||||
|
|
||||||
- name: Remove hourly cron job for OpenVPN
|
- name: Remove hourly cron job for OpenVPN
|
||||||
lineinfile:
|
lineinfile:
|
||||||
|
@ -159,6 +174,7 @@
|
||||||
value: "OpenVPN is a means of connecting to other machines anywhere on the internet, via a middleman server, using Virtual Private Network techniques to create secure connections."
|
value: "OpenVPN is a means of connecting to other machines anywhere on the internet, via a middleman server, using Virtual Private Network techniques to create secure connections."
|
||||||
- option: enabled
|
- option: enabled
|
||||||
value: "{{ openvpn_enabled }}"
|
value: "{{ openvpn_enabled }}"
|
||||||
|
# Uncommented as openvpn_handle variable is now mandatory: (if set to "", /etc/iiab/uuid will be used instead)
|
||||||
- option: handle
|
- option: handle
|
||||||
value: "{{ openvpn_handle }}"
|
value: "{{ openvpn_handle }}"
|
||||||
- option: cron_enabled
|
- option: cron_enabled
|
||||||
|
|
|
@ -13,7 +13,7 @@ if [ "$2" = "up" ]; then
|
||||||
sleep 2
|
sleep 2
|
||||||
/sbin/ip route list dev "$1" | grep -q '^default' &&
|
/sbin/ip route list dev "$1" | grep -q '^default' &&
|
||||||
# restart the services
|
# restart the services
|
||||||
systemctl -q is-enabled openvpn@xscenet.service && /usr/lib/iiab/up-wan
|
systemctl -q is-enabled openvpn@xscenet.service && /usr/lib/iiab/up_wan
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# we added this to prevent logs from filling with openvpn errors
|
# we added this to prevent logs from filling with openvpn errors
|
||||||
|
|
|
@ -4,17 +4,19 @@
|
||||||
HANDLE=
|
HANDLE=
|
||||||
UUID=
|
UUID=
|
||||||
if [ -f /etc/iiab/openvpn_handle ]; then
|
if [ -f /etc/iiab/openvpn_handle ]; then
|
||||||
# Option #0: Might source directly from /etc/iiab/local_vars.yml in future
|
# Option #0: Source directly from /etc/iiab/local_vars.yml in future?
|
||||||
# Option #1
|
# Option #1
|
||||||
HANDLE=`cat /etc/iiab/openvpn_handle`
|
HANDLE=`cat /etc/iiab/openvpn_handle`
|
||||||
else
|
# Option #2: UUID is later used, if openvpn_handle is not set
|
||||||
# Option #2: Dangerous to invoke hypothetical variables :(
|
# Sourcing a variable from ~4 different places is a recipe for total confusion (or worse!)
|
||||||
source /etc/iiab/iiab.env
|
#else
|
||||||
# Option #3: CAUSED FAILURES IN AUGUST 2018, invoking stale variable from /etc/iiab/iiab.ini, but safer now that relegated to #3 ?
|
# # Option #3: Dangerous to invoke hypothetical variables :(
|
||||||
if [ -z "$HANDLE" ]; then
|
# source /etc/iiab/iiab.env
|
||||||
HANDLE=`cat /etc/iiab/iiab.ini | gawk \
|
# # Option #4: CAUSED FAILURES IN AUGUST 2018, invoking stale variable from /etc/iiab/iiab.ini, but safer now that relegated to #4 ?
|
||||||
'{ if((toupper($1) == "HANDLE") && ($2 == "=")) { print $3;}}'`
|
# if [ -z "$HANDLE" ]; then
|
||||||
fi
|
# HANDLE=`cat /etc/iiab/iiab.ini | gawk \
|
||||||
|
# '{ if((toupper($1) == "HANDLE") && ($2 == "=")) { print $3;}}'`
|
||||||
|
# fi
|
||||||
fi
|
fi
|
||||||
HANDLE=${HANDLE// /_}
|
HANDLE=${HANDLE// /_}
|
||||||
if [ -f /etc/iiab/uuid ]; then
|
if [ -f /etc/iiab/uuid ]; then
|
||||||
|
|
|
@ -1,8 +1,13 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# script to write a handle file that identifies the openvpn client to server
|
# Interactive script (over)writes /etc/iiab/openvpn_handle file, identifying client to server
|
||||||
|
|
||||||
|
echo -e '\nCORRECT METHOD: CHANGE VARIABLE openvpn_handle IN /etc/iiab/local_vars.yml'
|
||||||
|
echo -e 'THEN RUN "cd /opt/iiab/iiab" THEN "./runrole openvpn"\n'
|
||||||
|
|
||||||
|
echo -e "Or, for a temporary solution until the next time Ansible is run,"
|
||||||
|
read -p "what OpenVPN handle do you want to use? " ans
|
||||||
echo
|
echo
|
||||||
echo
|
|
||||||
read -p "what identifying handle would you like to use? " ans
|
|
||||||
if [ "$ans" == "" ]; then
|
if [ "$ans" == "" ]; then
|
||||||
if [ -f /etc/iiab/openvpn_handle ]; then
|
if [ -f /etc/iiab/openvpn_handle ]; then
|
||||||
rm -f /etc/iiab/openvpn_handle
|
rm -f /etc/iiab/openvpn_handle
|
||||||
|
|
|
@ -11,7 +11,7 @@ systemctl enable openvpn@xscenet.service
|
||||||
systemctl start openvpn@xscenet.service
|
systemctl start openvpn@xscenet.service
|
||||||
|
|
||||||
sleep 5
|
sleep 5
|
||||||
ping -c 2 10.8.0.1
|
ping -c 2 {{ openvpn_server_virtual_ip }} # 10.8.0.1
|
||||||
if [ $? -eq 0 ]; then
|
if [ $? -eq 0 ]; then
|
||||||
echo OpenVPN successfully started.
|
echo OpenVPN successfully started.
|
||||||
else
|
else
|
|
@ -2,7 +2,7 @@
|
||||||
# script to manage openvpn
|
# script to manage openvpn
|
||||||
|
|
||||||
if [ ! -f "/etc/openvpn/iiab-vpn.conf" ]; then
|
if [ ! -f "/etc/openvpn/iiab-vpn.conf" ]; then
|
||||||
VPNCONFIG='party-line.conf'
|
VPNCONFIG='xscenet.conf' # WAS BUGGY (set to non-existent "party-line.conf", but thankfully unused) as of August 2018
|
||||||
VPNIP={{ openvpn_server_virtual_ip }}
|
VPNIP={{ openvpn_server_virtual_ip }}
|
||||||
else
|
else
|
||||||
# expect the sourced file to set the above variables
|
# expect the sourced file to set the above variables
|
|
@ -1,3 +1,5 @@
|
||||||
|
# REPLACED BY xscenet.conf.j2 -> /etc/openvpn/xscenet.conf
|
||||||
|
|
||||||
#########################################
|
#########################################
|
||||||
# Sample client-side OpenVPN config file
|
# Sample client-side OpenVPN config file
|
||||||
# for connecting to multi-client server.
|
# for connecting to multi-client server.
|
|
@ -1,27 +0,0 @@
|
||||||
$!/bin/bash
|
|
||||||
$ start the openvpn tunnel if the service is enabled
|
|
||||||
|
|
||||||
enabled={{ openvpn_enabled }}
|
|
||||||
VPNIP-{{ openvpn_server_port }}
|
|
||||||
|
|
||||||
if [ "$enabled" = 'True' ]; then
|
|
||||||
# make sure the wan is functioning
|
|
||||||
# 8.8.8.8 is one of google's dns servers
|
|
||||||
ping -c 3 -i 3 8.8.8.8
|
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
#echo "internet is not available, tunnel not possible"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# check the vpn tunnel
|
|
||||||
ping -c 5 -i 5 "$VPNIP"
|
|
||||||
# a zero return means the tunnel is up
|
|
||||||
if [ $? -eq 0 ]; then
|
|
||||||
exit 0
|
|
||||||
else
|
|
||||||
killall openvpn
|
|
||||||
sleep 10
|
|
||||||
#echo "Starting openvpn and waiting 10 seconds for daemon to become ready"
|
|
||||||
systemctl start openvpn@xscenet
|
|
||||||
fi
|
|
||||||
fi
|
|
27
roles/openvpn/templates/start.j2.deprecated
Normal file
27
roles/openvpn/templates/start.j2.deprecated
Normal file
|
@ -0,0 +1,27 @@
|
||||||
|
$!/bin/bash
|
||||||
|
$ start the openvpn tunnel if the service is enabled
|
||||||
|
|
||||||
|
enabled={{ openvpn_enabled }}
|
||||||
|
VPNIP={{ openvpn_server_port }}
|
||||||
|
|
||||||
|
if [ "$enabled" = 'True' ]; then
|
||||||
|
# make sure the wan is functioning
|
||||||
|
# 8.8.8.8 is one of google's dns servers
|
||||||
|
ping -c 3 -i 3 8.8.8.8
|
||||||
|
if [ $? -ne 0 ]; then
|
||||||
|
#echo "internet is not available, tunnel not possible"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# check the vpn tunnel
|
||||||
|
ping -c 5 -i 5 "$VPNIP"
|
||||||
|
# a zero return means the tunnel is up
|
||||||
|
if [ $? -eq 0 ]; then
|
||||||
|
exit 0
|
||||||
|
else
|
||||||
|
killall openvpn
|
||||||
|
sleep 10
|
||||||
|
#echo "Starting openvpn and waiting 10 seconds for daemon to become ready"
|
||||||
|
systemctl start openvpn@xscenet
|
||||||
|
fi
|
||||||
|
fi
|
|
@ -190,7 +190,7 @@ openvpn_install: True
|
||||||
openvpn_enabled: False
|
openvpn_enabled: False
|
||||||
|
|
||||||
# For /etc/iiab/openvpn_handle
|
# For /etc/iiab/openvpn_handle
|
||||||
openvpn_handle: UNNAMED
|
openvpn_handle: ""
|
||||||
|
|
||||||
# cron seems necessary on CentOS:
|
# cron seems necessary on CentOS:
|
||||||
openvpn_cron_enabled: False
|
openvpn_cron_enabled: False
|
||||||
|
|
|
@ -87,7 +87,7 @@ openvpn_install: True
|
||||||
openvpn_enabled: False
|
openvpn_enabled: False
|
||||||
|
|
||||||
# Set /etc/iiab/openvpn_handle in advance here:
|
# Set /etc/iiab/openvpn_handle in advance here:
|
||||||
openvpn_handle: UNNAMED
|
openvpn_handle: ""
|
||||||
|
|
||||||
# The following seems necessary on CentOS:
|
# The following seems necessary on CentOS:
|
||||||
# openvpn_cron_enabled: True
|
# openvpn_cron_enabled: True
|
||||||
|
|
|
@ -87,7 +87,7 @@ openvpn_install: True
|
||||||
openvpn_enabled: True
|
openvpn_enabled: True
|
||||||
|
|
||||||
# Set /etc/iiab/openvpn_handle in advance here:
|
# Set /etc/iiab/openvpn_handle in advance here:
|
||||||
openvpn_handle: UNNAMED
|
openvpn_handle: ""
|
||||||
|
|
||||||
# The following seems necessary on CentOS:
|
# The following seems necessary on CentOS:
|
||||||
# openvpn_cron_enabled: True
|
# openvpn_cron_enabled: True
|
||||||
|
|
|
@ -87,7 +87,7 @@ openvpn_install: True
|
||||||
openvpn_enabled: False
|
openvpn_enabled: False
|
||||||
|
|
||||||
# Set /etc/iiab/openvpn_handle in advance here:
|
# Set /etc/iiab/openvpn_handle in advance here:
|
||||||
openvpn_handle: UNNAMED
|
openvpn_handle: ""
|
||||||
|
|
||||||
# The following seems necessary on CentOS:
|
# The following seems necessary on CentOS:
|
||||||
# openvpn_cron_enabled: True
|
# openvpn_cron_enabled: True
|
||||||
|
|
|
@ -87,7 +87,7 @@ openvpn_install: True
|
||||||
openvpn_enabled: True
|
openvpn_enabled: True
|
||||||
|
|
||||||
# Set /etc/iiab/openvpn_handle in advance here:
|
# Set /etc/iiab/openvpn_handle in advance here:
|
||||||
openvpn_handle: UNNAMED
|
openvpn_handle: ""
|
||||||
|
|
||||||
# The following seems necessary on CentOS:
|
# The following seems necessary on CentOS:
|
||||||
# openvpn_cron_enabled: True
|
# openvpn_cron_enabled: True
|
||||||
|
|
|
@ -87,7 +87,7 @@ openvpn_install: True
|
||||||
openvpn_enabled: False
|
openvpn_enabled: False
|
||||||
|
|
||||||
# Set /etc/iiab/openvpn_handle in advance here:
|
# Set /etc/iiab/openvpn_handle in advance here:
|
||||||
openvpn_handle: UNNAMED
|
openvpn_handle: ""
|
||||||
|
|
||||||
# The following seems necessary on CentOS:
|
# The following seems necessary on CentOS:
|
||||||
# openvpn_cron_enabled: True
|
# openvpn_cron_enabled: True
|
||||||
|
|
|
@ -87,7 +87,7 @@ openvpn_install: True
|
||||||
openvpn_enabled: True
|
openvpn_enabled: True
|
||||||
|
|
||||||
# Set /etc/iiab/openvpn_handle in advance here:
|
# Set /etc/iiab/openvpn_handle in advance here:
|
||||||
openvpn_handle: UNNAMED
|
openvpn_handle: ""
|
||||||
|
|
||||||
# The following seems necessary on CentOS:
|
# The following seems necessary on CentOS:
|
||||||
# openvpn_cron_enabled: True
|
# openvpn_cron_enabled: True
|
||||||
|
|
Loading…
Reference in a new issue