Saltstack Official Linux Formula
Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

120 lines
2.5KB

  1. {%- from "linux/map.jinja" import system with context %}
  2. {%- if system.cgroup.enabled|default(True) %}
  3. cgroup_package:
  4. pkg.installed:
  5. - pkgs:
  6. - cgroup-bin
  7. include:
  8. - linux.system.grub
  9. /etc/default/grub.d/80-cgroup.cfg:
  10. file.managed:
  11. - contents: 'GRUB_CMDLINE_LINUX_DEFAULT="quiet cgroup_enable=memory swapaccount=1"'
  12. - require:
  13. - file: grub_d_directory
  14. {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
  15. - watch_in:
  16. - cmd: grub_update
  17. {%- endif %}
  18. /etc/cgconfig.conf:
  19. file.managed:
  20. - user: root
  21. - group: root
  22. - mode: 0644
  23. - template: jinja
  24. - source: salt://linux/files/cgconfig.conf
  25. {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
  26. - check_cmd: /usr/sbin/cgconfigparser -l
  27. {%- endif %}
  28. /etc/cgrules.conf:
  29. file.managed:
  30. - user: root
  31. - group: root
  32. - mode: 0644
  33. - template: jinja
  34. - source: salt://linux/files/cgrules.conf
  35. /etc/default/cgred:
  36. file.managed:
  37. - contents: |
  38. OPTIONS=-v --logfile=/var/log/cgrulesengd.log
  39. /etc/systemd/system/cgred.service:
  40. file.managed:
  41. - contents: |
  42. [Unit]
  43. Description=CGroups Rules Engine Daemon
  44. After=syslog.target
  45. [Service]
  46. Type=forking
  47. EnvironmentFile=-/etc/default/cgred
  48. ExecStart=/usr/sbin/cgrulesengd $OPTIONS
  49. [Install]
  50. WantedBy=multi-user.target
  51. cgred_service_running:
  52. service.running:
  53. - enable: true
  54. - names: ['cgred']
  55. - watch:
  56. - file: /etc/cgconfig.conf
  57. - file: /etc/cgrules.conf
  58. - file: /etc/default/cgred
  59. - file: /etc/systemd/system/cgred.service
  60. {%- if grains.get('noservices') %}
  61. - onlyif: /bin/false
  62. {%- endif %}
  63. {%- else %}
  64. cgred_service_dead:
  65. service.dead:
  66. - enable: false
  67. - names: ['cgred']
  68. {%- if grains.get('noservices') %}
  69. - onlyif: /bin/false
  70. {%- endif %}
  71. include:
  72. - linux.system.grub
  73. remove_/etc/default/grub.d/80-cgroup.cfg:
  74. file.absent:
  75. - name: /etc/default/grub.d/80-cgroup.cfg
  76. - require:
  77. - file: grub_d_directory
  78. {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
  79. - watch_in:
  80. - cmd: grub_update
  81. {%- endif %}
  82. remove_/etc/systemd/system/cgred.service:
  83. file.absent:
  84. - name: /etc/systemd/system/cgred.service
  85. remove_/etc/cgconfig.conf:
  86. file.absent:
  87. - name: /etc/cgconfig.conf
  88. remove_/etc/cgrules.conf:
  89. file.absent:
  90. - name: /etc/cgrules.conf
  91. remove_/etc/default/cgred:
  92. file.absent:
  93. - name: /etc/default/cgred
  94. purge_cgroup_package:
  95. pkg.purged:
  96. - pkgs:
  97. - cgroup-tools
  98. {%- endif %}