spiped removal

This commit is contained in:
Ryan Cavicchioni 2020-06-12 16:30:06 -05:00
parent 3a43d5ec60
commit 91d2fcbf27
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
2 changed files with 35 additions and 5 deletions

View File

@ -8,3 +8,4 @@
name: "spiped-{{ item.name }}"
state: restarted
loop: "{{ spiped_tunnels | default([]) }}"
no_log: true

View File

@ -33,10 +33,12 @@
group: root
mode: 0644
loop: "{{ spiped_tunnels | default([]) }}"
when:
- ansible_service_mgr == 'systemd'
- item.state | default('present') == 'present'
notify:
- restart spiped tunnels
- spiped daemon-reload
when: ansible_service_mgr == 'systemd'
- restart spiped tunnels
no_log: true
- name: configure keys
@ -47,14 +49,41 @@
group: "{{ spiped_group }}"
mode: 0400
loop: "{{ spiped_tunnels | default([]) }}"
when:
- ansible_service_mgr == 'systemd'
- item.state | default('present') == 'present'
notify:
- restart spiped tunnels
no_log: true
- name: manage services
service:
systemd:
name: "spiped-{{ item.name }}.service"
state: "{{ item.state | default('started') }}"
enabled: "{{ item.enabled | default(true) }}"
state: "{{ (item.state | default('present') == 'absent') | ternary('stopped', 'started') }}"
enabled: "{{ item.state | default('present') != 'absent' }}"
daemon_reload: true
loop: "{{ spiped_tunnels | default([]) }}"
no_log: true
- name: remove keys
file:
path: "{{ spiped_etc_path }}/{{ item.name }}.key"
state: "absent"
loop: "{{ spiped_tunnels | default([]) }}"
when:
- item.state is defined
- item.state == "absent"
no_log: true
- name: remove systemd unit
file:
path: "/etc/systemd/system/spiped-{{ item.name }}.service"
state: "absent"
loop: "{{ spiped_tunnels | default([]) }}"
notify:
- spiped daemon-reload
when:
- ansible_service_mgr == 'systemd'
- item.state is defined
- item.state == "absent"
no_log: true