Files
homelab/mesh/keys.yaml
2024-06-24 17:04:36 -04:00

29 lines
785 B
YAML

- name: Update nginx stream configuration
hosts:
- colors
- kubernetes
- truenas
- nextcloud-aio
- unifi-external
become: true
become_user: root
become_method: sudo
tasks:
- name: Ensure wireguard directory exists
ansible.builtin.file:
path: /etc/wireguard
state: directory
mode: '0700'
- name: Check if privatekey exists
stat: path=/etc/wireguard/privatekey
register: key
- name: Generate pubkey and privatekey
shell: wg genkey | tee /etc/wireguard/privatekey | wg pubkey > /etc/wireguard/publickey
when: not key.stat.exists or key.stat.size == 0
- name: cat pubkey
command: cat /etc/wireguard/publickey
register: pubkey
- name: Print publickey to console
debug:
msg: "{{pubkey.stdout}}"