summaryrefslogtreecommitdiff
path: root/roles/network/wireguard/base/tasks/main.yml
blob: da8a3861fd89987aa049211d38a412214c52a361 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
---
- name: enable spreadspace repo
  when: (ansible_distribution == 'Debian' and (ansible_distribution_release | debian_release_compare('<', 'bullseye'))) or
        (ansible_distribution == 'Ubuntu' and (ansible_distribution_release | ubuntu_release_compare('<', 'focal')))
  import_role:
    name: apt-repo/spreadspace

- name: install wireguard modules via dkms (legacy systems only)
  when: (ansible_distribution == 'Debian' and (ansible_distribution_release | debian_release_compare('<', 'bullseye'))) or
        (ansible_distribution == 'Ubuntu' and (ansible_distribution_release | ubuntu_release_compare('<', 'jammy')))
  block:
  - name: install dkms
    import_role:
      name: prepare-dkms

  - name: install wireguard-dkms package
    apt:
      name: wireguard-dkms
      state: present

  - name: check if module is available for the currently running kernel
    command: modprobe --dry-run wireguard
    check_mode: no
    register: wireguard_module_available
    failed_when: false
    changed_when: false

  - name: rebuild wireguard module
    when: wireguard_module_available.rc != 0
    command: dpkg-reconfigure wireguard-dkms

  - name: check again if module is available for the currently running kernel
    when: wireguard_module_available.rc != 0
    command: modprobe --dry-run wireguard
    check_mode: no
    changed_when: false

- name: install wireguard tools
  apt:
    name: wireguard-tools
    state: present