mirror of
https://github.com/willshersystems/ansible-sshd
synced 2025-01-06 23:40:19 +01:00
6e3257736e
The documentation says there is only one global scope for handlers: > There is only one global scope for handlers (handler names and listen topics) > regardless of where the handlers are defined. This also includes handlers > defined in roles. So following the naming convention as we do in all the other variables sounds like a good idea. https://docs.ansible.com/ansible/latest/playbook_guide/playbooks_handlers.html Signed-off-by: Jakub Jelen <jjelen@redhat.com>
54 lines
1.8 KiB
YAML
54 lines
1.8 KiB
YAML
---
|
|
|
|
- name: Reload the SSH service
|
|
ansible.builtin.service:
|
|
name: "{{ sshd_service }}"
|
|
state: reloaded
|
|
when:
|
|
- sshd_allow_reload|bool
|
|
- ansible_facts['virtualization_type'] | default(None) not in __sshd_skip_virt_env
|
|
- ansible_connection != 'chroot'
|
|
- ansible_facts['os_family'] != 'AIX'
|
|
- ansible_facts['os_family'] != 'OpenWrt'
|
|
listen: sshd_reload
|
|
|
|
- name: Restart the SSH service
|
|
ansible.builtin.service:
|
|
name: "{{ sshd_service }}"
|
|
state: restarted
|
|
when:
|
|
- sshd_allow_restart|bool
|
|
- ansible_facts['virtualization_type'] | default(None) not in __sshd_skip_virt_env
|
|
- ansible_connection != 'chroot'
|
|
- ansible_facts['os_family'] != 'AIX'
|
|
- ansible_facts['os_family'] != 'OpenWrt'
|
|
listen: sshd_restart
|
|
|
|
# sshd on AIX cannot be 'reloaded', it must be Stopped+Started.
|
|
# It's dangerous to do this in two tasks.. you're stopping SSH and then trying to SSH back in to start it.
|
|
# Instead, use a dirty shell script:
|
|
# https://www.ibm.com/developerworks/community/blogs/brian/entry/scripting_the_stop_and_restart_of_src_controlled_processes_on_aix6
|
|
- name: Reload sshd Service (AIX)
|
|
ansible.builtin.shell: |
|
|
set -eu
|
|
if set -o | grep pipefail 2>&1 /dev/null ; then
|
|
set -o pipefail
|
|
fi
|
|
stopsrc -s sshd
|
|
until $(lssrc -s sshd | grep -q inoperative); do sleep 1; done
|
|
startsrc -s sshd
|
|
listen: sshd_reload
|
|
changed_when: false
|
|
when:
|
|
- sshd_allow_reload|bool
|
|
- ansible_facts['os_family'] == 'AIX'
|
|
|
|
# sshd on OpenWrt does not support reloading a service, it has to be restarted instead
|
|
- name: Reload the SSH service (OpenWrt)
|
|
ansible.builtin.service:
|
|
name: "{{ sshd_service }}"
|
|
state: restarted
|
|
when:
|
|
- sshd_allow_reload|bool
|
|
- ansible_facts['os_family'] == 'OpenWrt'
|
|
listen: sshd_reload
|