1
0
Fork 0

Split init.sls into config, install and service

Following the template-formula example.
This commit is contained in:
Gilles Dartiguelongue 2017-02-14 12:50:32 +01:00
parent 1c6661a485
commit f0cf823177
6 changed files with 48 additions and 21 deletions

View File

@ -25,9 +25,17 @@ Installs the ``logrotate`` package and service/timer/cron.
Manages logrotate config and include dir.
``logrotate.install``
---------------------
Installs the logrotate package and its dependencies.
``logrotate.jobs``
------------------
Create custom job for logrotate.
``logrotate.service``
---------------------
Manages the startup and running state of the logrotate service.

View File

@ -11,6 +11,12 @@ logrotate_config:
- user: {{ salt['pillar.get']('logrotate:config:user', logrotate.user) }}
- group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }}
- mode: {{ salt['pillar.get']('logrotate:config:mode', '644') }}
- require:
- pkg: logrotate
logrotate_directory:
file.directory:
- name: {{ logrotate.include_dir }}
- user: {{ salt['pillar.get']('logrotate:config:user', logrotate.user) }}
- group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }}
- mode: 755
- makedirs: True

View File

@ -1,19 +1,7 @@
{% from "logrotate/map.jinja" import logrotate with context %}
logrotate:
pkg.installed:
- name: {{ logrotate.pkg|json }}
service.running:
- name: {{ logrotate.service }}
- enable: True
logrotate_directory:
file.directory:
- name: {{ logrotate.include_dir }}
- user: {{ salt['pillar.get']('logrotate:config:user', logrotate.user) }}
- group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }}
- mode: 755
- makedirs: True
- require:
- pkg: logrotate
# -*- coding: utf-8 -*-
# vim: ft=sls
include:
- logrotate.install
- logrotate.config
- logrotate.service

8
logrotate/install.sls Normal file
View File

@ -0,0 +1,8 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{% from "logrotate/map.jinja" import logrotate with context %}
logrotate-pkg:
pkg.installed:
- name: {{ logrotate.pkg }}

View File

@ -15,7 +15,7 @@ logrotate_{{key}}:
- group: {{ salt['pillar.get']('logrotate:config:group', logrotate.group) }}
- mode: {{ salt['pillar.get']('logrotate:config:mode', '644') }}
- require:
- pkg: logrotate
- pkg: logrotate-pkg
- context:
{% if value is mapping %}
path: {{ value.get('path', []) }}

17
logrotate/service.sls Normal file
View File

@ -0,0 +1,17 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{% from "logrotate/map.jinja" import logrotate with context %}
include:
- logrotate.config
- logrotate.install
logrotate:
service.running:
- name: {{ logrotate.service }}
- enable: True
- require:
- pkg: logrotate-pkg
- file: logrotate_config
- file: logrotate_directory