Saltstack Official Linux Formula
Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

97 lines
2.6KB

  1. {%- from "linux/map.jinja" import system with context %}
  2. {%- if system.enabled %}
  3. {%- if system.kernel is defined %}
  4. {%- set kernel_boot_opts = [] %}
  5. {%- do kernel_boot_opts.append('isolcpus=' ~ system.kernel.isolcpu) if system.kernel.isolcpu is defined %}
  6. {%- do kernel_boot_opts.append('elevator=' ~ system.kernel.elevator) if system.kernel.elevator is defined %}
  7. {%- do kernel_boot_opts.extend(system.kernel.boot_options) if system.kernel.boot_options is defined %}
  8. include:
  9. - linux.system.grub
  10. {%- if kernel_boot_opts %}
  11. /etc/default/grub.d/99-custom-settings.cfg:
  12. file.managed:
  13. - contents: 'GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT {{ kernel_boot_opts|join(' ') }}"'
  14. - require:
  15. - file: grub_d_directory
  16. {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
  17. - watch_in:
  18. - cmd: grub_update
  19. {%- endif %}
  20. {%- endif %}
  21. {%- if system.kernel.version is defined %}
  22. linux_kernel_package:
  23. pkg.installed:
  24. - pkgs:
  25. - linux-image-{{ system.kernel.version }}-{{ system.kernel.type|default('generic') }}
  26. {%- if system.kernel.get('headers', False) %}
  27. - linux-headers-{{ system.kernel.version }}-{{ system.kernel.type|default('generic') }}
  28. {%- endif %}
  29. {%- if system.kernel.get('extra', False) %}
  30. - linux-image-extra-{{ system.kernel.version }}-{{ system.kernel.type|default('generic') }}
  31. {%- endif %}
  32. - refresh: true
  33. # Not very Salt-ish.. :-(
  34. linux_kernel_old_absent:
  35. cmd.wait:
  36. - name: "dpkg -l '*linux-generic-*[0-9]*' '*linux-image-*[0-9]*' '*linux-headers-*[0-9]*' '*linux-image-extra-*[0-9]*' | grep -E '^ii' | awk '{print $2}' | grep -v '{{ system.kernel.version }}' | xargs dpkg --purge --force-depends"
  37. - watch:
  38. - pkg: linux_kernel_package
  39. {%- endif %}
  40. {%- for module in system.kernel.get('modules', []) %}
  41. linux_kernel_module_{{ module }}:
  42. kmod.present:
  43. - name: {{ module }}
  44. - persist: true
  45. {%- endfor %}
  46. {%- if system.kernel.module is defined %}
  47. modprobe_d_directory:
  48. file.directory:
  49. - name: /etc/modprobe.d
  50. - user: root
  51. - group: root
  52. - mode: 755
  53. {%- for module_name in system.kernel.module %}
  54. /etc/modprobe.d/{{ module_name }}.conf:
  55. file.managed:
  56. - user: root
  57. - group: root
  58. - mode: 0644
  59. - template: jinja
  60. - source: salt://linux/files/modprobe.conf.jinja
  61. - defaults:
  62. module_name: {{ module_name }}
  63. - require:
  64. - file: modprobe_d_directory
  65. {%- endfor %}
  66. {%- endif %}
  67. {%- for sysctl_name, sysctl_value in system.kernel.get('sysctl', {}).items() %}
  68. linux_kernel_{{ sysctl_name }}:
  69. sysctl.present:
  70. - name: {{ sysctl_name }}
  71. - value: {{ sysctl_value }}
  72. {%- endfor %}
  73. {%- endif %}
  74. {%- endif %}