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.

cpu.sls 1.2KB

8 jaren geleden
8 jaren geleden
8 jaren geleden
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. {%- from "linux/map.jinja" import system with context %}
  2. {%- if system.cpu.governor is defined %}
  3. include:
  4. - linux.system.sysfs
  5. ondemand_service_disable:
  6. service.dead:
  7. - name: ondemand
  8. - enable: false
  9. {%- if grains.get('virtual', None) in ['physical', None] %}
  10. {#- Governor cannot be set in VMs, etc. #}
  11. /etc/sysfs.d/governor.conf:
  12. file.managed:
  13. - source: salt://linux/files/governor.conf.jinja
  14. - template: jinja
  15. - user: root
  16. - group: root
  17. - mode: 0644
  18. - defaults:
  19. governor: {{ system.cpu.governor }}
  20. - require:
  21. - file: /etc/sysfs.d
  22. {% for cpu_core in range(salt['grains.get']('num_cpus', 1)) %}
  23. {% set core_key = 'devices/system/cpu/cpu' + cpu_core|string + '/cpufreq/scaling_governor' %}
  24. {% if salt['file.file_exists']('/sys/'+ core_key) %}
  25. governor_write_sysfs_cpu_core_{{ cpu_core }}:
  26. module.run:
  27. {%- if 'module.run' in salt['config.get']('use_superseded', default=[]) %}
  28. - sysfs.write:
  29. - key: {{ core_key }}
  30. - value: {{ system.cpu.governor }}
  31. {%- else %}
  32. - name: sysfs.write
  33. - key: {{ core_key }}
  34. - value: {{ system.cpu.governor }}
  35. {%- endif %}
  36. {% endif %}
  37. {%- endfor %}
  38. {%- endif %}
  39. {%- endif %}