diff --git a/wireguard/handlers/main.yml b/wireguard/handlers/main.yml index 71b65f1111ba88c7be0b38aa16a1efd9e212dfc1..f19c21a0688bf372e3a4b5f5b290cffaf2fca83d 100644 --- a/wireguard/handlers/main.yml +++ b/wireguard/handlers/main.yml @@ -2,6 +2,6 @@ - name: restart wireguard systemd: - name: "wg-quick@{{item.key}}.service" + name: "wg-quick@{{ item.key }}.service" state: restarted - with_dict: "{{wireguard_interfaces}}" + with_dict: "{{ wireguard_interfaces }}" diff --git a/wireguard/tasks/main.yml b/wireguard/tasks/main.yml index c7086bb100af39e07750f7bf00299641ff24b68c..62da7ca2dfdab949669056bbb492cf81c9a17033 100644 --- a/wireguard/tasks/main.yml +++ b/wireguard/tasks/main.yml @@ -1,44 +1,44 @@ --- - name: ensure wireguard is installed - include_tasks: "install-{{ansible_facts['os_family']}}.yml" + include_tasks: "install-{{ ansible_facts['os_family'] }}.yml" - name: ensure we have a private key shell: - cmd: "wg genkey | tee {{item.key}}.key | wg pubkey > {{item.key}}.pub" + cmd: "wg genkey | tee {{ item.key }}.key | wg pubkey > {{ item.key }}.pub" chdir: /etc/wireguard - creates: "/etc/wireguard/{{item.key}}.key" - with_dict: "{{wireguard_interfaces}}" + creates: "/etc/wireguard/{{ item.key }}.key" + with_dict: "{{ wireguard_interfaces }}" notify: - restart wireguard no_log: true - name: get the pubkey slurp: - src: "/etc/wireguard/{{item.key}}.pub" + src: "/etc/wireguard/{{ item.key }}.pub" register: pubkeys - with_dict: "{{wireguard_interfaces}}" + with_dict: "{{ wireguard_interfaces }}" - name: store the pubkey in facts set_fact: # yamllint disable-line rule:line-length - wireguard_pubkeys: "{{dict(pubkeys.results|map(attribute='item')|map(attribute='key') | zip(pubkeys.results|map(attribute='content')|map('b64decode')|map('trim')))}}" + wireguard_pubkeys: "{{ dict(pubkeys.results|map(attribute='item')|map(attribute='key') | zip(pubkeys.results|map(attribute='content')|map('b64decode')|map('trim'))) }}" cacheable: true - name: configure wireguard template: src: wireguard.conf.j2 - dest: /etc/wireguard/{{item.key}}.conf + dest: /etc/wireguard/{{ item.key }}.conf owner: root group: root mode: '0600' - with_dict: "{{wireguard_interfaces}}" + with_dict: "{{ wireguard_interfaces }}" notify: - restart wireguard - name: enable interface systemd: - name: "wg-quick@{{item.key}}.service" + name: "wg-quick@{{ item.key }}.service" state: started enabled: true - with_dict: "{{wireguard_interfaces}}" + with_dict: "{{ wireguard_interfaces }}"