From 91f8baf981b2cfb5e7184a5e2ff28f181c6105f5 Mon Sep 17 00:00:00 2001 From: Knut Ahlers Date: Sun, 5 May 2019 13:28:26 +0200 Subject: [PATCH] Add support for Archlinux Signed-off-by: Knut Ahlers --- README.md | 1 + meta/main.yml | 2 ++ tasks/Archlinux.yml | 24 ++++++++++++++++++++++++ tasks/Debian.yml | 5 +++++ tasks/Ubuntu.yml | 25 +++++++++++++++++++++++++ tasks/main.yml | 23 +++-------------------- 6 files changed, 60 insertions(+), 20 deletions(-) create mode 100644 tasks/Archlinux.yml create mode 100644 tasks/Debian.yml create mode 100644 tasks/Ubuntu.yml 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 +...