fix(wg): correct check for existing private key

Registering output of ‹ansible.builtin.stat› generates an object
containing ‹stat› member itself.

Signed-off-by: Matej Focko <me@mfocko.xyz>
This commit is contained in:
Matej Focko 2024-12-22 20:32:28 +01:00
parent 4960068555
commit ab5c374990
Signed by: mfocko
SSH key fingerprint: SHA256:icm0fIOSJUpy5+1x23sfr+hLtF9UhY8VpMC7H4WFJP8

View file

@ -6,11 +6,11 @@
- name: Check for existence of private key - name: Check for existence of private key
ansible.builtin.stat: ansible.builtin.stat:
path: /etc/wireguard/private.key path: /etc/wireguard/private.key
register: _private_key_stat register: _private_key
- name: Generate keypair - name: Generate keypair
ansible.builtin.include_tasks: tasks/generate_keypair.yml ansible.builtin.include_tasks: tasks/generate_keypair.yml
when: not _private_key_stat.exists when: not _private_key.stat.exists
- name: Save private key - name: Save private key
ansible.builtin.template: ansible.builtin.template:
@ -21,7 +21,7 @@
mode: 0700 mode: 0700
vars: vars:
key: "{{ wg_private_key }}" key: "{{ wg_private_key }}"
when: not _private_key_stat.exists when: not _private_key.stat.exists
- name: Save public key - name: Save public key
ansible.builtin.template: ansible.builtin.template:
@ -32,7 +32,7 @@
mode: 0700 mode: 0700
vars: vars:
key: "{{ wg_public_key }}" key: "{{ wg_public_key }}"
when: not _private_key_stat.exists when: not _private_key.stat.exists
- name: Set dns_command for co-openSUSE - name: Set dns_command for co-openSUSE
ansible.builtin.set_fact: ansible.builtin.set_fact: