66 lines
2 KiB
YAML
66 lines
2 KiB
YAML
---
|
|
- hosts: localhost
|
|
become: yes
|
|
vars:
|
|
card: card0 # default to card0
|
|
base_profiles: # standard tuned profiles available on Fedora, should dynamically discover?
|
|
- balanced
|
|
- desktop
|
|
- latency-performance
|
|
- network-latency
|
|
- network-throughput
|
|
- powersave
|
|
- virtual-host
|
|
amdgpu_profiles: # statically defined mapping of the contents in /sys/class/drm/{{ card }}/device/pp_power_profile_mode
|
|
# - { name: 'bootup_default', value: 0 }
|
|
# - { name: '3D_fullscreen', value: 1 }
|
|
- { name: 'powersaving', value: 2 }
|
|
- { name: 'video', value: 3 }
|
|
- { name: 'VR', value: 4 }
|
|
# - { name: 'compute', value: 5 }
|
|
# - { name: 'custom', value: 6 }
|
|
handlers:
|
|
- name: restart tuned
|
|
ansible.builtin.service:
|
|
name: tuned
|
|
state: restarted
|
|
tasks:
|
|
- name: find hwmon/max power capability file for {{ card }}
|
|
find:
|
|
paths: /sys/class/drm/{{ card }}/device/hwmon
|
|
file_type: file
|
|
recurse: yes
|
|
use_regex: yes
|
|
patterns:
|
|
- '^power1_cap_max$'
|
|
register: hwmon
|
|
- name: print hwmon
|
|
debug:
|
|
msg: "{{ hwmon }}"
|
|
- name: get max power capability for {{ card }}
|
|
slurp:
|
|
src: "{{ hwmon.files.0.path }}"
|
|
register: power_max
|
|
- name: ensure tuned is installed
|
|
package:
|
|
name: tuned
|
|
state: present
|
|
- name: create custom profile directories
|
|
file:
|
|
state: directory
|
|
path: /etc/tuned/{{ item.1 }}-amdgpu-{{ item.0.name }}
|
|
mode: "0755"
|
|
with_nested:
|
|
- "{{ amdgpu_profiles }}"
|
|
- "{{ base_profiles }}"
|
|
- name: template custom tuned profiles
|
|
template:
|
|
src: templates/tuned.conf.j2
|
|
dest: /etc/tuned/{{ item.1 }}-amdgpu-{{ item.0.name }}/tuned.conf
|
|
owner: root
|
|
group: root
|
|
mode: "0644"
|
|
with_nested:
|
|
- "{{ amdgpu_profiles }}"
|
|
- "{{ base_profiles }}"
|
|
notify: restart tuned
|