From 4d3b35a34db5cc9b560eb60a96682cba552340b7 Mon Sep 17 00:00:00 2001 From: David Galloway Date: Thu, 18 Feb 2021 13:22:53 -0500 Subject: [PATCH] ansible: Install tmpreaper/tmpwatch and clean /tmp daily Signed-off-by: David Galloway --- ansible/examples/slave.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/ansible/examples/slave.yml b/ansible/examples/slave.yml index 47b53a01..7d340560 100644 --- a/ansible/examples/slave.yml +++ b/ansible/examples/slave.yml @@ -55,6 +55,8 @@ - doxygen - ditaa - ant + - tmpreaper + tmp_cleaner_name: tmpreaper when: ansible_os_family == "Debian" # Libvirt DEBs (Bionic and older) @@ -145,6 +147,8 @@ - rpmdevtools - openssl-devel - libffi-devel + - tmpwatch + tmp_cleaner_name: tmpwatch when: ansible_os_family == "RedHat" # Libvirt RPMs @@ -627,6 +631,29 @@ line: '%dist .el{{ ansible_distribution_major_version }}' when: ansible_os_family == "RedHat" + ## tmpwatch/tmpreaper TASKS + - name: tmpwatch/tmpreaper Tasks + block: + # In case we're running 'ansible-playbook --tags tmp' + - name: "Make sure {{ tmp_cleaner_name }} is installed" + package: + name: "{{ tmp_cleaner_name }}" + state: present + + - name: Disable tmpreaper cron.daily timer + file: + path: /etc/cron.daily/tmpreaper + state: absent + when: ansible_os_family == "Debian" + + - name: Create tmp cleaning cronjob + cron: + name: "Delete /tmp files that have not been accessed in 30 days" + special_time: daily + job: "{{ tmp_cleaner_name }} 30d /tmp/" + when: permanent|bool + tags: tmp + ## GITCONFIG TASKS - name: Ensure the gitconfig file exists shell: printf "[user]\name=Ceph CI\nemail=ceph-release-team@redhat.com\n" > /home/{{ jenkins_user }}/.gitconfig -- 2.39.5