mirror of
https://github.com/saltstack-formulas/cron-formula.git
synced 2024-11-27 23:07:46 +01:00
refactor(pillar): sync map.jinja with template-formula
This commit is contained in:
parent
07bf957430
commit
e00c316ebe
@ -1,10 +1,12 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
{%- from "cron/map.jinja" import cron_settings with context %}
|
||||
{#- Get the `tplroot` from `tpldir` #}
|
||||
{%- set tplroot = tpldir.split('/')[0] %}
|
||||
{%- from tplroot ~ "/map.jinja" import cron with context %}
|
||||
|
||||
{%- if 'tasks' in cron_settings %}
|
||||
{%- for task,task_options in cron_settings.tasks.items() %}
|
||||
{%- if 'tasks' in cron %}
|
||||
{%- for task,task_options in cron.tasks.items() %}
|
||||
|
||||
cron.{{ task }}:
|
||||
cron.{{ task_options.type|default('present') }}:
|
||||
@ -37,5 +39,6 @@ cron.{{ task }}:
|
||||
{%- if 'comment' in task_options %}
|
||||
- comment: {{ task_options.comment }}
|
||||
{%- endif %}
|
||||
{%- endfor %}
|
||||
|
||||
{%- endfor %}
|
||||
{%- endif %}
|
5
cron/config/init.sls
Normal file
5
cron/config/init.sls
Normal file
@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
include:
|
||||
- .file
|
4
cron/defaults.yaml
Normal file
4
cron/defaults.yaml
Normal file
@ -0,0 +1,4 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=yaml
|
||||
---
|
||||
cron: {}
|
@ -2,6 +2,6 @@
|
||||
# vim: ft=sls
|
||||
|
||||
include:
|
||||
- cron.install
|
||||
- cron.config
|
||||
- cron.service
|
||||
- .package
|
||||
- .config
|
||||
- .service
|
||||
|
@ -1,8 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
{%- from "cron/map.jinja" import cron_settings with context %}
|
||||
|
||||
cron.install:
|
||||
pkg.installed:
|
||||
- name: {{ cron_settings.pkg }}
|
@ -1,24 +1,49 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=jinja
|
||||
|
||||
{%- set os_family_map = salt['grains.filter_by']({
|
||||
'RedHat': {
|
||||
'pkg': 'cronie',
|
||||
'service': 'crond',
|
||||
},
|
||||
'Suse': {
|
||||
'pkg': 'cronie',
|
||||
'service': 'cron',
|
||||
},
|
||||
'Debian': {
|
||||
'pkg': 'cron',
|
||||
'service': 'cron',
|
||||
},
|
||||
}, grain='os_family', merge=salt['pillar.get']('cron:lookup')) %}
|
||||
{#- Get the `tplroot` from `tpldir` #}
|
||||
{%- set tplroot = tpldir.split('/')[0] %}
|
||||
{#- Start imports as #}
|
||||
{%- import_yaml tplroot ~ "/defaults.yaml" as default_settings %}
|
||||
{%- import_yaml tplroot ~ "/osarchmap.yaml" as osarchmap %}
|
||||
{%- import_yaml tplroot ~ "/osfamilymap.yaml" as osfamilymap %}
|
||||
{%- import_yaml tplroot ~ "/osmap.yaml" as osmap %}
|
||||
{%- import_yaml tplroot ~ "/osfingermap.yaml" as osfingermap %}
|
||||
|
||||
{%- set cron_settings = salt['pillar.get'](
|
||||
'cron',
|
||||
default=os_family_map,
|
||||
merge=True
|
||||
)
|
||||
{#- Retrieve the config dict only once #}
|
||||
{%- set _config = salt['config.get'](tplroot, default={}) %}
|
||||
|
||||
{%- set defaults = salt['grains.filter_by'](
|
||||
default_settings,
|
||||
default=tplroot,
|
||||
merge=salt['grains.filter_by'](
|
||||
osarchmap,
|
||||
grain='osarch',
|
||||
merge=salt['grains.filter_by'](
|
||||
osfamilymap,
|
||||
grain='os_family',
|
||||
merge=salt['grains.filter_by'](
|
||||
osmap,
|
||||
grain='os',
|
||||
merge=salt['grains.filter_by'](
|
||||
osfingermap,
|
||||
grain='osfinger',
|
||||
merge=salt['grains.filter_by'](
|
||||
_config,
|
||||
default='lookup'
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
)
|
||||
%}
|
||||
|
||||
{%- set config = salt['grains.filter_by'](
|
||||
{'defaults': defaults},
|
||||
default='defaults',
|
||||
merge=_config
|
||||
)
|
||||
%}
|
||||
|
||||
{%- set cron = config %}
|
||||
|
35
cron/osarchmap.yaml
Normal file
35
cron/osarchmap.yaml
Normal file
@ -0,0 +1,35 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=yaml
|
||||
#
|
||||
# Setup variables using grains['osarch'] based logic.
|
||||
# You just need to add the key:values for an `osarch` that differ
|
||||
# from `defaults.yaml`.
|
||||
# Only add an `osarch` which is/will be supported by the formula.
|
||||
#
|
||||
# If you do not need to provide defaults via the `osarch` grain,
|
||||
# you will need to provide at least an empty dict in this file, e.g.
|
||||
# osarch: {}
|
||||
---
|
||||
amd64:
|
||||
arch: amd64
|
||||
|
||||
x86_64:
|
||||
arch: amd64
|
||||
|
||||
386:
|
||||
arch: 386
|
||||
|
||||
arm64:
|
||||
arch: arm64
|
||||
|
||||
armv6l:
|
||||
arch: armv6l
|
||||
|
||||
armv7l:
|
||||
arch: armv7l
|
||||
|
||||
ppc64le:
|
||||
arch: ppc64le
|
||||
|
||||
s390x:
|
||||
arch: s390x
|
23
cron/osfamilymap.yaml
Normal file
23
cron/osfamilymap.yaml
Normal file
@ -0,0 +1,23 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=yaml
|
||||
#
|
||||
# Setup variables using grains['os_family'] based logic.
|
||||
# You just need to add the key:values for an `os_family` that differ
|
||||
# from `defaults.yaml` + `osarch.yaml`.
|
||||
# Only add an `os_family` which is/will be supported by the formula.
|
||||
#
|
||||
# If you do not need to provide defaults via the `os_family` grain,
|
||||
# you will need to provide at least an empty dict in this file, e.g.
|
||||
# osfamilymap: {}
|
||||
---
|
||||
Debian:
|
||||
pkg: cron
|
||||
service: cron
|
||||
|
||||
RedHat:
|
||||
pkg: cronie
|
||||
service: crond
|
||||
|
||||
Suse:
|
||||
pkg: cronie
|
||||
service: cron
|
13
cron/osfingermap.yaml
Normal file
13
cron/osfingermap.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=yaml
|
||||
#
|
||||
# Setup variables using grains['osfinger'] based logic.
|
||||
# You just need to add the key:values for an `osfinger` that differ
|
||||
# from `defaults.yaml` + `osarch.yaml` + `os_family.yaml` + `osmap.yaml`.
|
||||
# Only add an `osfinger` which is/will be supported by the formula.
|
||||
#
|
||||
# If you do not need to provide defaults via the `os_finger` grain,
|
||||
# you will need to provide at least an empty dict in this file, e.g.
|
||||
# osfingermap: {}
|
||||
---
|
||||
osfingermap: {}
|
13
cron/osmap.yaml
Normal file
13
cron/osmap.yaml
Normal file
@ -0,0 +1,13 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=yaml
|
||||
#
|
||||
# Setup variables using grains['os'] based logic.
|
||||
# You just need to add the key:values for an `os` that differ
|
||||
# from `defaults.yaml` + `osarch.yaml` + `os_family.yaml`.
|
||||
# Only add an `os` which is/will be supported by the formula.
|
||||
#
|
||||
# If you do not need to provide defaults via the `os` grain,
|
||||
# you will need to provide at least an empty dict in this file, e.g.
|
||||
# osmap: {}
|
||||
---
|
||||
osmap: {}
|
5
cron/package/init.sls
Normal file
5
cron/package/init.sls
Normal file
@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
include:
|
||||
- .install
|
10
cron/package/install.sls
Normal file
10
cron/package/install.sls
Normal file
@ -0,0 +1,10 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
{#- Get the `tplroot` from `tpldir` #}
|
||||
{%- set tplroot = tpldir.split('/')[0] %}
|
||||
{%- from tplroot ~ "/map.jinja" import cron with context %}
|
||||
|
||||
cron.install:
|
||||
pkg.installed:
|
||||
- name: {{ cron.pkg }}
|
@ -1,15 +0,0 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
{%- from "cron/map.jinja" import cron_settings with context %}
|
||||
|
||||
cron.service:
|
||||
{%- if 'enabled' not in cron_settings or ( 'enabled' in cron_settings and cron_settings.enabled ) %}
|
||||
service.running:
|
||||
- name: {{ cron_settings.service }}
|
||||
- enable: True
|
||||
{%- else %}
|
||||
service.dead:
|
||||
- name: {{ cron_settings.service }}
|
||||
- enable: False
|
||||
{%- endif %}
|
5
cron/service/init.sls
Normal file
5
cron/service/init.sls
Normal file
@ -0,0 +1,5 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
include:
|
||||
- .running
|
17
cron/service/running.sls
Normal file
17
cron/service/running.sls
Normal file
@ -0,0 +1,17 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
# vim: ft=sls
|
||||
|
||||
{#- Get the `tplroot` from `tpldir` #}
|
||||
{%- set tplroot = tpldir.split('/')[0] %}
|
||||
{%- from tplroot ~ "/map.jinja" import cron with context %}
|
||||
|
||||
cron.service:
|
||||
{%- if 'enabled' not in cron or ( 'enabled' in cron and cron.enabled ) %}
|
||||
service.running:
|
||||
- name: {{ cron.service }}
|
||||
- enable: true
|
||||
{%- else %}
|
||||
service.dead:
|
||||
- name: {{ cron.service }}
|
||||
- enable: false
|
||||
{%- endif %}
|
@ -49,7 +49,7 @@ Available states
|
||||
^^^^^^^^
|
||||
Installs and configures the cron package.
|
||||
|
||||
``cron.install``
|
||||
``cron.package``
|
||||
^^^^^^^^^^^^^^^^
|
||||
Installs the cron package.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user