fix private key creation
This commit is contained in:
parent
9c0f2ff86f
commit
5db3e19630
|
@ -38,25 +38,34 @@
|
||||||
tags:
|
tags:
|
||||||
- wg-generate-keys
|
- wg-generate-keys
|
||||||
|
|
||||||
- name: Generate WireGuard private key
|
- block:
|
||||||
shell: "wg genkey"
|
- name: Generate WireGuard private key
|
||||||
register: wg_private_key_result
|
shell: "wg genkey"
|
||||||
|
register: wg_private_key_result
|
||||||
|
tags:
|
||||||
|
- wg-generate-keys
|
||||||
|
|
||||||
|
- name: Set private key fact
|
||||||
|
set_fact:
|
||||||
|
private_key: "{{ wg_private_key_result.stdout }}"
|
||||||
|
tags:
|
||||||
|
- wg-generate-keys
|
||||||
when: not config_file_stat.stat.exists
|
when: not config_file_stat.stat.exists
|
||||||
tags:
|
|
||||||
- wg-generate-keys
|
|
||||||
|
|
||||||
- name: Read WireGuard config file
|
- block:
|
||||||
slurp:
|
- name: Read WireGuard config file
|
||||||
src: "{{ wireguard_remote_directory }}/{{ wireguard_interface }}.conf"
|
slurp:
|
||||||
register: wg_config
|
src: "{{ wireguard_remote_directory }}/{{ wireguard_interface }}.conf"
|
||||||
tags:
|
register: wg_config
|
||||||
- wg-config
|
tags:
|
||||||
|
- wg-config
|
||||||
|
|
||||||
- name: Set private key fact
|
- name: Set private key fact
|
||||||
set_fact:
|
set_fact:
|
||||||
private_key: "{{ wg_config['content'] | b64decode | regex_findall('PrivateKey = (.*)') | first }}"
|
private_key: "{{ wg_config['content'] | b64decode | regex_findall('PrivateKey = (.*)') | first }}"
|
||||||
tags:
|
tags:
|
||||||
- wg-config
|
- wg-config
|
||||||
|
when: config_file_stat.stat.exists
|
||||||
|
|
||||||
- name: Derive WireGuard public key
|
- name: Derive WireGuard public key
|
||||||
shell: "echo '{{ private_key }}' | wg pubkey"
|
shell: "echo '{{ private_key }}' | wg pubkey"
|
||||||
|
|
Reference in a new issue