This commit is contained in:
parent
ccdd304d53
commit
3cc7f89544
13
states/logrotate/config.sls
Normal file
13
states/logrotate/config.sls
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
---
|
||||||
|
{%- from "logrotate/map.jinja" import logrotate with context %}
|
||||||
|
{%- for filename, cfg in logrotate.config.items() %}
|
||||||
|
logrotate-config-{{ filename }}:
|
||||||
|
file.managed:
|
||||||
|
- name: /etc/logrotate.d/{{ filename }}
|
||||||
|
- source: salt://logrotate/templates/config.j2
|
||||||
|
- user: root
|
||||||
|
- group: root
|
||||||
|
- template: jinja
|
||||||
|
- context:
|
||||||
|
cfg: {{ cfg }}
|
||||||
|
{%- endfor %}
|
15
states/logrotate/defaults.yaml
Normal file
15
states/logrotate/defaults.yaml
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
---
|
||||||
|
logrotate:
|
||||||
|
config:
|
||||||
|
salt:
|
||||||
|
files:
|
||||||
|
- /var/log/salt/master
|
||||||
|
- /var/log/salt/minion
|
||||||
|
options:
|
||||||
|
- daily
|
||||||
|
- rotate 6
|
||||||
|
- compress
|
||||||
|
- delaycompress
|
||||||
|
- missingok
|
||||||
|
- notifempty
|
||||||
|
- create 0640 root root
|
4
states/logrotate/init.sls
Normal file
4
states/logrotate/init.sls
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
---
|
||||||
|
include:
|
||||||
|
- .install
|
||||||
|
- .config
|
5
states/logrotate/install.sls
Normal file
5
states/logrotate/install.sls
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
---
|
||||||
|
{%- from "logrotate/map.jinja" import logrotate with context %}
|
||||||
|
logrotate-pkg:
|
||||||
|
pkg.installed:
|
||||||
|
- pkgs: logrotate
|
3
states/logrotate/kernelmap.yaml
Normal file
3
states/logrotate/kernelmap.yaml
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
---
|
||||||
|
Linux:
|
||||||
|
os: "linux"
|
14
states/logrotate/map.jinja
Normal file
14
states/logrotate/map.jinja
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{%- import_yaml "logrotate/defaults.yaml" as default_settings -%}
|
||||||
|
|
||||||
|
{%- import_yaml "logrotate/kernelmap.yaml" as kernelmap -%}
|
||||||
|
{%- import_yaml "logrotate/osarchmap.yaml" as osarchmap -%}
|
||||||
|
|
||||||
|
{%- set defaults = salt['grains.filter_by'](default_settings,
|
||||||
|
default='logrotate',
|
||||||
|
merge=salt['grains.filter_by'](osarchmap, grain='osarch',
|
||||||
|
merge=salt['grains.filter_by'](kernelmap, grain='kernel')
|
||||||
|
)
|
||||||
|
)
|
||||||
|
-%}
|
||||||
|
|
||||||
|
{%- set logrotate = salt['pillar.get']('logrotate', default=defaults, merge=True) -%}
|
24
states/logrotate/osarchmap.yaml
Normal file
24
states/logrotate/osarchmap.yaml
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
---
|
||||||
|
amd64:
|
||||||
|
arch: "amd64"
|
||||||
|
|
||||||
|
x86_64:
|
||||||
|
arch: "amd64"
|
||||||
|
|
||||||
|
386:
|
||||||
|
arch: "386"
|
||||||
|
|
||||||
|
arm64:
|
||||||
|
arch: "arm64"
|
||||||
|
|
||||||
|
aarch64:
|
||||||
|
arch: "arm64"
|
||||||
|
|
||||||
|
armv6l:
|
||||||
|
arch: "armv6"
|
||||||
|
|
||||||
|
armv7l:
|
||||||
|
arch: "armv7"
|
||||||
|
|
||||||
|
armhf:
|
||||||
|
arch: "armv7"
|
10
states/logrotate/templates/config.j2
Normal file
10
states/logrotate/templates/config.j2
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
## {{ salt['pillar.get']('salt_managed', default='Salt Managed') }}
|
||||||
|
{%- from "logrotate/map.jinja" import logrotate with context -%}
|
||||||
|
{%- for file in cfg.files %}
|
||||||
|
{{ file }}
|
||||||
|
{%- endfor %}
|
||||||
|
{
|
||||||
|
{%- for option in cfg.options %}
|
||||||
|
{{ option }}
|
||||||
|
{%- endfor %}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user