aboutsummaryrefslogtreecommitdiffstats
path: root/roles/wireguard/tasks/generate.yml
blob: 6b91fb2ae3d431aec7cc607a9877f55c8e1b34fb (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

# wireguard ~~ roles/wireguard/tasks/generate.yml
# generate client configuration

---

- name: check keys on local disk
  stat:
    path: "{{ wg_host_keys }}"
  register: stat_host_keys
  delegate_to: localhost

- name: generate host keys on local machine
  shell: |
    umask 077
    wg genkey | tee "{{ wg_host_keys }}" | wg pubkey >> "{{ wg_host_keys }}"
  args:
    chdir: "{{ wg_dir }}"
  when: not stat_host_keys.stat.exists or wg_force is defined and wg_force
  delegate_to: localhost

- name: generate client configuration
  template:
    src: host.conf.j2
    dest: "{{ wg_dir }}/{{ ansible_host }}.conf"
    mode: "0600"
  when: ansible_host != global.dcontroller
  delegate_to: localhost

remember that computers suck.