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

107 lines
3.1 KiB
YAML

---
# tasks file for tuned_amdgpu
#
- name: Gather package facts
ansible.builtin.package_facts:
manager: auto
- 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
# note: power-profiles-daemon conflicts with tuned
# since F35 it must be removed so tuned may be installed
- name: Replace 'power-profiles-daemon' with 'tuned' on Fedora 35+
ansible.builtin.package: # use with_items/pkg since 'dnf' module in Ansible doesn't support 'swap'
name: "{{ item.name }}"
state: "{{ item.state }}"
with_items:
- {name: 'power-profiles-daemon', state: 'absent'}
- {name: 'tuned', state: 'present'}
when:
- ansible_distribution == 'Fedora'
- ansible_distribution_major_version|int > 35
register: fed_ppdtuned_swap
become: true
- name: Install tuned
ansible.builtin.package:
name: tuned
state: present
when: (fed_ppdtuned_swap is not defined) or ('tuned' not in ansible_facts.packages)
become: true
- 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 profile vars
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
- 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:
- "{{ amdgpu_profiles }}"
- "{{ 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: 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:
- "{{ amdgpu_profiles }}"
- "{{ 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'