2022-11-27 06:51:39 +00:00
|
|
|
---
|
|
|
|
# tasks file for tuned_amdgpu
|
|
|
|
#
|
|
|
|
- name: Gather package facts
|
|
|
|
ansible.builtin.package_facts:
|
|
|
|
manager: auto
|
|
|
|
|
2024-06-29 14:40:36 +00:00
|
|
|
- name: Use legacy custom-profile directory when < 2.23.0
|
|
|
|
ansible.builtin.set_fact:
|
|
|
|
tuned_amdgpu_profile_dir: "/etc/tuned"
|
|
|
|
when: ansible_facts['packages']['tuned'][0]['version'] is version('2.23.0', '<') # versions are in a list...? pick the first; only expect one
|
|
|
|
|
2024-08-06 13:08:11 +00:00
|
|
|
# around Fedora 35/36, the packages for 'power-profiles-daemon' and 'tuned' conflicted; no more - can coincide
|
2024-08-06 13:16:10 +00:00
|
|
|
# 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
|
2024-08-06 13:08:11 +00:00
|
|
|
ansible.builtin.systemd_service:
|
|
|
|
name: power-profiles-daemon
|
|
|
|
enabled: false
|
|
|
|
masked: true
|
2024-08-06 13:16:10 +00:00
|
|
|
state: stopped
|
|
|
|
when: "'power-profiles-daemon' in ansible_facts['packages']"
|
2022-11-27 06:51:39 +00:00
|
|
|
become: true
|
|
|
|
|
2024-08-06 13:08:11 +00:00
|
|
|
- name: Ensure 'tuned' is installed
|
2022-11-27 06:51:39 +00:00
|
|
|
ansible.builtin.package:
|
|
|
|
name: tuned
|
|
|
|
state: present
|
|
|
|
become: true
|
|
|
|
|
2024-08-09 13:25:54 +00:00
|
|
|
- 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] }}"
|
|
|
|
|
2023-07-08 04:45:36 +00:00
|
|
|
- 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
|
|
|
|
|
2024-08-06 13:08:11 +00:00
|
|
|
- name: Configure vars in '/etc/tuned/amdgpu-profile-vars.conf'
|
2024-08-05 13:12:02 +00:00
|
|
|
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:
|
|
|
|
- gpu_clock_min
|
|
|
|
- gpu_clock_max
|
|
|
|
- gpumem_clock_static
|
|
|
|
- gpu_power_multi_def
|
|
|
|
- gpu_power_multi_oc
|
|
|
|
- gpu_mv_offset
|
2024-08-06 13:08:11 +00:00
|
|
|
become: true
|
2024-08-05 13:12:02 +00:00
|
|
|
|
2022-11-27 06:51:39 +00:00
|
|
|
- name: Create custom profile directories
|
|
|
|
ansible.builtin.file:
|
|
|
|
state: directory
|
2024-06-29 14:40:36 +00:00
|
|
|
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:
|
2023-04-08 17:28:51 +00:00
|
|
|
- "{{ amdgpu_profiles }}"
|
2022-11-27 06:51:39 +00:00
|
|
|
- "{{ base_profiles }}"
|
|
|
|
become: true
|
|
|
|
|
2024-08-05 13:12:02 +00:00
|
|
|
- name: Template AMDGPU profile script
|
2023-07-08 04:45:36 +00:00
|
|
|
ansible.builtin.template:
|
2024-08-05 13:12:02 +00:00
|
|
|
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
|
2023-07-08 04:45:36 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0755"
|
2022-11-27 06:51:39 +00:00
|
|
|
notify: Restart tuned
|
|
|
|
become: true
|
|
|
|
|
2023-07-08 04:45:36 +00:00
|
|
|
- name: Template tuned.conf for custom profiles
|
2022-11-27 06:51:39 +00:00
|
|
|
ansible.builtin.template:
|
|
|
|
src: templates/tuned.conf.j2
|
2024-06-29 14:40:36 +00:00
|
|
|
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:
|
2023-04-08 17:28:51 +00:00
|
|
|
- "{{ amdgpu_profiles }}"
|
2022-11-27 06:51:39 +00:00
|
|
|
- "{{ base_profiles }}"
|
|
|
|
notify: Restart tuned
|
|
|
|
become: true
|
2024-08-04 19:02:27 +00:00
|
|
|
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
|
2024-03-25 00:18:00 +00:00
|
|
|
|
|
|
|
- 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'
|