From 1cf78fe7fd6de763c2591626d0d1d1cc37c41f9a Mon Sep 17 00:00:00 2001 From: Josh Lay Date: Sat, 29 Jun 2024 09:40:36 -0500 Subject: [PATCH] handle new 'tuned' profiles dir >= 2.23.0 --- roles/tuned_amdgpu/defaults/main.yml | 2 ++ roles/tuned_amdgpu/tasks/main.yml | 13 +++++++++---- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/roles/tuned_amdgpu/defaults/main.yml b/roles/tuned_amdgpu/defaults/main.yml index 6792dcb..92ffeee 100644 --- a/roles/tuned_amdgpu/defaults/main.yml +++ b/roles/tuned_amdgpu/defaults/main.yml @@ -10,3 +10,5 @@ amdgpu_profiles: - default - overclock - peak + +tuned_amdgpu_profile_dir: '/etc/tuned/profiles' # introduced in '2.23.0-1' diff --git a/roles/tuned_amdgpu/tasks/main.yml b/roles/tuned_amdgpu/tasks/main.yml index 18c3377..4a2908f 100644 --- a/roles/tuned_amdgpu/tasks/main.yml +++ b/roles/tuned_amdgpu/tasks/main.yml @@ -5,6 +5,11 @@ 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+ @@ -38,7 +43,7 @@ - name: Create custom profile directories ansible.builtin.file: state: directory - path: /etc/tuned/{{ item.1 }}-amdgpu-{{ item.0 }} + path: "{{ (tuned_amdgpu_profile_dir, item.1 + '-amdgpu-' + item.0) | ansible.builtin.path_join }}" mode: "0755" with_nested: - "{{ amdgpu_profiles }}" @@ -48,7 +53,7 @@ - name: Copy 'common' AMDGPU script for all profiles ansible.builtin.template: src: profile-common.sh.j2 - dest: "/etc/tuned/{{ item.1 }}-amdgpu-{{ item.0 }}/amdgpu-common.sh" + dest: "{{ (tuned_amdgpu_profile_dir, item.1 + '-amdgpu-' + item.0, 'amdgpu-common.sh') | ansible.builtin.path_join }}" mode: "0644" # sourced, doesn't require executable bit owner: root group: root @@ -61,7 +66,7 @@ - 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 + dest: "{{ (tuned_amdgpu_profile_dir, item.1 + '-amdgpu-' + item.0, 'amdgpu-clock.sh') | ansible.builtin.path_join }}" owner: root group: root mode: "0755" @@ -72,7 +77,7 @@ - name: Template tuned.conf for custom profiles ansible.builtin.template: src: templates/tuned.conf.j2 - dest: /etc/tuned/{{ item.1 }}-amdgpu-{{ item.0 }}/tuned.conf + dest: "{{ (tuned_amdgpu_profile_dir, item.1 + '-amdgpu-' + item.0, 'tuned.conf') | ansible.builtin.path_join }}" owner: root group: root mode: "0644"