diff --git a/defaults/main.yml b/defaults/main.yml index aedbd2c..607f965 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -81,3 +81,11 @@ __sshd_sysconfig_supports_use_strong_rng: false __sshd_runtime_directory: false __sshd_runtime_directory_mode: "0755" + +__sshd_skip_virt_env: + - kvm + - docker + - podman + - container + - containerd + - VirtualPC diff --git a/handlers/main.yml b/handlers/main.yml index e2b4902..11e7770 100644 --- a/handlers/main.yml +++ b/handlers/main.yml @@ -6,12 +6,7 @@ state: reloaded when: - sshd_allow_reload|bool - - ansible_virtualization_type|default(None) != 'kvm' - - ansible_virtualization_type|default(None) != 'docker' - - ansible_virtualization_type|default(None) != 'podman' - - ansible_virtualization_type|default(None) != 'container' - - ansible_virtualization_type|default(None) != 'containerd' - - ansible_virtualization_type|default(None) != 'VirtualPC' # for Github Actions + - ansible_virtualization_type|default(None) not in __sshd_skip_virt_env - ansible_connection != 'chroot' - ansible_os_family != 'AIX' listen: reload_sshd diff --git a/tasks/install.yml b/tasks/install.yml index ab46651..1dfd483 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -217,12 +217,7 @@ state: started when: - sshd_manage_service|bool - - ansible_virtualization_type|default(None) != 'kvm' - - ansible_virtualization_type|default(None) != 'docker' - - ansible_virtualization_type|default(None) != 'podman' - - ansible_virtualization_type|default(None) != 'container' - - ansible_virtualization_type|default(None) != 'containerd' - - ansible_virtualization_type|default(None) != 'VirtualPC' # for Github Actions + - ansible_virtualization_type|default(None) not in __sshd_skip_virt_env - ansible_connection != 'chroot' # Due to ansible bug 21026, cannot use service module on RHEL 7 diff --git a/tests/tasks/restore.yml b/tests/tasks/restore.yml index da65a5e..386f3d2 100644 --- a/tests/tasks/restore.yml +++ b/tests/tasks/restore.yml @@ -30,13 +30,16 @@ name: sshd state: reloaded changed_when: false + vars: + __sshd_skip_virt_env: + - kvm + - docker + - podman + - container + - containerd + - VirtualPC when: - __sshd_test_backup is defined - - ansible_virtualization_type|default(None) != 'kvm' - - ansible_virtualization_type|default(None) != 'docker' - - ansible_virtualization_type|default(None) != 'podman' - - ansible_virtualization_type|default(None) != 'container' # new podman - - ansible_virtualization_type|default(None) != 'containerd' - - ansible_virtualization_type|default(None) != 'VirtualPC' # for Github Actions + - ansible_virtualization_type|default(None) not in __sshd_skip_virt_env - ansible_connection != 'chroot' - ansible_os_family != 'AIX'