Saltstack Official Linux Formula
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

101 lines
2.6KB

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