autossh removal

This commit is contained in:
Ryan Cavicchioni 2020-06-12 16:29:02 -05:00
parent ca5e9bd44e
commit 00d74fc10f
Signed by: ryanc
GPG Key ID: 877EEDAF9245103D
2 changed files with 26 additions and 3 deletions

View File

@ -4,6 +4,7 @@ autossh_package_state: present
autossh_service_name: autossh@.service
autossh_systemd_unit_path: /etc/systemd/system/autossh@.service
autossh_systemd_unit_state: present
autossh_etc_path: /etc/autossh
autossh_run_path: /run/autossh

View File

@ -71,8 +71,30 @@
notify: reload autossh instances
- name: manage services
service:
systemd:
name: "autossh@{{ 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: "{{ autossh_config | default([]) }}"
- name: remove systemd unit
file:
path: "{{ autossh_systemd_unit_path }}"
state: absent
notify:
- autossh daemon-reload
when:
- ansible_service_mgr == 'systemd'
- autossh_systemd_unit_state == "absent"
no_log: true
- name: configure autossh tunnels
file:
path: "{{ autossh_etc_path }}/{{ item.name }}"
state: absent
loop: "{{ autossh_config | default([]) }}"
when:
- ansible_service_mgr == 'systemd'
- item.state is defined
- item.state == "absent"