diff --git a/roles/os_hardening/handlers/main.yml b/roles/os_hardening/handlers/main.yml index bcc2e3fd..104c9a8a 100644 --- a/roles/os_hardening/handlers/main.yml +++ b/roles/os_hardening/handlers/main.yml @@ -2,10 +2,20 @@ - name: Update-initramfs # noqa no-changed-when ansible.builtin.command: update-initramfs -u +- name: Restart auditd + ansible.builtin.systemd: + name: auditd + state: restarted + when: + - molecule_yml.driver.name | default() != "docker" # restarting auditd in a container does not + - not ansible_facts.os_family == 'RedHat' + - name: Restart auditd # noqa command-instead-of-module no-changed-when ansible.builtin.command: cmd: service auditd restart # rhel: see: https://access.redhat.com/solutions/2664811 - when: molecule_yml.driver.name | default() != "docker" # restarting auditd in a container does not work + when: + - molecule_yml.driver.name | default() != "docker" # restarting auditd in a container does not work + - ansible_facts.os_family == 'RedHat' - name: Reload systemd ansible.builtin.systemd: