@ -1,38 +1,23 @@
- name : Install wg-quick@{{ peer.if.name | default( dn42_wg_default_if_prefix + peer.name) }} config
- name : Install wg-quick@{{ peer.if.name | default( "dn42_" + peer.name) }} config
template:
dest : "/etc/wireguard/{{ peer.if.name | default( dn42_wg_default_if_prefix + peer.name) }}.conf"
dest : "/etc/wireguard/{{ peer.if.name | default( 'dn42_' + peer.name) }}.conf"
src : "wg-quick.j2"
when:
- peer.wg is defined
- (not peer.state is defined) or peer.state != "absent"
when : "peer.wg is defined"
register : "configuration"
- name : Enable wg-quick@{{ peer.if.name | default( dn42_wg_default_if_prefix + peer.name) }} service
- name : Enable wg-quick@{{ peer.if.name | default( "dn42_" + peer.name) }} service
service:
name : "wg-quick@{{ peer.if.name | default( dn42_wg_default_if_prefix + peer.name) }}"
name : "wg-quick@{{ peer.if.name | default( 'dn42_' + peer.name) }}"
enabled : yes
when:
- peer.wg is defined
- (not peer.state is defined) or peer.state != "absent"
- name : Restart wg-quick@{{ peer.if.name | default( dn42_wg_default_if_prefix + peer.name) }}
- name : Restart wg-quick@{{ peer.if.name | default('dn42_' + peer.name) }}
service:
name : "wg-quick@{{ peer.if.name | default( dn42_wg_default_if_prefix + peer.name) }}"
name : "wg-quick@{{ peer.if.name | default( 'dn42_' + peer.name) }}"
state : restarted
when:
- "configuration is changed"
- (not peer.state is defined) or peer.state != "absent"
when : "configuration is changed"
- name : Stop wg-quick@{{ peer.if.name | default(dn42_wg_default_if_prefix + peer.name) }}
service:
name : "wg-quick@{{ peer.if.name | default(dn42_wg_default_if_prefix + peer.name) }}"
state : stopped
enabled : no
when : peer.state is defined and peer.state == "absent"
- name : Remove wg-quick@{{ peer.if.name | default(dn42_wg_default_if_prefix + peer.name) }} config
file:
path : "/etc/wireguard/{{ peer.if.name | default(dn42_wg_default_if_prefix + peer.name) }}.conf"
state : absent
when : peer.state is defined and peer.state == "absent"