Allow overriding of default logrotate options
Two variables have been added, rsyslog_client_log_rotate_options and rsyslog_client_log_rotate_scripts, to allow deployers to override and set logrotate config options as they wish. The os_aggregate_storage.j2 template has also been renamed to logrotate.j2 to better fit its purpose. Change-Id: If7538fd2409f3583f22209868f538e01796813c2
This commit is contained in:
parent
aaf9a5d3ab
commit
6c1f43a4cc
|
@ -42,6 +42,19 @@ rsyslog_client_tcp_port: 514
|
|||
rsyslog_client_log_files: []
|
||||
|
||||
rsyslog_client_log_rotate_file: os_aggregate_storage
|
||||
rsyslog_client_log_rotate_options:
|
||||
- copytruncate
|
||||
- weekly
|
||||
- missingok
|
||||
- rotate 14
|
||||
- compress
|
||||
- dateext
|
||||
- maxage 60
|
||||
- notifempty
|
||||
- nocreate
|
||||
rsyslog_client_log_rotate_scripts:
|
||||
- name: postrotate
|
||||
content: "restart rsyslog 2>&1 || true"
|
||||
|
||||
# Set the `rsyslog_client_user_defined_targets` to define specific log targets.
|
||||
# This option will allow you to define multiple log targets with different templates
|
||||
|
|
|
@ -0,0 +1,6 @@
|
|||
---
|
||||
features:
|
||||
- The options of application logrotate configuration files are now configurable.
|
||||
``rsyslog_client_log_rotate_options`` can be used to provide a list of directives, and
|
||||
``rsyslog_client_log_rotate_scripts`` can be used to provide a list of postrotate, prerotate,
|
||||
firstaction, or lastaction scripts.
|
|
@ -54,7 +54,7 @@
|
|||
|
||||
- name: Write log rotate file
|
||||
template:
|
||||
src: "os_aggregate_storage.j2"
|
||||
src: "logrotate.j2"
|
||||
dest: "/etc/logrotate.d/{{ rsyslog_client_log_rotate_file }}"
|
||||
owner: "root"
|
||||
group: "root"
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
{% for log_file in rsyslog_client_all_log_files %}
|
||||
{{ log_file }}
|
||||
{% endfor %}
|
||||
{
|
||||
{% if rsyslog_client_log_rotate_options | length > 0 %}
|
||||
{% for option in rsyslog_client_log_rotate_options %}
|
||||
{{ option }}
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% if rsyslog_client_log_rotate_scripts | length > 0 %}
|
||||
{% for script in rsyslog_client_log_rotate_scripts %}
|
||||
{{ script.name }}
|
||||
{{ script.content }}
|
||||
endscript
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
}
|
|
@ -1,17 +0,0 @@
|
|||
{% for log_file in rsyslog_client_all_log_files %}
|
||||
{{ log_file }}
|
||||
{% endfor %}
|
||||
{
|
||||
copytruncate
|
||||
weekly
|
||||
missingok
|
||||
rotate 14
|
||||
compress
|
||||
dateext
|
||||
maxage 60
|
||||
notifempty
|
||||
nocreate
|
||||
postrotate
|
||||
restart rsyslog 2>&1 || true
|
||||
endscript
|
||||
}
|
|
@ -35,6 +35,17 @@
|
|||
hostname: "logs-01.test.example.com"
|
||||
template: '$template LogglyFormat,"TESTING\n"'
|
||||
action_options: 'LogglyFormat'
|
||||
rsyslog_client_log_rotate_options:
|
||||
- copytruncate
|
||||
- weekly
|
||||
- missingok
|
||||
- rotate 14
|
||||
- compress
|
||||
- dateext
|
||||
- maxage 60
|
||||
- notifempty
|
||||
- nocreate
|
||||
- size 1G
|
||||
post_tasks:
|
||||
- name: Open rsyslog client file
|
||||
slurp:
|
||||
|
@ -69,6 +80,7 @@
|
|||
- "'$ActionQueueFileName test-loggly1' in rsyslog_client_content"
|
||||
- "'/var/log/dmesg' in logrotate_client_content"
|
||||
- "'/var/log/udev' in logrotate_client_content"
|
||||
- "'size 1G' in logrotate_client_content"
|
||||
- "rsyslog_default_file.stat.exists"
|
||||
- "rsyslog_client_file.stat.exists"
|
||||
- "logrotate_file.stat.exists"
|
||||
|
|
Loading…
Reference in New Issue