Saltstack Official Linux Formula
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

kernel.sls 2.8KB

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