Merge pull request #3 from myii/bug/fix-general-issues

fix(iteritems): replace with `items` instead (and other fixes for consistency)
This commit is contained in:
Niels Abspoel 2019-04-04 20:36:09 +02:00 committed by GitHub
commit 2d4adf9e24
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 102 additions and 101 deletions

View File

@ -1,41 +1,41 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{% from "cron/map.jinja" import cron_settings with context %}
{%- from "cron/map.jinja" import cron_settings with context %}
{% if 'tasks' in cron_settings %}
{% for task,task_options in cron_settings.tasks.iteritems() %}
{%- if 'tasks' in cron_settings %}
{%- for task,task_options in cron_settings.tasks.items() %}
cron.{{ task }}:
cron.{{ task_options.type|default('present') }}:
- name: '{{ task_options.name }}'
{% if 'user' in task_options %}
- user: {{ task_options.user|default('root') }}
{% endif %}
{% if 'minute' in task_options %}
- minute: '{{ task_options.minute }}'
{% endif %}
{% if 'hour' in task_options %}
- hour: '{{ task_options.hour }}'
{% endif %}
{% if 'daymonth' in task_options %}
- daymonth: '{{ task_options.daymonth }}'
{% endif %}
{% if 'month' in task_options %}
- month: '{{ task_options.month }}'
{% endif %}
{% if 'dayweek' in task_options %}
- dayweek: '{{ task_options.dayweek }}'
{% endif %}
{% if 'commented' in task_options and task_options.commented %}
- commented: True
{% endif %}
{% if 'special' in task_options %}
- special: '{{ task_options.special }}'
{% endif %}
- identifier: '{{ task }}'
{% if 'comment' in task_options %}
- comment: '{{ task_options.comment }}'
{% endif %}
{% endfor %}
{% endif %}
cron.{{ task_options.type|default('present') }}:
- name: {{ task_options.name }}
{%- if 'user' in task_options %}
- user: {{ task_options.user|default('root') }}
{%- endif %}
{%- if 'minute' in task_options %}
- minute: '{{ task_options.minute }}'
{%- endif %}
{%- if 'hour' in task_options %}
- hour: '{{ task_options.hour }}'
{%- endif %}
{%- if 'daymonth' in task_options %}
- daymonth: '{{ task_options.daymonth }}'
{%- endif %}
{%- if 'month' in task_options %}
- month: '{{ task_options.month }}'
{%- endif %}
{%- if 'dayweek' in task_options %}
- dayweek: '{{ task_options.dayweek }}'
{%- endif %}
{%- if 'commented' in task_options and task_options.commented %}
- commented: True
{%- endif %}
{%- if 'special' in task_options %}
- special: '{{ task_options.special }}'
{%- endif %}
- identifier: '{{ task }}'
{%- if 'comment' in task_options %}
- comment: {{ task_options.comment }}
{%- endif %}
{%- endfor %}
{%- endif %}

View File

@ -2,6 +2,6 @@
# vim: ft=sls
include:
- cron.install
- cron.config
- cron.service
- cron.install
- cron.config
- cron.service

View File

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

View File

@ -1,24 +1,24 @@
# -*- 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',
},
{%- 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')) %}
{% set cron_settings = salt['pillar.get'](
'cron',
default=os_family_map,
merge=True
)
{%- set cron_settings = salt['pillar.get'](
'cron',
default=os_family_map,
merge=True
)
%}

View File

@ -1,15 +1,15 @@
# -*- coding: utf-8 -*-
# vim: ft=sls
{% from "cron/map.jinja" import cron_settings with context %}
{%- 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 %}
{%- 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 %}

View File

@ -1,33 +1,34 @@
cron:
enabled: True # Default
lookup: # Not needed, just if you want to use another cron program
pkg: 'cronie'
tasks:
task1:
type: 'present' # Default
name: 'echo test > /tmp/test'
user: 'root'
minute: 0
hour: 0
daymonth: 7
month: 1
dayweek: 6
comment: 'comment1'
task2:
type: 'absent' # To remove that crontask
name: 'echo task2 > /tmp/test2'
user: 'root'
minute: 'random'
hour: 1
task3:
type: 'absent'
name: 'echo task3 > /tmp/test3'
user: 'root'
special: '@hourly'
comment: 'comment3'
task4:
type: 'present' # run every 5 minutes
user: 'root'
minute: '*/5'
hour: '*'
comment: 'comment4'
enabled: True # Default
lookup: # Not needed, just if you want to use another cron program
pkg: cronie
tasks:
task1:
type: present # Default
name: echo test > /tmp/test
user: root
minute: 0
hour: 0
daymonth: 7
month: 1
dayweek: 6
comment: comment1
task2:
type: absent # To remove that crontask
name: echo task2 > /tmp/test2
user: root
minute: random
hour: 1
task3:
type: absent
name: echo task3 > /tmp/test3
user: root
special: '@hourly'
comment: comment3
task4:
type: present # run every 5 minutes
name: echo task4 > /tmp/test4
user: root
minute: '*/5'
hour: '*'
comment: comment4