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.

52 lines
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. {%- for name, sysfs in system.get('sysfs', {}).items() %}
  12. /etc/sysfs.d/{{ name }}.conf:
  13. file.managed:
  14. - source: salt://linux/files/sysfs.conf
  15. - template: jinja
  16. - user: root
  17. - group: root
  18. - mode: 0644
  19. - defaults:
  20. name: {{ name }}
  21. sysfs: {{ sysfs|yaml }}
  22. - require:
  23. - file: /etc/sysfs.d
  24. {%- if sysfs is mapping %}
  25. {%- set sysfs_list = [sysfs] %}
  26. {%- else %}
  27. {%- set sysfs_list = sysfs %}
  28. {%- endif %}
  29. {%- for item in sysfs_list %}
  30. {%- set list_idx = loop.index %}
  31. {%- for key, value in item.items() %}
  32. {%- if key not in ["mode", "owner"] %}
  33. {%- if grains.get('virtual_subtype', None) not in ['Docker', 'LXC'] %}
  34. {#- Sysfs cannot be set in docker, LXC, etc. #}
  35. linux_sysfs_write_{{ list_idx }}_{{ name }}_{{ key }}:
  36. module.run:
  37. - name: sysfs.write
  38. - key: {{ key }}
  39. - value: {{ value }}
  40. {%- endif %}
  41. {%- endif %}
  42. {%- endfor %}
  43. {%- endfor %}
  44. {%- endfor %}