92 lines
2.4 KiB
YAML
92 lines
2.4 KiB
YAML
---
|
|
# Tasks to clean the Red Hat Subscription Manager logs.
|
|
- name: "Cleaning the Red Hat Subscription Manager logs."
|
|
ansible.builtin.file:
|
|
path: /var/log/rhsm
|
|
state: absent
|
|
when: ansible_distribution == 'RedHat'
|
|
|
|
# Tasks to clean the audit logs.
|
|
- name: "Cleaning the audit logs."
|
|
ansible.builtin.file:
|
|
path: "{{ item }}"
|
|
state: absent
|
|
loop:
|
|
- /var/log/audit/audit.log
|
|
- /var/log/btmp
|
|
- /var/log/boot.log
|
|
- /var/log/cron
|
|
- /var/log/dnf.log
|
|
- /var/log/lastlog
|
|
- /var/log/maillog
|
|
- /var/log/messages
|
|
- /var/log/secure
|
|
- /var/log/wtmp
|
|
- /var/log/yum.log
|
|
|
|
# Tasks to clean the persistent udev rules.
|
|
- name: "Cleaning persistent udev rules."
|
|
ansible.builtin.file:
|
|
path: /etc/udev/rules.d/70-persistent-net.rules
|
|
state: absent
|
|
|
|
# Tasks to find the /tmp directories.
|
|
- name: "Finding the /tmp directories."
|
|
ansible.builtin.find:
|
|
paths:
|
|
- /tmp
|
|
- /var/tmp
|
|
file_type: any
|
|
register: find_tmp_directories
|
|
|
|
# Tasks to clean the /tmp directories.
|
|
- name: "Cleaning the /tmp directories."
|
|
ansible.builtin.file:
|
|
path: "{{ item.path }}"
|
|
state: absent
|
|
loop: "{{ find_tmp_directories.files }}"
|
|
loop_control:
|
|
label: "{{ item.path }}"
|
|
|
|
# Tasks to find the SSH host keys.
|
|
- name: "Finding the SSH host keys."
|
|
ansible.builtin.find:
|
|
paths: /etc/ssh
|
|
patterns: 'ssh_host_*'
|
|
register: find_ssh_host_keys
|
|
|
|
# Tasks to clean the SSH host keys.
|
|
- name: "Cleaning the SSH host keys."
|
|
ansible.builtin.file:
|
|
path: "{{ item.path }}"
|
|
state: absent
|
|
loop: "{{ find_ssh_host_keys.files }}"
|
|
loop_control:
|
|
label: "{{ item.path }}"
|
|
|
|
# Tasks to clean the machine-id.
|
|
- name: "Emptying the /etc/machine-id."
|
|
community.general.filesize:
|
|
path: /etc/machine-id
|
|
size: 0
|
|
|
|
- name: "Cleaning the machine-id."
|
|
block:
|
|
- name: "Removing /var/lib/dbus/machine-id."
|
|
ansible.builtin.file:
|
|
path: /var/lib/dbus/machine-id
|
|
state: absent
|
|
- name: "Creating a symbolic link to /etc/machine-id."
|
|
ansible.builtin.file:
|
|
src: /etc/machine-id
|
|
dest: /var/lib/dbus/machine-id
|
|
state: link
|
|
when: ansible_distribution_major_version | int <= 8
|
|
|
|
# Tasks to clean the shell history.
|
|
- name: "Cleaning the shell history."
|
|
block:
|
|
- name: "Cleaning the shell history."
|
|
ansible.builtin.file:
|
|
path: "{{ ansible_env.HOME }}/.bash_history"
|
|
state: absent |