Last active
December 23, 2015 05:29
-
-
Save renoirb/6587436 to your computer and use it in GitHub Desktop.
Modular cron definition with MAILTO environment variable
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
# file pillar/cron/piwik.sls | |
cron: | |
piwik_archive_cron: | |
name: /usr/bin/piwik-archive.sh | |
user: root | |
minute: 5 | |
hour: * |
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
# file salt/init.sls | |
cron: | |
pkg: | |
- installed | |
service.running: | |
- enable: True | |
- require: | |
- pkg: cron | |
- file: /etc/profile.d/A0-mailto.sh | |
/etc/profile.d/A0-mailto.sh: | |
file.managed: | |
- user: root | |
- group: root | |
- mode: 755 | |
- source: salt://cron/mailto.sh | |
{% for job, args in pillar.get('cron', {}).items() %} | |
{{ job }}: | |
cron.present: | |
- user: {{ args.get('user', 'root') }} | |
- minute: {{ args.get('minute', '\*') }} | |
- hour: {{ args.get('hour', '\*') }} | |
{% if 'daymonth' in args %} | |
- daymonth: {{ args.get('daymonth') }} | |
{% endif %} | |
{% if 'month' in args %} | |
- month: {{ args.get('month') }} | |
{% endif %} | |
{% if 'dayweek' in args %} | |
- dayweek: {{ args.get('dayweek') }} | |
{% 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
# file salt/cron/mailto.sh | |
MAILTO=team-webplatform-systems@w3.org |
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
#!/bin/bash -l | |
# file piwik/piwik-archive.sh | |
/usr/bin/logger -i -p local1.notice -t cron "[notice] Host `hostname` ran Piwik hourly archive" | |
/usr/bin/php /srv/webplatform/piwik/misc/cron/archive.php -- url=http://tracking.webplatform.org/piwik/ > /var/log/piwik-archive.log |
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
# file piwik/init.sls | |
include: | |
- php.apache | |
- php | |
- piwik.config | |
php-piwik: | |
pkg: | |
- latest | |
- names: | |
- php5-mysql | |
/srv/webplatform/piwik/tmp: | |
file.directory: | |
- mode: 755 | |
- user: www-data | |
- group: www-data | |
- makedirs: True | |
- recurse: | |
- user | |
- group | |
/usr/bin/piwik-archive.sh: | |
file.managed: | |
- mode: 755 | |
- user: root | |
- group: root | |
- source: salt://piwik/piwik-archive.sh | |
- require: | |
- pkg: piwik_archive_cron |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment