allow to remove peers

main
n0emis 4 years ago
parent d8a6a48bd9
commit ede924e821
Signed by: n0emis
GPG Key ID: 00FAF748B777CF10

@ -22,6 +22,17 @@
template: template:
dest: "/etc/bird/peers/{{ peer.name }}.conf" dest: "/etc/bird/peers/{{ peer.name }}.conf"
src: "bird2/peer.conf.j2" src: "bird2/peer.conf.j2"
when: (not peer.state is defined) or peer.state != "absent"
loop: "{{ dn42_peers }}"
loop_control:
loop_var: "peer"
notify: reload bird
- name: Remove bird peer config-files
file:
path: "/etc/bird/peers/{{ peer.name }}.conf"
state: absent
when: peer.state is defined and peer.state == "absent"
loop: "{{ dn42_peers }}" loop: "{{ dn42_peers }}"
loop_control: loop_control:
loop_var: "peer" loop_var: "peer"

@ -3,21 +3,36 @@
template: template:
dest: "/etc/wireguard/{{ peer.if.name | default(dn42_wg_default_if_prefix + peer.name) }}.conf" dest: "/etc/wireguard/{{ peer.if.name | default(dn42_wg_default_if_prefix + peer.name) }}.conf"
src: "wg-quick.j2" src: "wg-quick.j2"
when: "peer.wg is defined" when:
- peer.wg is defined
- (not peer.state is defined) or peer.state != "absent"
register: "configuration" 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_wg_default_if_prefix + peer.name) }} service
service: service:
name: "wg-quick@{{ peer.if.name | default(dn42_wg_default_if_prefix + peer.name) }}" name: "wg-quick@{{ peer.if.name | default(dn42_wg_default_if_prefix + peer.name) }}"
enabled: yes 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_wg_default_if_prefix + 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_wg_default_if_prefix + peer.name) }}"
state: restarted state: restarted
when: "configuration is changed" when:
- "configuration is changed"
- (not peer.state is defined) or peer.state != "absent"
- 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"

Loading…
Cancel
Save