Saltstack Official Linux Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

59 lines
1.6KB

  1. {%- from "linux/map.jinja" import system with context %}
  2. {%- if system.enabled %}
  3. include:
  4. - linux.system.user
  5. - linux.system.cron
  6. {%- for name, job in system.job.items() %}
  7. {%- set job_user = job.get('user', 'root') %}
  8. {%- set job_state_name = job.get('identifier', job.command) %}
  9. linux_job_{{ name }}:
  10. {%- if job.get('enabled', True) %}
  11. cron.present:
  12. - name: >
  13. {{ job_state_name }}
  14. {%- if job.get('identifier', True) %}
  15. - identifier: {{ job.get('identifier', job.get('name', name)) }}
  16. {%- endif %}
  17. {%- if job.get('commented', False) %}
  18. - commented: True
  19. {%- endif %}
  20. - user: {{ job_user }}
  21. {%- if job.special is defined %}
  22. - special: '{{ job.special }}'
  23. {%- else %}
  24. {%- if job.minute is defined %}
  25. - minute: '{{ job.minute }}'
  26. {%- endif %}
  27. {%- if job.hour is defined %}
  28. - hour: '{{ job.hour }}'
  29. {%- endif %}
  30. {%- if job.daymonth is defined %}
  31. - daymonth: '{{ job.daymonth }}'
  32. {%- endif %}
  33. {%- if job.month is defined %}
  34. - month: '{{ job.month }}'
  35. {%- endif %}
  36. {%- if job.dayweek is defined %}
  37. - dayweek: '{{ job.dayweek }}'
  38. {%- endif %}
  39. {%- endif %}
  40. - require:
  41. - sls: linux.system.cron
  42. {%- if job_user in system.get('user', {}).keys() %}
  43. - user: system_user_{{ job_user }}
  44. {%- endif %}
  45. {%- else %}
  46. cron.absent:
  47. - name: >
  48. {{ job_state_name }}
  49. {%- if job.get('identifier', True) %}
  50. - identifier: {{ job.get('identifier', job.get('name', name)) }}
  51. {%- endif %}
  52. - user: {{ job_user }}
  53. {%- endif %}
  54. {%- endfor %}
  55. {%- endif %}