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

132 lines
3.7 KiB
YAML
Raw Normal View History

2022-11-27 06:51:39 +00:00
---
# 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']"
2022-11-27 06:51:39 +00:00
become: true
- name: Ensure 'tuned' is installed
2022-11-27 06:51:39 +00:00
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:
2024-08-27 11:54:55 +00:00
- 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
2022-11-27 06:51:39 +00:00
- name: Create custom profile directories
ansible.builtin.file:
state: directory
path: "{{ (tuned_amdgpu_profile_dir, item.1 + '-amdgpu-' + item.0) | ansible.builtin.path_join }}"
2022-11-27 06:51:39 +00:00
mode: "0755"
with_nested:
- ['default', 'overclock', 'peak']
2022-11-27 06:51:39 +00:00
- "{{ 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"
2022-11-27 06:51:39 +00:00
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
2022-11-27 06:51:39 +00:00
ansible.builtin.template:
src: templates/tuned.conf.j2
dest: "{{ (tuned_amdgpu_profile_dir, item.1 + '-amdgpu-' + item.0, 'tuned.conf') | ansible.builtin.path_join }}"
2022-11-27 06:51:39 +00:00
owner: root
group: root
mode: "0644"
with_nested:
- ['default', 'overclock', 'peak']
2022-11-27 06:51:39 +00:00
- "{{ base_profiles }}"
notify: Restart tuned
become: true
tags:
- tuned.conf
2022-11-27 06:51:39 +00:00
- 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'