aboutsummaryrefslogtreecommitdiffstats
path: root/roles/wireguard/tasks/keys.yml
blob: ee424083776b2631c19a758eb70fafd5f2671a62 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
---

- name: generate hosts keys
  ansible.builtin.shell: |
    set -o pipefail
    ls "{{ wireguard_local_dir }}/{{ item }}.keys" && exit 0
    umask 077
    wg genkey | \
    tee "{{ item }}.keys" | \
    wg pubkey >> "{{ item }}.keys"
    exit 2
  args:
    chdir: "{{ wireguard_local_dir }}"
  loop: "{{ groups.all }}"
  run_once: true
  delegate_to: localhost
  register: result
  changed_when: result.rc == 2
  failed_when: result.rc not in [0, 2]
remember that computers suck.