Compare commits

..

11 Commits
v1.0 ... master

8 changed files with 213 additions and 6 deletions

24
CHANGELOG.md Normal file
View File

@ -0,0 +1,24 @@
DEPRECATED, see README.md
## v1.1.2
### Enhancements
* Remove Debian installer log files after 4 weeks.
## v1.1.1
### Features
* Add `apt-transport-https` package.
* Ensure to install `less` package on Debian.
## v1.1
### Features
* Configure and update mlocate/updatedb.
* Remove some unwanted packages.
* Manage default editor.
## v1.0
### Features
* Only install new packages from *utils* section.

View File

@ -1,27 +1,46 @@
# PKG_UTILS # NO LONGER SUPPORTED, please take a look to [apt_install][debops apt_install role] [resources][debops resources role] roles!
1. [Overview](#overview) 1. [Overview](#overview)
2. [Role Variables](#role-variables) 2. [Role Variables](#role-variables)
* [OS Specific Variables](#os-specific-variables) * [OS Specific Variables](#os-specific-variables)
3. [Example Playbook](#example-playbook) 3. [Example Playbook](#example-playbook)
4. [Packages](#packages) 4. [Packages](#packages)
5. [Development](#development) * [New Packages](#new-packages)
5. [License](#license) * [Unwanted Packages](#unwanted-packages)
6. [Author Information](#author-information) 5. [Configuration](#configuration)
* [Default Editor](#default-editor)
* [Updatedb](#updatedb)
6. [Development](#development)
7. [License](#license)
8. [Author Information](#author-information)
## Overview ## Overview
Manage some packages from 'utils' section (Apt). Manage some packages installation and configuration from 'utils' section (Apt).
## Role Variables ## Role Variables
* **pkg_utils_new_state**: State of new pkg_utils packages [default: `latest`]. * **pkg_utils_new_state**: State of new pkg_utils packages [default: `installed`].
* **pkg_utils_old_manage**: If this role should manage unwanted packages [default: `true`].
* **pkg_utils_old_state**: State of useless pkg_utils [default: `absent`].
* **pkg_utils_default_editor_name**: The default editor name [default: `vim.nox`].
* **pkg_utils_default_editor_path**: The default editor path [default: `/usr/bin/vim.nox`].
* **pkg_utils_default_editor_manage**: If the default editor should be managed [default: `true`].
* **pkg_utils_updatedb_conf_path**: Configuration file for **updatedb** [default: `/etc/updatedb.conf`].
* **pkg_utils_updatedb_conf_tpl**: Template used to generate the previous config file [default: `etc/updatedb.conf.j2`].
* **pkg_utils_updatedb_prune_bind_mounts**: Whether or not bind mounts are scanned [default: `true`].
* **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 ### OS Specific Variables
Please see default value by Operating System file in [vars][vars directory] directory. Please see default value by Operating System file in [vars][vars directory] directory.
* **pkg_utils_new_list**: The list of packages to install to provide `pkg_utils`. * **pkg_utils_new_list**: The list of packages to install to provide `pkg_utils`.
* **pkg_utils_old_list**: The list of unwanted packages to remove.
## Example Playbook ## Example Playbook
@ -33,9 +52,28 @@ Please see default value by Operating System file in [vars][vars directory] dire
- role: ipr-cnrs.pkg_utils - role: ipr-cnrs.pkg_utils
``` ```
* Don't remove any packages:
``` yml
- hosts: serverXYZ
roles:
- role: ipr-cnrs.pkg_utils
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 ## Packages
### New Packages ### New Packages
* **apt-transport-https**: https download transport for APT.
* **bdsmainutils**: Collection of more utilities from FreeBSD. * **bdsmainutils**: Collection of more utilities from FreeBSD.
* **colordiff**: Tool to colorize 'diff' output. * **colordiff**: Tool to colorize 'diff' output.
* **cpio**: GNU cpio; a program to manage archives of files. * **cpio**: GNU cpio; a program to manage archives of files.
@ -69,6 +107,28 @@ sudo multitail -s 2 /var/log/auth.log /var/log/syslog /var/log/mail.log
* **zip**: Archiver for .zip files. * **zip**: Archiver for .zip files.
* **zsh**: Shell with lots of features. * **zsh**: Shell with lots of features.
### Unwanted Packages
* **vim-tiny**: Compact version of vim editor.
## Configuration
### Default Editor
* Set the *pkg_utils_default_editor.name* var [default: `vim.nox`] as the default editor on the system.
### Updatedb
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 ## 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… 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…
@ -93,3 +153,5 @@ Jérémy Gardais
[pkg_utils github]: https://github.com/ipr-cnrs/pkg_utils [pkg_utils github]: https://github.com/ipr-cnrs/pkg_utils
[wtfpl website]: http://www.wtfpl.net/about/ [wtfpl website]: http://www.wtfpl.net/about/
[ipr website]: https://ipr.univ-rennes1.fr/ [ipr website]: https://ipr.univ-rennes1.fr/
[debops apt_install role]: https://docs.debops.org/en/master/ansible/roles/debops.apt_install/index.html
[debops resources role]: https://docs.debops.org/en/master/ansible/roles/debops.resources/index.html

View File

@ -4,3 +4,62 @@
# packages # packages
pkg_utils_new_state: 'installed' pkg_utils_new_state: 'installed'
pkg_utils_old_manage: true
pkg_utils_old_state: 'absent'
# configuration
pkg_utils_default_editor_manage: true
pkg_utils_default_editor_name: 'vim.nox'
pkg_utils_default_editor_path: '/usr/bin/vim.nox'
pkg_utils_updatedb_conf_path: '/etc/updatedb.conf'
pkg_utils_updatedb_conf_tpl: 'etc/updatedb.conf.j2'
pkg_utils_updatedb_prune_bind_mounts: true
pkg_utils_updatedb_prunenames:
- .bzr
- .git
- .hg
- .svn
pkg_utils_updatedb_prunepaths:
- /media
- /mnt
- /tmp
- /var/lib/ceph
- /var/spool
pkg_utils_updatedb_prunefs:
- 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: true
pkg_utils_purge_installer_age: '4w'

3
handlers/main.yml Normal file
View File

@ -0,0 +1,3 @@
---
- name: update mlocate db
command: updatedb

View File

@ -16,4 +16,52 @@
with_items: with_items:
- '{{ pkg_utils_new_list }}' - '{{ pkg_utils_new_list }}'
- name: Remove useless packages
apt:
name: '{{ item }}'
state: '{{ pkg_utils_old_state }}'
with_items:
- '{{ pkg_utils_old_list }}'
when: pkg_utils_old_manage
# }}}
# configuration {{{
- name: CONFIG {{ pkg_utils_default_editor_name }} as default editor
alternatives:
name: editor
path: '{{ pkg_utils_default_editor_path }}'
priority: 80
when: pkg_utils_default_editor_manage
- name: CONFIG updatedb
template:
src: '{{ pkg_utils_updatedb_conf_tpl }}'
dest: '{{ pkg_utils_updatedb_conf_path }}'
owner: root
group: root
mode: 0644
backup: true
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
# }}} # }}}

0
templates/README.md Normal file
View File

View File

@ -0,0 +1,6 @@
# {{ ansible_managed }}
PRUNE_BIND_MOUNTS="{{ 'yes' if pkg_utils_updatedb_prune_bind_mounts else 'no' }}"
PRUNENAMES="{{ pkg_utils_updatedb_prunenames | join(' ') }}"
PRUNEPATHS="{{ pkg_utils_updatedb_prunepaths | join(' ') }}"
PRUNEFS="{{ pkg_utils_updatedb_prunefs | join(' ') }}"

View File

@ -3,11 +3,13 @@
# vars file for Debian-based distros # vars file for Debian-based distros
pkg_utils_new_list: pkg_utils_new_list:
- 'apt-transport-https'
- 'bsdmainutils' - 'bsdmainutils'
- 'colordiff' - 'colordiff'
- 'cpio' - 'cpio'
- 'debian-goodies' - 'debian-goodies'
- 'htop' - 'htop'
- 'less'
- 'lsof' - 'lsof'
- 'lzip' - 'lzip'
- 'mlocate' - 'mlocate'
@ -22,3 +24,6 @@ pkg_utils_new_list:
- 'vim-scripts' - 'vim-scripts'
- 'zip' - 'zip'
- 'zsh' - 'zsh'
pkg_utils_old_list:
- 'vim-tiny'