Saltstack Official Linux Formula
Nie możesz wybrać więcej, niż 25 tematów Tematy muszą się zaczynać od litery lub cyfry, mogą zawierać myślniki ('-') i mogą mieć do 35 znaków.

65 lines
1.4KB

  1. {%- from "linux/map.jinja" import system with context %}
  2. linux_sysfs_package:
  3. pkg.installed:
  4. - pkgs:
  5. - sysfsutils
  6. - refresh: true
  7. /etc/sysfs.d:
  8. file.directory:
  9. - require:
  10. - pkg: linux_sysfs_package
  11. {% set apply = system.get('sysfs', {}).pop('enable_apply', True) %}
  12. {%- for name, sysfs in system.get('sysfs', {}).items() %}
  13. /etc/sysfs.d/{{ name }}.conf:
  14. file.managed:
  15. - source: salt://linux/files/sysfs.conf
  16. - template: jinja
  17. - user: root
  18. - group: root
  19. - mode: 0644
  20. - defaults:
  21. name: {{ name }}
  22. sysfs: {{ sysfs|yaml }}
  23. - require:
  24. - file: /etc/sysfs.d
  25. {%- if sysfs is mapping %}
  26. {%- set sysfs_list = [sysfs] %}
  27. {%- else %}
  28. {%- set sysfs_list = sysfs %}
  29. {%- endif %}
  30. {%- if apply %}
  31. {%- for item in sysfs_list %}
  32. {%- set list_idx = loop.index %}
  33. {%- for key, value in item.items() %}
  34. {%- if key not in ["mode", "owner"] %}
  35. {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
  36. {#- Sysfs cannot be set in docker, LXC, etc. #}
  37. linux_sysfs_write_{{ list_idx }}_{{ name }}_{{ key }}:
  38. module.run:
  39. {%- if 'module.run' in salt['config.get']('use_superseded', default=[]) %}
  40. - sysfs.write:
  41. - key: {{ key }}
  42. - value: {{ value }}
  43. {%- else %}
  44. - name: sysfs.write
  45. - key: {{ key }}
  46. - value: {{ value }}
  47. {%- endif %}
  48. {%- endif %}
  49. {%- endif %}
  50. {%- endfor %}
  51. {%- endfor %}
  52. {%- endif %}
  53. {%- endfor %}