Saltstack Official Linux Formula
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

57 行
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. linux_job_{{ job.command }}:
  9. {%- if job.get('enabled', True) %}
  10. cron.present:
  11. - name: >
  12. {{ job.command }}
  13. {%- if job.get('identifier', True) %}
  14. - identifier: {{ job.get('identifier', job.get('name', name)) }}
  15. {%- endif %}
  16. {%- if job.get('commented', False) %}
  17. - commented: True
  18. {%- endif %}
  19. - user: {{ job_user }}
  20. {%- if job.special is defined %}
  21. - special: '{{ job.special }}'
  22. {%- else %}
  23. {%- if job.minute is defined %}
  24. - minute: '{{ job.minute }}'
  25. {%- endif %}
  26. {%- if job.hour is defined %}
  27. - hour: '{{ job.hour }}'
  28. {%- endif %}
  29. {%- if job.daymonth is defined %}
  30. - daymonth: '{{ job.daymonth }}'
  31. {%- endif %}
  32. {%- if job.month is defined %}
  33. - month: '{{ job.month }}'
  34. {%- endif %}
  35. {%- if job.dayweek is defined %}
  36. - dayweek: '{{ job.dayweek }}'
  37. {%- endif %}
  38. {%- endif %}
  39. - require:
  40. - sls: linux.system.cron
  41. {%- if job_user in system.get('user', {}).keys() %}
  42. - user: system_user_{{ job_user }}
  43. {%- endif %}
  44. {%- else %}
  45. cron.absent:
  46. - name: {{ job.command }}
  47. {%- if job.get('identifier', True) %}
  48. - identifier: {{ job.get('identifier', job.get('name', name)) }}
  49. {%- endif %}
  50. - user: {{ job_user }}
  51. {%- endif %}
  52. {%- endfor %}
  53. {%- endif %}