forked from dseira/cron-formula
-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from mchugh19/saltcheck-tests
add first saltcheck tests
- Loading branch information
Showing
6 changed files
with
136 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
{%- set cron = salt['pillar.get']('cron', {}) %} | ||
|
||
{%- for task, task_options in cron.get('tasks', {}).items() %} | ||
{%- set cron_type = task_options.type|d('present') %} | ||
|
||
validate_cron.{{ task }}_{{ cron_type }}: | ||
module_and_function: cron.get_entry | ||
args: | ||
- {{ task_options.user|d('root') }} | ||
- {{ task }} | ||
{%- if cron_type == 'absent' %} | ||
assertion: assertFalse | ||
{%- else %} | ||
assertion: assertEqual | ||
assertion_section: identifier | ||
expected-return: {{ task }} | ||
{%- endif %} | ||
|
||
{%- if cron_type == 'present' %} | ||
validate_cron.{{ task }}_commented: | ||
module_and_function: cron.get_entry | ||
args: | ||
- {{ task_options.user|d('root') }} | ||
- {{ task }} | ||
assertion: {{ 'assertTrue' if task_options.commented|d(False) else 'assertFalse' }} | ||
assertion_section: commented | ||
|
||
{#- Note: `special` is `spec` in the module #} | ||
{%- for section in ['minute', 'hour', 'daymonth', 'month', 'dayweek', 'comment', 'spec'] %} | ||
{%- if section in task_options %} | ||
{%- set expected = task_options[section] %} | ||
validate_cron.{{ task }}_{{ section }}: | ||
module_and_function: cron.get_entry | ||
args: | ||
- {{ task_options.user|d('root') }} | ||
- {{ task }} | ||
assertion: {{ 'assertLessEqual' if expected == 'random' else 'assertEqual' }} | ||
assertion_section: {{ section }} | ||
expected-return: '{{ 0 if expected == 'random' else expected }}' | ||
{%- endif %} | ||
{%- endfor %} | ||
{%- endif %} | ||
{%- endfor %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
{%- set package_name = 'cronie' %} | ||
{%- if grains.os_family in ['Debian'] %} | ||
{%- set package_name = 'cron' %} | ||
{%- endif %} | ||
|
||
verify_cron.package: | ||
module_and_function: pkg.version | ||
args: | ||
- {{ package_name }} | ||
assertion: assertNotEmpty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# -*- coding: utf-8 -*- | ||
# vim: ft=sls | ||
|
||
{%- set service_name = 'crond' %} | ||
{%- if grains.os_family in ['Debian', 'Suse'] %} | ||
{%- set service_name = 'cron' %} | ||
{%- elif grains.os_family in ['Arch'] %} | ||
{%- set service_name = 'cronie' %} | ||
{%- endif %} | ||
|
||
verify_cron.service_available: | ||
module_and_function: service.available | ||
args: | ||
- {{ service_name }} | ||
assertion: assertTrue | ||
|
||
verify_cron.service_enabled: | ||
module_and_function: service.enabled | ||
args: | ||
- {{ service_name }} | ||
assertion: assertTrue | ||
|
||
verify_cron.service_running: | ||
module_and_function: service.status | ||
args: | ||
- {{ service_name }} | ||
assertion: assertTrue |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters