diff --git a/README.md b/README.md index b647611..348e63d 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ This role installs OpenVPN on a host, configures a client connection and enables ## Requirements +- Archlinux - Debian >= 8 (jessie) - Ubuntu >= 16.04 (xenial) diff --git a/meta/main.yml b/meta/main.yml index 5f088fa..7cda061 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -15,6 +15,8 @@ galaxy_info: versions: - jessie - stretch + - name: Archlinux + versions: [all] categories: #- cloud diff --git a/tasks/Archlinux.yml b/tasks/Archlinux.yml new file mode 100644 index 0000000..7535680 --- /dev/null +++ b/tasks/Archlinux.yml @@ -0,0 +1,24 @@ +--- + +- name: Install required package + pacman: + name: openvpn + +- name: Install client connection + template: + src: templates/client.conf + dest: /etc/openvpn/client/client.conf + register: openvpn_config + +- name: Enable autostart for OpenVPN connection "client" + systemd: + name: openvpn-client@client.service + enabled: yes + +- name: Restart OpenVPN connection when required + systemd: + name: openvpn-client@client.service + state: restarted + when: openvpn_config.changed + +... diff --git a/tasks/Debian.yml b/tasks/Debian.yml new file mode 100644 index 0000000..94bfeef --- /dev/null +++ b/tasks/Debian.yml @@ -0,0 +1,5 @@ +--- + +- include: "Ubuntu.yml" + +... diff --git a/tasks/Ubuntu.yml b/tasks/Ubuntu.yml new file mode 100644 index 0000000..72f92eb --- /dev/null +++ b/tasks/Ubuntu.yml @@ -0,0 +1,25 @@ +--- + +- name: Install required package + apt: + name: openvpn + cache_valid_time: 86400 + +- name: Install client connection + template: + src: templates/client.conf + dest: /etc/openvpn/client.conf + register: openvpn_config + +- name: Enable autostart for OpenVPN connection "client" + systemd: + name: openvpn@client.service + enabled: yes + +- name: Restart OpenVPN connection when required + systemd: + name: openvpn@client.service + state: restarted + when: openvpn_config.changed + +... diff --git a/tasks/main.yml b/tasks/main.yml index 7096a86..dfcc519 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,23 +1,6 @@ --- -- name: Install required package - apt: - name: openvpn - cache_valid_time: 86400 +- name: "Loading distribution specific instructions for {{ ansible_distribution }}" + include: "{{ ansible_distribution }}.yml" -- name: Install client connection - template: - src: templates/client.conf - dest: /etc/openvpn/client.conf - register: openvpn_config - -- name: Enable autostart for OpenVPN connection "client" - systemd: - name: openvpn@client.service - enabled: yes - -- name: Restart OpenVPN connection when required - systemd: - name: openvpn@client.service - state: restarted - when: openvpn_config.changed +...