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.

83 lines
2.1KB

  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 %}
  5. include:
  6. - linux.system.grub
  7. /etc/default/grub.d/90-isolcpu.cfg:
  8. file.managed:
  9. - contents: 'GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT isolcpus={{ system.kernel.isolcpu }}"'
  10. - require:
  11. - file: grub_d_directory
  12. {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
  13. - watch_in:
  14. - cmd: grub_update
  15. {%- endif %}
  16. {%- endif %}
  17. {%- if system.kernel.version is defined %}
  18. linux_kernel_package:
  19. pkg.installed:
  20. - pkgs:
  21. - linux-image-{{ system.kernel.version }}-{{ system.kernel.type|default('generic') }}
  22. {%- if system.kernel.get('headers', False) %}
  23. - linux-headers-{{ system.kernel.version }}-{{ system.kernel.type|default('generic') }}
  24. {%- endif %}
  25. {%- if system.kernel.get('extra', False) %}
  26. - linux-image-extra-{{ system.kernel.version }}-{{ system.kernel.type|default('generic') }}
  27. {%- endif %}
  28. - refresh: true
  29. # Not very Salt-ish.. :-(
  30. linux_kernel_old_absent:
  31. cmd.wait:
  32. - 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 }}')"
  33. - watch:
  34. - pkg: linux_kernel_package
  35. {%- endif %}
  36. {%- for module in system.kernel.get('modules', []) %}
  37. linux_kernel_module_{{ module }}:
  38. kmod.present:
  39. - name: {{ module }}
  40. - persist: true
  41. {%- endfor %}
  42. {%- for module_name, module_content in system.kernel.get('module', {}).iteritems() %}
  43. /etc/modprobe.d/{{ module_name }}.conf:
  44. file.managed:
  45. - user: root
  46. - group: root
  47. - mode: 0644
  48. - template: jinja
  49. - source: salt://linux/files/modprobe.conf.jinja
  50. - defaults:
  51. module_content: {{ module_content }}
  52. module_name: {{ module_name }}
  53. {%- endfor %}
  54. {%- for sysctl_name, sysctl_value in system.kernel.get('sysctl', {}).iteritems() %}
  55. linux_kernel_{{ sysctl_name }}:
  56. sysctl.present:
  57. - name: {{ sysctl_name }}
  58. - value: {{ sysctl_value }}
  59. {%- endfor %}
  60. {%- endif %}
  61. {%- endif %}