restart-vpn.yml 759 B

123456789101112131415161718192021222324252627282930
  1. ---
  2. - hosts: dhcp
  3. become: True
  4. gather_facts: False
  5. tasks:
  6. - name: Load potential endpoints
  7. include_vars:
  8. file: ../vars/vault.yaml
  9. - name: Select a random endpoint
  10. set_fact:
  11. wg_info: "{{ vaulted_wg_info | shuffle | first }}"
  12. - name: Record new endpoint config
  13. set_fact:
  14. wg_public_key: "{{ wg_info.pubkey }}"
  15. wg_endpoint: "{{ wg_info.endpoint }}"
  16. - name: Update wireguard config
  17. template:
  18. src: ../roles/wg-gateway/templates/wg.conf.j2
  19. dest: /etc/wireguard/{{ wg_interface }}.conf
  20. owner: root
  21. group: root
  22. mode: '0644'
  23. - name: Restart wireguard interface
  24. systemd:
  25. name: wg-quick@{{ wg_interface }}
  26. state: restarted