Open mephi42 opened 6 years ago
I too am hitting similar issues with logrotate.set
. The easiest way to hit it is to leave value
empty (since many options do not take an argument). My work-around is to set setting
to a string containing a space.
I then hit an issue where it's showing changes every time it executes, even when no changes are required. I worked around that by using an - unless: grep -q <regex> <file>
argument.
So my state ends up looking like this:
{%- for file, settings in salt['pillar.get']('logrotate', {}).items() %}
{%- for setting, value in settings['settings'].items() %}
Set {{ setting }} in /etc/logrotate.d/{{ settings.name }}:
logrotate.set:
- key: {{ file }}
- value: {{ setting }}
{%- if value %}
- setting: {{ value }}
{%- else %}
# Here we avoid a "SaltInvocationError: Error: /path/to/logs/*
# includes a dict, and a specific setting inside the dict was not
# declared" error which seems to be Salt issue #48125.
- setting: ' '
{%- endif %}
# logrotate.set always seems to report changes, so this is a
# hacky work-around.
- unless: >-
grep -qE '^\s*{{ setting }}\s*{{ value }}$'
/etc/logrotate.d/{{ settings.name }}
{%- endfor %}
{%- endfor %}
The module seems very buggy in general.
I just ran into this issue on a Debian 9 running 2018.3.2 (Oxygen). Solution for me was to remove the "conf_file" directive.
Since it's been some time since my last PR, I'll see if I can find time to look at this in the coming week.
just ran into this on ubuntu 18.04, with salt 2019.2.0. since this is a bug that breaks documented behaviour (ie: using conf_file
doesn't work right now), it'd be great to get this resolved.
ZD-6406
It's been 2 years since this was reported, any updates from the team on when this might get addressed?
I'd say this state is broken. It could really use some attention.
Using salt-3003-1. Made a tiny mod to the 'conf_file' line and it's spitting out a python3 "KeyError: 'include files'" error. Changed from the default /etc/logrotate.conf to /etc/logrotate.d/blah. Sigh have to rewrite the state now.
Here is the content of my
/etc/logrotate.d/syslog
(it was this way out of the box):Here is my SLS file:
First, a minor issue: if I ask Salt to edit
/etc/logrotate.d/syslog
directly usingconf_file
directive, it will fail withKeyError: include files
. The following patch helped:Now, the main issue:
Error: A setting for a dict was declared, but the configuration line given is not a dict
. I dumped the parsed conf, and apparently the parser did not process multiple file syntax correctly:(Edit) Ugly workaround for now:
Versions Report
v2017.7.3