diff --git a/handlers/main.yml b/handlers/main.yml index 732e8f5..8776427 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -3,7 +3,7 @@ service: name: "wg-quick@{{ wireguard_interface }}" state: restarted - when: wg_syncconf == "false" + when: not wg_syncconf listen: "reconfigure wireguard" - name: syncconf wireguard @@ -13,5 +13,5 @@ exit 0 args: executable: "/bin/bash" - when: wg_syncconf == "true" + when: wg_syncconf listen: "reconfigure wireguard" diff --git a/tasks/main.yml b/tasks/main.yml index 04a3770..7dd79ae 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -43,15 +43,19 @@ command: "wg --help" register: wg_subcommands -- name: Set default value for wg_syncconf variable +- name: Set default value for wg_syncconf variable (assume wg syncconf subcommand not available) set_fact: - wg_syncconf: "false" + wg_syncconf: false - name: Check if wg syncconf subcommand is available set_fact: - wg_syncconf: "true" + wg_syncconf: true when: wg_subcommands.stdout | regex_search('syncconf:') +- name: Show syncconf subcommand status + debug: + var: wg_syncconf + - block: - name: Generate WireGuard private key shell: "wg genkey"