2014-12-18 23:12:51 +01:00
|
|
|
---
|
2018-09-08 10:13:51 +02:00
|
|
|
|
2017-09-06 16:20:00 +02:00
|
|
|
- name: Reload the SSH service
|
2022-06-03 12:22:17 +02:00
|
|
|
ansible.builtin.service:
|
2014-12-18 23:12:51 +01:00
|
|
|
name: "{{ sshd_service }}"
|
|
|
|
state: reloaded
|
2018-09-08 10:13:51 +02:00
|
|
|
when:
|
2019-05-23 21:38:31 +02:00
|
|
|
- sshd_allow_reload|bool
|
2023-08-05 12:01:19 +02:00
|
|
|
- ansible_facts['virtualization_type']|default(None) not in __sshd_skip_virt_env
|
2018-09-11 15:10:58 +02:00
|
|
|
- ansible_connection != 'chroot'
|
2023-08-05 12:01:19 +02:00
|
|
|
- ansible_facts['os_family'] != 'AIX'
|
|
|
|
- ansible_facts['os_family'] != 'OpenWrt'
|
2017-09-06 16:20:00 +02:00
|
|
|
listen: reload_sshd
|
2019-07-10 19:07:07 +02:00
|
|
|
|
2020-09-14 17:48:04 +02:00
|
|
|
# sshd on AIX cannot be 'reloaded', it must be Stopped+Started.
|
2019-07-10 19:07:07 +02:00
|
|
|
# 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)
|
2022-06-03 12:22:17 +02:00
|
|
|
ansible.builtin.shell: |
|
2021-04-07 20:12:03 +02:00
|
|
|
set -eu
|
|
|
|
if set -o | grep pipefail 2>&1 /dev/null ; then
|
|
|
|
set -o pipefail
|
|
|
|
fi
|
2019-07-10 19:07:07 +02:00
|
|
|
stopsrc -s sshd
|
2019-11-06 20:36:36 +01:00
|
|
|
until $(lssrc -s sshd | grep -q inoperative); do sleep 1; done
|
2019-07-10 19:07:07 +02:00
|
|
|
startsrc -s sshd
|
|
|
|
listen: reload_sshd
|
2021-04-07 20:12:03 +02:00
|
|
|
changed_when: false
|
2019-07-10 19:07:07 +02:00
|
|
|
when:
|
|
|
|
- sshd_allow_reload|bool
|
2023-08-05 12:01:19 +02:00
|
|
|
- ansible_facts['os_family'] == 'AIX'
|
2022-09-14 20:18:37 +02:00
|
|
|
|
|
|
|
# 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
|
2023-08-05 12:01:19 +02:00
|
|
|
- ansible_facts['os_family'] == 'OpenWrt'
|
2022-09-14 20:18:37 +02:00
|
|
|
listen: reload_sshd
|