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.

59 line
1.2KB

  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. - name: sysfs.write
  40. - key: {{ key }}
  41. - value: {{ value }}
  42. {%- endif %}
  43. {%- endif %}
  44. {%- endfor %}
  45. {%- endfor %}
  46. {%- endif %}
  47. {%- endfor %}