|
|
@ -55,10 +55,10 @@
|
|
|
|
wg-generate-keys
|
|
|
|
wg-generate-keys
|
|
|
|
|
|
|
|
|
|
|
|
- name: Register if private key already exists
|
|
|
|
- name: Register if private key already exists
|
|
|
|
local_action:
|
|
|
|
stat:
|
|
|
|
module: stat
|
|
|
|
|
|
|
|
path: "{{ private_key_file_path }}"
|
|
|
|
path: "{{ private_key_file_path }}"
|
|
|
|
register: private_key_file_stat
|
|
|
|
register: private_key_file_stat
|
|
|
|
|
|
|
|
delegate_to: localhost
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
- wg-generate-keys
|
|
|
|
- wg-generate-keys
|
|
|
|
|
|
|
|
|
|
|
@ -67,21 +67,21 @@
|
|
|
|
register: wg_private_key_result
|
|
|
|
register: wg_private_key_result
|
|
|
|
with_inventory_hostnames:
|
|
|
|
with_inventory_hostnames:
|
|
|
|
- vpn
|
|
|
|
- vpn
|
|
|
|
when: private_key_file_stat.stat.exists == False
|
|
|
|
when: not private_key_file_stat.stat.exists
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
- wg-generate-keys
|
|
|
|
- wg-generate-keys
|
|
|
|
|
|
|
|
|
|
|
|
- name: Set private key fact
|
|
|
|
- name: Set private key fact
|
|
|
|
set_fact:
|
|
|
|
set_fact:
|
|
|
|
wg_private_key: "{{ wg_private_key_result.results[0].stdout }}"
|
|
|
|
wg_private_key: "{{ wg_private_key_result.results[0].stdout }}"
|
|
|
|
when: private_key_file_stat.stat.exists == False
|
|
|
|
when: not private_key_file_stat.stat.exists
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
- wg-generate-keys
|
|
|
|
- wg-generate-keys
|
|
|
|
|
|
|
|
|
|
|
|
- name: Generate WireGuard public key
|
|
|
|
- name: Generate WireGuard public key
|
|
|
|
shell: "echo '{{ wg_private_key }}' | wg pubkey"
|
|
|
|
shell: "echo '{{ wg_private_key }}' | wg pubkey"
|
|
|
|
register: wg_public_key_result
|
|
|
|
register: wg_public_key_result
|
|
|
|
when: private_key_file_stat.stat.exists == False
|
|
|
|
when: not private_key_file_stat.stat.exists
|
|
|
|
with_inventory_hostnames:
|
|
|
|
with_inventory_hostnames:
|
|
|
|
- vpn
|
|
|
|
- vpn
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
@ -90,31 +90,31 @@
|
|
|
|
- name: Set public key fact
|
|
|
|
- name: Set public key fact
|
|
|
|
set_fact:
|
|
|
|
set_fact:
|
|
|
|
wg_public_key: "{{ wg_public_key_result.results[0].stdout }}"
|
|
|
|
wg_public_key: "{{ wg_public_key_result.results[0].stdout }}"
|
|
|
|
when: private_key_file_stat.stat.exists == False
|
|
|
|
when: not private_key_file_stat.stat.exists
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
- wg-generate-keys
|
|
|
|
- wg-generate-keys
|
|
|
|
|
|
|
|
|
|
|
|
- name: Store hosts private key locally
|
|
|
|
- name: Store hosts private key locally
|
|
|
|
local_action:
|
|
|
|
template:
|
|
|
|
module: template
|
|
|
|
|
|
|
|
src: "wg-privatekey.j2"
|
|
|
|
src: "wg-privatekey.j2"
|
|
|
|
dest: "{{ private_key_file_path }}"
|
|
|
|
dest: "{{ private_key_file_path }}"
|
|
|
|
owner: "{{ wireguard_cert_owner }}"
|
|
|
|
owner: "{{ wireguard_cert_owner }}"
|
|
|
|
group: "{{ wireguard_cert_group }}"
|
|
|
|
group: "{{ wireguard_cert_group }}"
|
|
|
|
mode: 0644
|
|
|
|
mode: 0644
|
|
|
|
when: private_key_file_stat.stat.exists == False
|
|
|
|
when: not private_key_file_stat.stat.exists
|
|
|
|
|
|
|
|
delegate_to: localhost
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
- wg-generate-keys
|
|
|
|
- wg-generate-keys
|
|
|
|
|
|
|
|
|
|
|
|
- name: Store hosts public key locally
|
|
|
|
- name: Store hosts public key locally
|
|
|
|
local_action:
|
|
|
|
template:
|
|
|
|
module: template
|
|
|
|
|
|
|
|
src: "wg-publickey.j2"
|
|
|
|
src: "wg-publickey.j2"
|
|
|
|
dest: "{{ public_key_file_path }}"
|
|
|
|
dest: "{{ public_key_file_path }}"
|
|
|
|
owner: "{{ wireguard_cert_owner }}"
|
|
|
|
owner: "{{ wireguard_cert_owner }}"
|
|
|
|
group: "{{ wireguard_cert_group }}"
|
|
|
|
group: "{{ wireguard_cert_group }}"
|
|
|
|
mode: 0644
|
|
|
|
mode: 0644
|
|
|
|
when: private_key_file_stat.stat.exists == False
|
|
|
|
when: not private_key_file_stat.stat.exists
|
|
|
|
|
|
|
|
delegate_to: localhost
|
|
|
|
tags:
|
|
|
|
tags:
|
|
|
|
- wg-generate-keys
|
|
|
|
- wg-generate-keys
|
|
|
|
|
|
|
|
|
|
|
|