2022-11-27 06:51:39 +00:00
|
|
|
---
|
|
|
|
# tasks file for tuned_amdgpu
|
|
|
|
#
|
|
|
|
- name: Gather package facts
|
|
|
|
ansible.builtin.package_facts:
|
|
|
|
manager: auto
|
|
|
|
|
|
|
|
# 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:
|
|
|
|
- ('power-profiles-daemon' in ansible_facts.packages) or ('tuned' not in ansible_facts.packages)
|
|
|
|
- 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
|
|
|
|
|
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
|
|
|
|
|
2022-11-27 06:51:39 +00:00
|
|
|
- name: Create custom profile directories
|
|
|
|
ansible.builtin.file:
|
|
|
|
state: directory
|
2023-04-08 17:28:51 +00:00
|
|
|
path: /etc/tuned/{{ item.1 }}-amdgpu-{{ item.0 }}
|
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
|
|
|
|
|
2023-07-08 04:45:36 +00:00
|
|
|
- name: Copy 'common' AMDGPU script for all profiles
|
|
|
|
ansible.builtin.copy:
|
|
|
|
src: profile-common.sh
|
|
|
|
dest: "/etc/tuned/{{ item.1 }}-amdgpu-{{ item.0 }}/amdgpu-common.sh"
|
|
|
|
mode: "0644" # sourced, doesn't require executable bit
|
2022-11-27 06:51:39 +00:00
|
|
|
owner: root
|
|
|
|
group: root
|
2023-07-08 04:45:36 +00:00
|
|
|
notify: Restart tuned
|
2022-11-27 06:51:39 +00:00
|
|
|
with_nested:
|
2023-04-08 17:28:51 +00:00
|
|
|
- "{{ amdgpu_profiles }}"
|
2022-11-27 06:51:39 +00:00
|
|
|
- "{{ base_profiles }}"
|
2023-07-08 04:45:36 +00:00
|
|
|
become: true
|
|
|
|
|
|
|
|
- name: Template custom AMDGPU profile scripts
|
|
|
|
ansible.builtin.template:
|
|
|
|
src: amdgpu-profile-{{ item.0 }}.sh.j2
|
|
|
|
dest: /etc/tuned/{{ item.1 }}-amdgpu-{{ item.0 }}/amdgpu-clock.sh
|
|
|
|
owner: root
|
|
|
|
group: root
|
|
|
|
mode: "0755"
|
|
|
|
loop: "{{ amdgpu_profiles | product(base_profiles) | list }}"
|
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
|
2023-04-08 17:28:51 +00:00
|
|
|
dest: /etc/tuned/{{ item.1 }}-amdgpu-{{ item.0 }}/tuned.conf
|
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
|
|
|
|
|
|
|
|
- name: Ensure tuned is enabled
|
|
|
|
ansible.builtin.service:
|
|
|
|
name: tuned
|
|
|
|
enabled: true
|
|
|
|
become: true
|