tuned: release-dependent profile basedir, lint

This commit is contained in:
Josh Lay 2025-07-27 12:34:44 -05:00
parent 0c33dccba8
commit c475723f52
Signed by: jlay
SSH key fingerprint: SHA256:RwEMoWwXniQX1sqHfSD+3z+LKU/TOkv3i1qsy75vfec
4 changed files with 35 additions and 25 deletions

View file

@ -1,3 +1,5 @@
---
tuned_base_profile: "network-latency"
tuned_custom_profile: "default-custom-profile"
# profiles are expected in a subdirectory past 2.23.0; default using package facts
tuned_amdgpu_profile_dir: "{{ '/etc/tuned' if ansible_facts['packages']['tuned'][0]['version'] is version('2.23.0', '<') else '/etc/tuned/profiles' }}"

View file

@ -1,8 +1,13 @@
---
- name: restart tuned
service:
- name: Restart
ansible.builtin.service:
name: tuned
state: restarted
become: true
listen: tuned_restart
- name: enable tuned profile
command: "/usr/sbin/tuned-adm profile {{ tuned_custom_profile.name }}"
- name: Enable Profile
ansible.builtin.command: "/usr/sbin/tuned-adm profile {{ tuned_custom_profile.name }}"
become: true
changed_when: true # handler, assumed this would be making/realizing changes
listen: tuned_enable

View file

@ -1,22 +1,22 @@
---
- name: create custom tuned profile directory
- name: Ensure profile directory
become: true
file:
path: "/etc/tuned/{{ tuned_custom_profile.name }}"
ansible.builtin.file:
path: "{{ (tuned_amdgpu_profile_dir, tuned_custom_profile.name) | path_join }}"
state: directory
owner: root
group: root
mode: 0755
mode: '0755'
- name: copy custom profile configuration file
- name: Profile configuration
become: true
template:
ansible.builtin.template:
src: custom_profile.conf.j2
dest: "/etc/tuned/{{ tuned_custom_profile.name }}/tuned.conf"
dest: "{{ (tuned_amdgpu_profile_dir, tuned_custom_profile.name, 'tuned.conf') | path_join }}"
owner: root
group: root
mode: 0644
mode: '0644'
notify:
- restart tuned
- enable tuned profile
- tuned_restart
- tuned_enable
register: tuned_custom_profile_template

View file

@ -1,14 +1,14 @@
---
- name: update apt caches
- name: Update apt caches
become: true
apt:
ansible.builtin.apt:
update_cache: true
when: (ansible_os_family in ["Debian"] )
- name: install packages
- name: Install packages
become: true
package:
ansible.builtin.package:
name: "{{ item }}"
state: present
with_items:
@ -16,20 +16,23 @@
- tuned-utils
# - tuned-profiles-realtime # only on Fedora? not on centos 8 stream
- name: start service
- name: Gather Package Facts # 'tuned' release determines profile location
ansible.builtin.package_facts:
- name: Start service
become: true
service:
ansible.builtin.service:
name: tuned
enabled: true
state: started
- name: get active tuned profile
- name: Get active tuned profile
become: true
command: /usr/sbin/tuned-adm active
ansible.builtin.command: /usr/sbin/tuned-adm active
register: tuned_active
changed_when: false
ignore_errors: true
- name: deploy custom tuned profiles
include_tasks: configure-custom-profile.yml
when: (ansible_distribution in ["CentOS" , "Red Hat Enterprise Linux", "RedHat", "Fedora" ] and not is_atomic)
- name: Deploy custom tuned profiles
ansible.builtin.include_tasks: configure-custom-profile.yml
when: not ansible_local.os.is_atomic