From 1babb21f19b9809fb28c5c9f82651f5fe218722b Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Fri, 23 Dec 2022 17:33:43 +0100 Subject: [PATCH] Optionally change the tmpreaper behaviour. --- defaults/main.yml | 3 ++- meta/main.yml | 9 +++++---- tasks/tmpreaper.yml | 33 +++++++++++++++++++-------------- 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/defaults/main.yml b/defaults/main.yml index c6f87e2..1171506 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -132,7 +132,8 @@ nfs_server_ganesha_exports: [] # - hostN # tmpreaper -tmpreaper_install: False +tmpreaper_install: false +mpreaper_use_ctime: true tmpreaper_protect_extra: '' tmpreaper_dirs: '/tmp/.' tmpreaper_extra_dirs: '' diff --git a/meta/main.yml b/meta/main.yml index bca318a..0aa20a6 100644 --- a/meta/main.yml +++ b/meta/main.yml @@ -1,13 +1,14 @@ galaxy_info: author: Andrea Dell'Amico - description: Systems Architect + description: Perform some low level system configuration company: ISTI-CNR + role_name: basic_system_setup issue_tracker_url: https://redmine-s2i2s.isti.cnr.it/projects/provisioning license: EUPL 1.2+ - min_ansible_version: 2.8 + min_ansible_version: "2.9" # To view available platforms and versions (or releases), visit: # https://galaxy.ansible.com/api/v1/platforms/ @@ -18,8 +19,8 @@ galaxy_info: - bionic - name: EL versions: - - 7 - - 8 + - "7" + - "8" galaxy_tags: - os-setup diff --git a/tasks/tmpreaper.yml b/tasks/tmpreaper.yml index e4775d7..ccda12c 100644 --- a/tasks/tmpreaper.yml +++ b/tasks/tmpreaper.yml @@ -1,26 +1,31 @@ --- - name: Install tmpreaper on Debian/Ubuntu - block: - - name: Install tmpreaper - apt: pkg=tmpreaper state=latest cache_valid_time=1800 - - - name: Install the tmpreaper configuration - template: src=tmpreaper.conf.j2 dest=/etc/tmpreaper.conf owner=root group=root mode=0444 - when: - tmpreaper_install - ansible_distribution_file_variety == "Debian" tags: tmpreaper + block: + - name: Install tmpreaper + ansible.builtin.apt: pkg=tmpreaper state=latest cache_valid_time=1800 + + - name: Change the date check criteria from ctime to mtime + ansible.builtin.lineinfile: + path: /etc/cron.daily/tmpreaper + regexp: "^ --ctime \" + line: "^ --mtime \" + when: not mpreaper_use_ctime + + - name: Install the tmpreaper configuration + ansible.builtin.template: src=tmpreaper.conf.j2 dest=/etc/tmpreaper.conf owner=root group=root mode=0444 - name: Remove tmpreaper on Debian/Ubuntu - block: - - name: Remove the tmpreaper package - apt: pkg=tmpreaper state=absent - - - name: Remove the tmpreaper configuration - file: dest=/etc/tmpreaper.conf state=absent - when: - not tmpreaper_install - ansible_distribution_file_variety == "Debian" tags: tmpreaper + block: + - name: Remove the tmpreaper package + ansible.builtin.apt: pkg=tmpreaper state=absent + + - name: Remove the tmpreaper configuration + ansible.builtin.file: dest=/etc/tmpreaper.conf state=absent