add tag, and cleanup
This commit is contained in:
parent
8616e8dcf1
commit
9c0f2ff86f
|
@ -14,7 +14,6 @@
|
||||||
- wireguard-tools
|
- wireguard-tools
|
||||||
tags:
|
tags:
|
||||||
- wg-install
|
- wg-install
|
||||||
- skip_ansible_lint
|
|
||||||
|
|
||||||
- name: Enable WireGuard kernel module
|
- name: Enable WireGuard kernel module
|
||||||
modprobe:
|
modprobe:
|
||||||
|
@ -42,21 +41,22 @@
|
||||||
- name: Generate WireGuard private key
|
- name: Generate WireGuard private key
|
||||||
shell: "wg genkey"
|
shell: "wg genkey"
|
||||||
register: wg_private_key_result
|
register: wg_private_key_result
|
||||||
|
when: not config_file_stat.stat.exists
|
||||||
tags:
|
tags:
|
||||||
- wg-generate-keys
|
- wg-generate-keys
|
||||||
- skip_ansible_lint
|
|
||||||
when: not config_file_stat.stat.exists
|
|
||||||
|
|
||||||
- name: Read WireGuard config file
|
- name: Read WireGuard config file
|
||||||
slurp:
|
slurp:
|
||||||
src: "{{ wireguard_remote_directory }}/{{ wireguard_interface }}.conf"
|
src: "{{ wireguard_remote_directory }}/{{ wireguard_interface }}.conf"
|
||||||
register: wg_config
|
register: 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
|
||||||
|
|
||||||
- name: Derive WireGuard public key
|
- name: Derive WireGuard public key
|
||||||
shell: "echo '{{ private_key }}' | wg pubkey"
|
shell: "echo '{{ private_key }}' | wg pubkey"
|
||||||
|
@ -69,7 +69,7 @@
|
||||||
set_fact:
|
set_fact:
|
||||||
public_key: "{{ wg_public_key_result.stdout }}"
|
public_key: "{{ wg_public_key_result.stdout }}"
|
||||||
tags:
|
tags:
|
||||||
wg-config
|
- wg-config
|
||||||
|
|
||||||
- name: Create WireGuard configuration directory
|
- name: Create WireGuard configuration directory
|
||||||
file:
|
file:
|
||||||
|
@ -95,12 +95,16 @@
|
||||||
stat:
|
stat:
|
||||||
path: "{{ wireguard_remote_directory }}/.reload-module-on-update"
|
path: "{{ wireguard_remote_directory }}/.reload-module-on-update"
|
||||||
register: reload_module_on_update
|
register: reload_module_on_update
|
||||||
|
tags:
|
||||||
|
- wg-config
|
||||||
|
|
||||||
- name: Set WireGuard reload-module-on-update
|
- name: Set WireGuard reload-module-on-update
|
||||||
file:
|
file:
|
||||||
dest: "{{ wireguard_remote_directory }}/.reload-module-on-update"
|
dest: "{{ wireguard_remote_directory }}/.reload-module-on-update"
|
||||||
state: touch
|
state: touch
|
||||||
when: not reload_module_on_update.stat.exists
|
when: not reload_module_on_update.stat.exists
|
||||||
|
tags:
|
||||||
|
- wg-config
|
||||||
|
|
||||||
- name: Start and enable WireGuard service
|
- name: Start and enable WireGuard service
|
||||||
service:
|
service:
|
||||||
|
@ -114,3 +118,5 @@
|
||||||
state: absent
|
state: absent
|
||||||
delegate_to: localhost
|
delegate_to: localhost
|
||||||
run_once: true
|
run_once: true
|
||||||
|
tags:
|
||||||
|
- wg-config
|
||||||
|
|
Reference in a new issue