From 63ca3a71a86c19ceb21a15d11fd6fe140093a3b5 Mon Sep 17 00:00:00 2001 From: Andrea Dell'Amico Date: Wed, 11 Dec 2019 11:57:55 +0100 Subject: [PATCH] Install and configure tmpreaper if required, on Debian/Ubuntu. --- .../deb-ubuntu-common/meta/main.yml | 1 + library/roles/tmpreaper/defaults/main.yml | 8 ++++++ library/roles/tmpreaper/tasks/main.yml | 27 +++++++++++++++++++ .../tmpreaper/templates/tmpreaper.conf.j2 | 7 +++++ 4 files changed, 43 insertions(+) create mode 100644 library/roles/tmpreaper/defaults/main.yml create mode 100644 library/roles/tmpreaper/tasks/main.yml create mode 100644 library/roles/tmpreaper/templates/tmpreaper.conf.j2 diff --git a/library/bootstrap-roles/deb-ubuntu-common/meta/main.yml b/library/bootstrap-roles/deb-ubuntu-common/meta/main.yml index fea9d90c..91308486 100644 --- a/library/bootstrap-roles/deb-ubuntu-common/meta/main.yml +++ b/library/bootstrap-roles/deb-ubuntu-common/meta/main.yml @@ -2,6 +2,7 @@ dependencies: - role: '../../library/roles/ubuntu-deb-general' - { role: '../../library/roles/cloud-init', when: ansible_product_name == "oVirt Node" } + - role: '../../library/roles/tmpreaper' - role: '../../library/roles/iptables' - { role: '../../library/roles/data_disk', when: additional_disks is defined and additional_disks } - role: '../../library/roles/sshd_config' diff --git a/library/roles/tmpreaper/defaults/main.yml b/library/roles/tmpreaper/defaults/main.yml new file mode 100644 index 00000000..c6f4272f --- /dev/null +++ b/library/roles/tmpreaper/defaults/main.yml @@ -0,0 +1,8 @@ +--- +tmpreaper_install: False +tmpreaper_protect_extra: '' +tmpreaper_dirs: '/tmp/.' +tmpreaper_delay: '256' +tmpreaper_additional_options: '' +tmpreaper_time: '7d' + diff --git a/library/roles/tmpreaper/tasks/main.yml b/library/roles/tmpreaper/tasks/main.yml new file mode 100644 index 00000000..8c0d74a1 --- /dev/null +++ b/library/roles/tmpreaper/tasks/main.yml @@ -0,0 +1,27 @@ +--- +- 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 | bool + - ansible_distribution_file_variety == "Debian" + tags: tmpreaper + +- 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 | bool + - ansible_distribution_file_variety == "Debian" + tags: tmpreaper + diff --git a/library/roles/tmpreaper/templates/tmpreaper.conf.j2 b/library/roles/tmpreaper/templates/tmpreaper.conf.j2 new file mode 100644 index 00000000..82569e0e --- /dev/null +++ b/library/roles/tmpreaper/templates/tmpreaper.conf.j2 @@ -0,0 +1,7 @@ +# +TMPREAPER_TIME={{ tmpreaper_time }} +TMPREAPER_PROTECT_EXTRA='{{ tmpreaper_protect_extra }}' +TMPREAPER_DIRS='{{ tmpreaper_dirs }}' +TMPREAPER_DELAY='{{ tmpreaper_delay }}' +TMPREAPER_ADDITIONALOPTIONS='{{ tmpreaper_additional_options }}' +