2020-02-17 04:43:13 +00:00
# Run 'sudo iiab-support' to turn on OpenVPN without hassle. GENERAL TIPS:
# http://FAQ.IIAB.IO -> "How can I remotely manage my Internet-in-a-Box?"
2020-01-13 21:19:50 +00:00
2017-05-27 18:09:50 +00:00
2020-02-17 04:33:09 +00:00
# "How do i fail a task in Ansible if the variable contains a boolean value?
# I want to perform input validation for Ansible playbooks"
# https://stackoverflow.com/questions/46664127/how-do-i-fail-a-task-in-ansible-if-the-variable-contains-a-boolean-value-i-want/46667499#46667499
2018-09-05 18:48:48 +00:00
2020-02-17 04:33:09 +00:00
# We assume 0-init/tasks/validate_vars.yml has DEFINITELY been run, so no need
# to re-check whether vars are defined here. As Ansible vars cannot be unset:
# https://serverfault.com/questions/856729/how-to-destroy-delete-unset-a-variable-value-in-ansible
2020-01-30 09:00:00 +00:00
2020-02-17 04:33:09 +00:00
- name : Assert that "openvpn_install is sameas true" (boolean not string etc)
assert :
that : openvpn_install is sameas true
fail_msg : "PLEASE SET 'openvpn_install: True' e.g. IN: /etc/iiab/local_vars.yml"
quiet : yes
2020-01-30 09:00:00 +00:00
2020-02-17 04:33:09 +00:00
- name : Assert that "openvpn_enabled | type_debug == 'bool'" (boolean not string etc)
assert :
that : openvpn_enabled | type_debug == 'bool'
fail_msg : "PLEASE GIVE VARIABLE 'openvpn_enabled' A PROPER (UNQUOTED) ANSIBLE BOOLEAN VALUE e.g. IN: /etc/iiab/local_vars.yml"
quiet : yes
2020-01-30 09:00:00 +00:00
2020-01-24 03:11:24 +00:00
2020-02-17 04:33:09 +00:00
- name : Install OpenVPN if 'openvpn_installed' not defined, e.g. in {{ iiab_state_file }} # /etc/iiab/iiab_state.yml
include_tasks : install.yml
when : openvpn_installed is undefined
2020-01-24 03:11:24 +00:00
2017-10-27 12:18:26 +00:00
2020-02-17 04:33:09 +00:00
- include_tasks : enable-or-disable.yml
2017-10-27 12:18:26 +00:00
2020-01-24 03:11:24 +00:00
2018-10-31 04:57:13 +00:00
- name : Add 'openvpn' variable values to {{ iiab_ini_file }}
2017-11-27 01:19:45 +00:00
ini_file :
2020-02-17 04:33:09 +00:00
path : "{{ iiab_ini_file }}" # /etc/iiab/iiab.ini
2017-11-27 01:19:45 +00:00
section : openvpn
option : "{{ item.option }}"
2020-01-12 02:41:37 +00:00
value : "{{ item.value | string }}"
2017-05-27 18:09:50 +00:00
with_items :
2017-11-27 01:19:45 +00:00
- option : name
value : OpenVPN
- option : description
2020-01-29 13:40:05 +00:00
value : '"OpenVPN enables live/remote support by connecting machines anywhere on the Internet, via a middleman server, using Virtual Private Network (VPN) techniques to create secure connections."'
2018-08-16 17:24:39 +00:00
# openvpn_handle variable can no longer be left completely undefined of August 2018 (EMPTY STRING "" IS TOLERATED, in which case OpenVPN server should use /etc/iiab/uuid in lieu of the handle)
2020-02-17 04:33:09 +00:00
- option : openvpn_handle
2018-08-15 20:40:04 +00:00
value : "{{ openvpn_handle }}"
2020-02-17 04:33:09 +00:00
- option : openvpn_cron_enabled
2017-11-27 01:19:45 +00:00
value : "{{ openvpn_cron_enabled }}"
2020-02-17 04:33:09 +00:00
- option : openvpn_server
2018-08-13 19:48:28 +00:00
value : "{{ openvpn_server }}"
2020-02-17 04:33:09 +00:00
- option : openvpn_server_virtual_ip
2018-08-13 19:48:28 +00:00
value : "{{ openvpn_server_virtual_ip }}"
2020-02-17 04:33:09 +00:00
- option : openvpn_server_port
2018-08-13 19:48:28 +00:00
value : "{{ openvpn_server_port }}"
2020-02-17 04:33:09 +00:00
- option : openvpn_enabled
value : "{{ openvpn_enabled }}"