robertdebock / ansible-role-logrotate Goto Github PK
View Code? Open in Web Editor NEWInstall and configure logrotate on your system.
Home Page: https://robertdebock.nl/
License: Apache License 2.0
Install and configure logrotate on your system.
Home Page: https://robertdebock.nl/
License: Apache License 2.0
Hello,
Great role.
Is it possible to add the "state: absent" key like this:
logrotate_entries:
- name: haproxy
state: absent ### That
path: "/var/log/haproxy.log"
compress: true
copytruncate: true
delaycompress: false
missingok: true
notifempty: true
dateext: true
dateformat: "-%d-%m-%Y"
This could trigger the deletion of logrotate deployer files with the role
What do you think?
Addition of delaycompress option
Delay compress is useful when you regularly read log files.
It is also a must when daemons may not switch over from old to new logs quickly
Add support for dateext
and dateformat
to configure generated log file.
To configure the generated log filename.
add the dateyesterday feature of logrotate to enable rotated logs at midnight to have corresponding date
Why is this feature required?
I rotate logs at midnight and the rotated files have dates of the time they are created rather than the actual time of the contents
Add any other context about the feature request here.
Please consider sponsoring me.
Running this role produces the following error on Debian 10:
fatal: [node001]: FAILED! => { "msg": "The task includes an option with an undefined variable. The error was: 'logrotate_service' is undefined\n\nThe error appears to be in '/mnt/nfs/ansible/roles/robertdebock.logrotate/tasks/main.yml': line 29, column 3, but may\nbe elsewhere in the file depending on the exact syntax problem.\n\nThe offending line appears to be:\n\n\n- name: start and enable logrotate\n ^ here\n" }
Add ability for a user of this role to define a prerotate script that is run prior to the logrotation process.
In the same way that logrotate provides the ability to run a script after a log has been rotated, it also provides a means by which a script can be run in advance. This functionality is used in my case to push log files off to an s3 bucket before rotation occurs.
prerotate is define in the manpage, here https://linux.die.net/man/8/logrotate
prerotate/endscript
The lines between prerotate and endscript (both of which must appear on lines by themselves) are executed (using /bin/sh) before the log file is rotated and only if the log will actually be rotated. These directives may only appear inside a log file definition. Normally, the absolute path to the log file is passed as first argument to the script. If sharedscripts is specified, whole pattern is passed to the script. See also postrotate. See sharedscripts and nosharedscripts for error handling.
logrotate has a maxsize feature.
It helps handling logs file that sometime grew unexpectly.
Hi and thank for this Ansible role.
I wanted to setup a logrotate that always keep logs with the value -1
but it is denied by the role : I got the following error message :
TASK [logrotate : assert | Test if logrotate_keep is set correctly] **************************************************************************************************************************
fatal: [192.168.1.21 -> localhost]: FAILED! => {"assertion": "logrotate_keep >= 0", "changed": false, "evaluated_to": false, "msg": "Assertion failed"}
The man of logrotate says :
❯ man logrotate | grep '\-1'
[...] If count is -1, old logs are not removed at all, except they are affected by maxage (use with caution, may waste performance and disk space). Default is 0.
May be the test should be logrotate_keep >= -1
?
Thanks again.
Best regards.
The excess lines generated by the template is very annoying and unnecessary
It looks like the blank lines were added to make the template more readable for easier updates
Please consider sponsoring me.
It should be possible to specify a list for the path
and postrotate
variable in a logrotate entry, instead of just a single string.
It is perfectly fine in logrotate to give multiple postrotate
commands and paths
to files that should be rotated, especially when one wants to simply apply the same ruleset on multiple paths.
Since it is currently only possible to specify a single path in a logrotate entry, you would need to duplicate the same entry over and over where just the logfile changes to achieve this same behaviour, which seems unnecessary.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.