From 04843b539462c9c9fc33491aef4a2449cace774f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=BCrgen=20H=C3=B6tzel?= Date: Sat, 2 May 2020 21:12:34 +0200 Subject: [PATCH] Use Arch Linux specific package list (#48) Arch Linux ships a Linux kernel > 5.6 and doesn't require DKMS. Move the package list variable to (distribution-specific) var files. For the Arch Linux LTS kernel (5.4) a binary wireguard-lts package is provided in [core]. --- tasks/main.yml | 14 ++++++++++---- tasks/setup-archlinux.yml | 24 ++++++++++++++++++------ vars/packages-archlinux.yml | 2 ++ vars/packages.yml | 3 +++ 4 files changed, 33 insertions(+), 10 deletions(-) create mode 100644 vars/packages-archlinux.yml create mode 100644 vars/packages.yml diff --git a/tasks/main.yml b/tasks/main.yml index 7dd79ae..31366c7 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -4,14 +4,20 @@ - include_tasks: "setup-{{ ansible_distribution|lower }}.yml" +- name: Load packages variable file based on the OS type, or a default if not found + include_vars: "{{ lookup('first_found', params) }}" + vars: + params: + files: + - "packages-{{ ansible_distribution | lower }}.yml" + - "packages.yml" + paths: + - "vars" + - name: Install WireGuard package: name: "{{ packages }}" state: present - vars: - packages: - - wireguard-dkms - - wireguard-tools tags: - wg-install diff --git a/tasks/setup-archlinux.yml b/tasks/setup-archlinux.yml index dd0b901..7967488 100644 --- a/tasks/setup-archlinux.yml +++ b/tasks/setup-archlinux.yml @@ -1,11 +1,23 @@ --- -- name: Install required packages +- name: Install wireguard-lts package pacman: - name: "{{ packages }}" - state: present + name: "{{ item.name }}" + state: "{{ item.state }}" + with_items: + - { name: wireguard-dkms, state: absent } + - { name: wireguard-lts, state: present } become: yes - vars: - packages: - - linux-headers tags: - wg-install + when: + - ansible_kernel is match(".*-lts$") + - ansible_kernel is version('5.6', '<') +- name: Install wireguard-dksm package + pacman: + name: wireguard-dkms + become: yes + tags: + - wg-install + when: + - not ansible_kernel is match(".*-lts$") + - ansible_kernel is version('5.6', '<') diff --git a/vars/packages-archlinux.yml b/vars/packages-archlinux.yml new file mode 100644 index 0000000..fdc6563 --- /dev/null +++ b/vars/packages-archlinux.yml @@ -0,0 +1,2 @@ +packages: + - wireguard-tools diff --git a/vars/packages.yml b/vars/packages.yml new file mode 100644 index 0000000..82c6b3c --- /dev/null +++ b/vars/packages.yml @@ -0,0 +1,3 @@ +packages: + - wireguard-dkms + - wireguard-tools