Saltstack Official Linux Formula
Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. {%- from "linux/map.jinja" import system with context %}
  2. {%- if system.cron.enabled is defined and system.cron.enabled %}
  3. cron_packages:
  4. pkg.installed:
  5. - names: {{ system.cron.pkgs }}
  6. cron_services:
  7. service.running:
  8. - enable: true
  9. - names: {{ system.cron.services }}
  10. - require:
  11. - pkg: cron_packages
  12. {%- if grains.get('noservices') %}
  13. - onlyif: /bin/false
  14. {%- endif %}
  15. {%- set allow_users = [] %}
  16. {%- for user_name, user_params in system.cron.get('user', {}).items() %}
  17. {%- set user_enabled = user_params.get('enabled', false) and
  18. system.get('user', {}).get(
  19. user_name, {'enabled': true}).get('enabled', true) %}
  20. {%- if user_enabled %}
  21. {%- do allow_users.append(user_name) %}
  22. {%- endif %}
  23. {%- endfor %}
  24. etc_cron_allow:
  25. {%- if allow_users %}
  26. file.managed:
  27. - name: /etc/cron.allow
  28. - template: jinja
  29. - source: salt://linux/files/cron_users.jinja
  30. - user: root
  31. - group: crontab
  32. - mode: 0640
  33. - defaults:
  34. users: {{ allow_users | yaml }}
  35. - require:
  36. - cron_packages
  37. {%- else %}
  38. file.absent:
  39. - name: /etc/cron.allow
  40. {%- endif %}
  41. {#
  42. /etc/cron.deny should be absent to comply with
  43. CIS 5.1.8 Ensure at/cron is restricted to authorized users
  44. #}
  45. etc_cron_deny:
  46. file.absent:
  47. - name: /etc/cron.deny
  48. etc_crontab:
  49. file.managed:
  50. - name: /etc/crontab
  51. - user: root
  52. - group: root
  53. - mode: 0600
  54. - replace: False
  55. - require:
  56. - cron_packages
  57. etc_cron_dirs:
  58. file.directory:
  59. - names:
  60. - /etc/cron.d
  61. - /etc/cron.daily
  62. - /etc/cron.hourly
  63. - /etc/cron.monthly
  64. - /etc/cron.weekly
  65. - user: root
  66. - group: root
  67. - dir_mode: 0600
  68. - recurse:
  69. - ignore_files
  70. - require:
  71. - cron_packages
  72. {%- else %}
  73. fake_linux_system_cron:
  74. test.nop:
  75. - comment: Fake state to satisfy 'require sls:linux.system.cron'
  76. {%- endif %}