#####################################
### someone's ansible provisioner ###
#####################################
# Part of: https://git.somenet.org/root/pub/somesible.git
# 2017-2025 by someone <someone@somenet.org>
#
---
- name: copy wireguard interface {{wg}} config
  copy:
    src: "{{item}}"
    dest: "/etc/wireguard/{{wg}}.conf"
    mode: 0600
    owner: "root"
    group: "root"
  with_first_found:
    - "{{lookup('env','PWD')}}/host_files/{{inventory_hostname}}/{{role_name}}/{{wg}}.conf"
    - "{{lookup('env','PWD')}}/group_files/{{group_files_group}}/{{role_name}}/{{wg}}.conf"
    - "{{lookup('env','PWD')}}/group_files/all/{{role_name}}/{{wg}}.conf"
    - "default/{{wg}}.conf"
  # does not work. Also register + when changed breaks the connections immediately, do not use!
  #notify: restart wg-quick.target


- name: "enable and start wireguard interface wg-quick@{{wg}}.service"
  include_role: name="base/systemd/enable-and-start"
  vars:
    service_name: "wg-quick@{{wg}}.service"
