system-config/playbooks/roles/logrotate/README.rst
Ian Wienand 1e2ea795c2
logrotate: don't use filename to generate config file
I noticed on our hosts some logrotate files named '*.1234.conf' --
these are coming from callers of logrotate role specifying
'/var/log/program/*.log', where the '*' is turning into a literal
filename.  I didn't really consider this case.

Having a file-name starting with '*' may technically be fine, but is a
bad idea for everyone's sanity and it's potential to foot-gun some
sort of operation that suddenly wipes out a lot more than you wanted
to.

Let's just use the hash of the name to be unambiguous and still
idempotent.  Make it more git-ish by using the same 7 digits as a
default short-hash.

Change-Id: I13d376f85a25a7b8c3a0bc0dcbabd916e8a9774a
2023-02-14 07:03:17 +11:00

59 lines
1.6 KiB
ReStructuredText

Add log rotation file
.. note:: This role does not manage the ``logrotate`` package or
configuration directory, and it is assumed to be installed
and available.
This role installs a log rotation file in ``/etc/logrotate.d/`` for a
given file.
For information on the directives see ``logrotate.conf(5)``. This is
not an exhaustive list of directives (contributions are welcome).
** Role Variables **
.. zuul:rolevar:: logrotate_file_name
The full path to log file on disk to rotate. May be a wild-card;
e.g. ``/var/log/progname/*.log``.
.. zuul:rolevar:: logrotate_config_file_name
:default: Unique name based on the hash of :zuul:rolevar::`logrotate.logrotate_file_name`
The name of the configuration file in ``/etc/logrotate.d``. If
this is specified, it is up to the caller to ensure it is unique
across all calls of this role.
.. zuul:rolevar:: logrotate_compress
:default: yes
.. zuul:rolevar:: logrotate_copytruncate
:default: yes
.. zuul:rolevar:: logrotate_delaycompress
:default: yes
.. zuul:rolevar:: logrotate_missingok
:default: yes
.. zuul:rolevar:: logrotate_rotate
:default: 7
.. zuul:rolevar:: logrotate_frequency
:default: daily
One of ``hourly``, ``daily``, ``weekly``, ``monthly``, ``yearly``
or ``size``.
If choosing ``size``, :zuul:rolevar::`logrotate.logrotate_size` must
be specified
.. zuul:rolevar:: logrotate_size
:default: None
Size; e.g. 100K, 10M, 1G. Only when
:zuul:rolevar::`logrotate.logrotate_frequency` is ``size``.
.. zuul:rolevar:: logrotate_notifempty
:default: yes