From 6819be90d330b466dfb61ce329479cf0f6eb3db3 Mon Sep 17 00:00:00 2001 From: Steffen Scheib Date: Wed, 14 Sep 2022 20:18:37 +0200 Subject: [PATCH] - Adding support for OpenWrt 21.03 --- README.md | 1 + handlers/main.yml | 11 +++++++++++ vars/OpenWrt.yml | 14 ++++++++++++++ 3 files changed, 26 insertions(+) create mode 100644 vars/OpenWrt.yml diff --git a/README.md b/README.md index f541156..8c24ebe 100644 --- a/README.md +++ b/README.md @@ -40,6 +40,7 @@ Tested on: * FreeBSD 10.1 * OpenBSD 6.0 * AIX 7.1, 7.2 +* OpenWrt 21.03 It will likely work on other flavours and more direct support via suitable [vars/](vars/) files is welcome. diff --git a/handlers/main.yml b/handlers/main.yml index bb9d8d6..1f63c61 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -9,6 +9,7 @@ - ansible_virtualization_type|default(None) not in __sshd_skip_virt_env - ansible_connection != 'chroot' - ansible_os_family != 'AIX' + - ansible_os_family != 'OpenWrt' listen: reload_sshd # sshd on AIX cannot be 'reloaded', it must be Stopped+Started. @@ -29,3 +30,13 @@ when: - sshd_allow_reload|bool - ansible_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_os_family == 'OpenWrt' + listen: reload_sshd diff --git a/vars/OpenWrt.yml b/vars/OpenWrt.yml new file mode 100644 index 0000000..34f8a30 --- /dev/null +++ b/vars/OpenWrt.yml @@ -0,0 +1,14 @@ +--- +__sshd_service: sshd +__sshd_packages: + - openssh-server + - openssh-sftp-server +__sshd_config_mode: "0644" +__sshd_sftp_server: "/usr/lib/sftp-server" +__sshd_defaults: + Subsystem: "sftp {{ __sshd_sftp_server }}" + AuthorizedKeysFile: .ssh/authorized_keys + HostKey: + - /etc/ssh/ssh_host_rsa_key + - /etc/ssh/ssh_host_ed25519_key +__sshd_os_supported: yes