tuned-amdgpu/roles/tuned_amdgpu/tasks/main.yml

131 lines
3.7 KiB
YAML

---
# tasks file for tuned_amdgpu
#
- name: Gather package facts
ansible.builtin.package_facts:
manager: auto
# around Fedora 35/36, the packages for 'power-profiles-daemon' and 'tuned' conflicted; no more - can coincide
# ensuring the service is masked should suffice - not removed; gnome/others may 'require' it. doing so may remove them implicitly
- name: Ensure power-profiles-daemon is off/disabled/masked
ansible.builtin.systemd_service:
name: power-profiles-daemon
enabled: false
masked: true
state: stopped
when: "'power-profiles-daemon' in ansible_facts['packages']"
become: true
- name: Ensure 'tuned' is installed
ansible.builtin.package:
name: tuned
state: present
become: true
- name: Ensure 'tuned-ppd' is absent
ansible.builtin.package:
name: tuned-ppd
state: absent
become: true
- name: Find bundled 'tuned' profiles
ansible.builtin.find:
paths:
- /usr/lib/tuned/ # this may change/benefit from var/defaults; packaging should generally prefer this path
patterns:
- 'tuned.conf'
recurse: true
register: tuned_bundled_configs
- name: Set fact with included profile names
ansible.builtin.set_fact:
base_profiles: "{{ base_profiles | default([]) + profile_name }}"
loop: "{{ tuned_bundled_configs.files }}"
loop_control:
label: "{{ profile_name }}"
vars:
profile_name: "{{ [item.path | dirname | basename] }}"
- name: Ensure dynamic tuning is disabled
ansible.builtin.lineinfile:
path: /etc/tuned/tuned-main.conf
regexp: '^dynamic_tuning.*='
line: 'dynamic_tuning = 0'
notify: Restart tuned
become: true
- name: Configure vars in '/etc/tuned/amdgpu-profile-vars.conf'
ansible.builtin.lineinfile:
path: /etc/tuned/amdgpu-profile-vars.conf
line: "{{ item }}={{ vars[item] }}"
regexp: "^{{ item }}="
create: true
mode: '0644'
when: vars[item] is defined
with_items:
- tuned_amdgpu_clock_min
- tuned_amdgpu_clock_max
- tuned_amdgpu_memclock_static
- tuned_amdgpu_power_multi_def
- tuned_amdgpu_power_multi_oc
- tuned_amdgpu_mv_offset
become: true
- name: Create custom profile directories
ansible.builtin.file:
state: directory
path: "{{ (tuned_amdgpu_profile_dir, item.1 + '-amdgpu-' + item.0) | ansible.builtin.path_join }}"
mode: "0755"
with_nested:
- ['default', 'overclock', 'peak']
- "{{ base_profiles }}"
become: true
- name: Template AMDGPU profile script
ansible.builtin.template:
src: amdgpu-profile.sh.j2
dest: "{{ (tuned_amdgpu_profile_dir, 'amdgpu-clock.sh') | ansible.builtin.path_join }}" # place in base dir for all profiles, called w/ arg
owner: root
group: root
mode: "0755"
notify: Restart tuned
become: true
- name: Copy gamescope RT capability script
ansible.builtin.copy:
src: rt_gamescope.sh
dest: /etc/tuned/rt_gamescope.sh
owner: root
group: root
mode: '0755'
become: true
- name: Template tuned.conf for custom profiles
ansible.builtin.template:
src: templates/tuned.conf.j2
dest: "{{ (tuned_amdgpu_profile_dir, item.1 + '-amdgpu-' + item.0, 'tuned.conf') | ansible.builtin.path_join }}"
owner: root
group: root
mode: "0644"
with_nested:
- ['default', 'overclock', 'peak']
- "{{ base_profiles }}"
notify: Restart tuned
become: true
tags:
- tuned.conf
- name: Ensure tuned is enabled
ansible.builtin.service:
name: tuned
enabled: true
become: true
- name: Copy gamemode memlock limits.d booster
become: true
ansible.builtin.template:
src: etc.security.limits.d.99-gamemode-memlock.conf
dest: /etc/security/limits.d/99-gamemode-memlock.conf
owner: root
group: root
mode: '0644'