From 52f4acd9a319d1c6a810f6dcf54c3f2f1bc0b258 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gardais=20J=C3=A9r=C3=A9my?= Date: Thu, 4 Jan 2018 12:16:04 +0100 Subject: [PATCH] Remove Debian installer log files after 4 weeks. --- CHANGELOG.md | 5 +++++ README.md | 17 +++++++++++++++++ defaults/main.yml | 4 ++++ tasks/main.yml | 22 +++++++++++++++++++++- 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9b98176..ee24a59 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,4 +1,9 @@ +## v1.1.2 + +### Enhancements +* Remove Debian installer log files after 4 weeks. + ## v1.1.1 ### Features diff --git a/README.md b/README.md index 9ab55e6..6c9f282 100644 --- a/README.md +++ b/README.md @@ -32,6 +32,8 @@ Manage some packages installation and configuration from 'utils' section (Apt). * **pkg_utils_updatedb_prunenames** : A list of directory names (without paths) which should not be scanned [default: `[.bzr, .git, .hg, .svn]`]. * **pkg_utils_updatedb_prunepaths** : A list of path names of directories which should not be scanned [default: `[/media, /mnt, /tmp, /var/lib/ceph, /var/spool]`]. * **pkg_utils_updatedb_prunefs** : A list of file system types (as used in /etc/mtab) which should not be scanned [default: `[afs, autofs, binfmt_misc, ceph, cifs, coda, curlftpfs, devfs, devpts, devtmpfs, ecryptfs, fuse.glusterfs, fuse.sshfs, fusesmb, iso9660, lustre, lustre_lite, mfs, ncpfs, NFS, nfs, nfs4, proc, rpc_pipefs, shfs, smbfs, sysfs, ftpfs, tmpfs, udf, usbfs]`]. +* **pkg_utils_purge_installer_log** : If the installer log files should be removed [default : `true`]. +* **pkg_utils_purge_installer_age** : Maximum age of the installer log files before removing [default : `4w`]. ### OS Specific Variables @@ -59,6 +61,15 @@ Please see default value by Operating System file in [vars][vars directory] dire pkg_utils_old_manage: false ``` +* Don't remove installer log files : + +``` yml +- hosts: serverXYZ + roles: + - role: ipr-cnrs.pkg_utils + pkg_utils_purge_installer_log: false +``` + ## Packages ### New Packages @@ -112,6 +123,12 @@ Based on the [Oefenweb module][oefenweb ansible updatedb], thanks ! * Set the default configuration file for *updatedb* and update the database for Mlocate with an handler. * Ensure to not scan some path, directories and filesystem. +### Installer log files + +* Debian installer log all the installation in `/var/log/installer`. +* If a system is stable, you should removed these log files. +* After 4 weeks (by default) this role will remove it. + ## Development This source code comes from our [Gogs instance][pkg_utils source] and the [Github repo][pkg_utils github] exist just to be able to send the role to Ansible Galaxy… diff --git a/defaults/main.yml b/defaults/main.yml index 6775c62..c8afa61 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -59,3 +59,7 @@ pkg_utils_updatedb_prunefs: - tmpfs - udf - usbfs + +pkg_utils_purge_installer_log: true +pkg_utils_purge_installer_age: '4w' + diff --git a/tasks/main.yml b/tasks/main.yml index dda4d9d..dbdd7df 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -26,7 +26,7 @@ # }}} - # configuration {{{ +# configuration {{{ - name: CONFIG {{ pkg_utils_default_editor_name }} as default editor alternatives: name: editor @@ -45,3 +45,23 @@ notify: update mlocate db # }}} + +# purge log {{{ + +- name: Find /var/log/installer + find: + path: /var/log/ + patterns: 'installer' + age: '{{ pkg_utils_purge_installer_age }}' + register: findresult + when: pkg_utils_purge_installer_log + +- name: Remove /var/log/installer older than {{ pkg_utils_purge_installer_age }} + file: + path: "{{ item.path }}" + state: absent + recurse: yes + with_items: '{{ findresult.files }}' + when: pkg_utils_purge_installer_log + +# }}}