SUSE based distributions do not use Cron, but instead a systemd
timer for running logrotate on a schedule.
As this timer is enabled through a systemd preset, skip the state
completely.
Signed-off-by: Georg Pfuetzenreuter <georg.pfuetzenreuter@suse.com>
* https://freenode.logbot.info/saltstack-formulas/20200506#c3811885-c3812572
* Avoid `defaults.merge`
* Send template values by `context`, to avoid:
```python
ID: logrotate-config
Function: file.managed
Name: /etc/logrotate.conf
Result: False
Comment: An exception occurred in this state: Traceback (most recent call last):
File "/var/tmp/.root_08c4d3_salt/pyall/salt/utils/templates.py", line 394, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/var/tmp/.root_08c4d3_salt/pyall/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/var/tmp/.root_08c4d3_salt/pyall/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/var/tmp/.root_08c4d3_salt/pyall/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "<template>", line 1, in top-level template code
File "/var/tmp/.root_08c4d3_salt/pyall/salt/utils/jinja.py", line 193, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: logrotate/map.jinja
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/var/tmp/.root_08c4d3_salt/pyall/salt/state.py", line 1981, in call
**cdata['kwargs'])
File "/var/tmp/.root_08c4d3_salt/pyall/salt/loader.py", line 1977, in wrapper
return f(*args, **kwargs)
File "/var/tmp/.root_08c4d3_salt/pyall/salt/states/file.py", line 3037, in managed
**kwargs
File "/var/tmp/.root_08c4d3_salt/pyall/salt/modules/file.py", line 4846, in check_managed_changes
**kwargs)
File "/var/tmp/.root_08c4d3_salt/pyall/salt/modules/file.py", line 4287, in get_managed
**kwargs)
File "/var/tmp/.root_08c4d3_salt/pyall/salt/utils/templates.py", line 169, in render_tmpl
output = render_str(tmplstr, context, tmplpath)
File "/var/tmp/.root_08c4d3_salt/pyall/salt/utils/templates.py", line 443, in render_jinja_tmpl
trace=tracestr)
salt.exceptions.SaltRenderError: Jinja error: logrotate/map.jinja
Traceback (most recent call last):
File "/var/tmp/.root_08c4d3_salt/pyall/salt/utils/templates.py", line 394, in render_jinja_tmpl
output = template.render(**decoded_context)
File "/var/tmp/.root_08c4d3_salt/pyall/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/var/tmp/.root_08c4d3_salt/pyall/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/var/tmp/.root_08c4d3_salt/pyall/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "<template>", line 1, in top-level template code
File "/var/tmp/.root_08c4d3_salt/pyall/salt/utils/jinja.py", line 193, in get_source
raise TemplateNotFound(template)
jinja2.exceptions.TemplateNotFound: logrotate/map.jinja
; line 1
---
{%- from "logrotate/map.jinja" import logrotate with context -%} <======================
{%- set config = salt['pillar.get']('logrotate:default_config', logrotate.default_config) -%}
{%- set processed_parameters = [] -%}
{%- macro set_parameter(parameter, default=None) -%}
[...]
```
* Semi-automated using `ssf-formula` (v0.5.0)
* Fix errors shown below:
```bash
logrotate-formula$ $(grep "\- yamllint" .travis.yml | sed -e "s:^\s\+-\s\(.*\):\1:")
./logrotate/osmap.yaml
1:1 warning missing document start "---" (document-start)
./logrotate/osfamilymap.yaml
1:1 warning missing document start "---" (document-start)
7:15 warning truthy value should be one of [false, true] (truthy)
12:14 warning truthy value should be one of [false, true] (truthy)
14:23 warning truthy value should be one of [false, true] (truthy)
16:14 warning truthy value should be one of [false, true] (truthy)
24:14 warning truthy value should be one of [false, true] (truthy)
./logrotate/defaults.yaml
4:1 warning missing document start "---" (document-start)
11:23 warning truthy value should be one of [false, true] (truthy)
13:13 warning truthy value should be one of [false, true] (truthy)
15:13 warning truthy value should be one of [false, true] (truthy)
16:1 error too many blank lines (1 > 0) (empty-lines)
pillar.example
3:1 warning missing document start "---" (document-start)
5:4 warning missing starting space in comment (comments)
6:6 warning missing starting space in comment (comments)
6:5 warning comment not indented like content (comments-indentation)
7:6 warning missing starting space in comment (comments)
9:13 warning truthy value should be one of [false, true] (truthy)
11:13 warning truthy value should be one of [false, true] (truthy)
12:15 warning truthy value should be one of [false, true] (truthy)
13:14 warning truthy value should be one of [false, true] (truthy)
26:12 error trailing spaces (trailing-spaces)
48:12 error too many spaces after hyphen (hyphens)
69:1 error too many blank lines (1 > 0) (empty-lines)
```
The iteritems dictionary method has been removed in Python 3 and using
items() is typically no problem in our case due to the fact that
dictionaries are rather small.
This fixes#15