mirror of
https://github.com/ansible-lockdown/RHEL9-CIS.git
synced 2025-12-24 14:23:05 +00:00
113 lines
2.7 KiB
YAML
113 lines
2.7 KiB
YAML
---
|
|
# handlers file for RHEL9-CIS
|
|
|
|
- name: Reload sysctl
|
|
ansible.builtin.shell: sysctl --system
|
|
|
|
- name: Sysctl flush ipv4 route table
|
|
ansible.posix.sysctl:
|
|
name: net.ipv4.route.flush
|
|
value: '1'
|
|
sysctl_set: true
|
|
ignore_errors: true # noqa ignore-errors
|
|
when:
|
|
- rhel9cis_flush_ipv4_route
|
|
- not system_is_container
|
|
|
|
- name: Sysctl flush ipv6 route table
|
|
ansible.posix.sysctl:
|
|
name: net.ipv6.route.flush
|
|
value: '1'
|
|
sysctl_set: true
|
|
when:
|
|
- rhel9cis_flush_ipv6_route
|
|
- not system_is_container
|
|
|
|
- name: Systemd restart tmp.mount
|
|
ansible.builtin.systemd:
|
|
name: tmp.mount
|
|
daemon_reload: true
|
|
enabled: true
|
|
masked: false
|
|
state: reloaded
|
|
|
|
- name: Remount tmp
|
|
ansible.posix.mount:
|
|
path: /tmp
|
|
state: remounted
|
|
|
|
- name: Restart firewalld
|
|
ansible.builtin.systemd:
|
|
name: firewalld
|
|
state: restarted
|
|
|
|
- name: Restart sshd
|
|
ansible.builtin.systemd:
|
|
name: sshd
|
|
state: restarted
|
|
|
|
- name: Restart postfix
|
|
ansible.builtin.systemd:
|
|
name: postfix
|
|
state: restarted
|
|
|
|
- name: Reload dconf
|
|
ansible.builtin.shell: dconf update
|
|
|
|
- name: Grub2cfg
|
|
ansible.builtin.shell: "grub2-mkconfig -o /boot/grub2/grub.cfg"
|
|
ignore_errors: true # noqa ignore-errors
|
|
|
|
- name: Restart rsyslog
|
|
ansible.builtin.systemd:
|
|
name: rsyslog
|
|
state: restarted
|
|
|
|
- name: Restart journald
|
|
ansible.builtin.systemd:
|
|
name: systemd-journald
|
|
state: restarted
|
|
|
|
- name: Restart systemd_journal_upload
|
|
ansible.builtin.systemd:
|
|
name: systemd-journal-upload
|
|
state: restarted
|
|
|
|
- name: Systemd daemon reload
|
|
ansible.builtin.systemd:
|
|
daemon-reload: true
|
|
|
|
- name: Apply_authselect
|
|
ansible.builtin.shell: authselect apply-changes
|
|
when: not rhel9cis_rule_5_4_2
|
|
|
|
- name: Apply_authselect
|
|
ansible.builtin.shell: "authselect select custom/{{ rhel9cis_authselect['custom_profile_name'] }} {{ rhel9cis_authselect['options'] }} --force --backup=rhel9cis_commit_{{ ansible_date_time.epoch}}"
|
|
when: rhel9cis_rule_5_4_2
|
|
## Auditd tasks note order for handlers to run
|
|
|
|
- name: Auditd immutable check
|
|
ansible.builtin.shell: grep -c "^-e 2" /etc/audit/rules.d/99_auditd.rules
|
|
changed_when: false
|
|
register: auditd_immutable_check
|
|
|
|
- name: Audit immutable fact
|
|
ansible.builtin.debug:
|
|
msg: "Reboot required for auditd to apply new rules as immutable set"
|
|
notify: Change_requires_reboot
|
|
when:
|
|
- auditd_immutable_check.stdout == '1'
|
|
|
|
- name: Stop auditd process
|
|
ansible.builtin.shell: systemctl kill auditd
|
|
listen: Restart auditd
|
|
|
|
- name: Start auditd process
|
|
ansible.builtin.systemd_service:
|
|
name: auditd
|
|
state: started
|
|
listen: Restart auditd
|
|
|
|
- name: Change_requires_reboot
|
|
ansible.builtin.set_fact:
|
|
change_requires_reboot: true
|