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 }}" name: "spiped-{{ item.name }}"
state: restarted state: restarted
loop: "{{ spiped_tunnels | default([]) }}" loop: "{{ spiped_tunnels | default([]) }}"
no_log: true

View File

@ -33,10 +33,12 @@
group: root group: root
mode: 0644 mode: 0644
loop: "{{ spiped_tunnels | default([]) }}" loop: "{{ spiped_tunnels | default([]) }}"
when:
- ansible_service_mgr == 'systemd'
- item.state | default('present') == 'present'
notify: notify:
- restart spiped tunnels
- spiped daemon-reload - spiped daemon-reload
when: ansible_service_mgr == 'systemd' - restart spiped tunnels
no_log: true no_log: true
- name: configure keys - name: configure keys
@ -47,14 +49,41 @@
group: "{{ spiped_group }}" group: "{{ spiped_group }}"
mode: 0400 mode: 0400
loop: "{{ spiped_tunnels | default([]) }}" loop: "{{ spiped_tunnels | default([]) }}"
when:
- ansible_service_mgr == 'systemd'
- item.state | default('present') == 'present'
notify: notify:
- restart spiped tunnels - restart spiped tunnels
no_log: true no_log: true
- name: manage services - name: manage services
service: systemd:
name: "spiped-{{ item.name }}.service" name: "spiped-{{ item.name }}.service"
state: "{{ item.state | default('started') }}" state: "{{ (item.state | default('present') == 'absent') | ternary('stopped', 'started') }}"
enabled: "{{ item.enabled | default(true) }}" enabled: "{{ item.state | default('present') != 'absent' }}"
daemon_reload: true
loop: "{{ spiped_tunnels | default([]) }}" loop: "{{ spiped_tunnels | default([]) }}"
no_log: true 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