diff --git a/roles/tuned/handlers/main.yml b/roles/tuned/handlers/main.yml index fb4ce78..9a9188c 100644 --- a/roles/tuned/handlers/main.yml +++ b/roles/tuned/handlers/main.yml @@ -3,3 +3,6 @@ service: name: tuned state: restarted + +- name: enable tuned profile + command: "/usr/sbin/tuned-adm profile {{ tuned_custom_profile.name }}" diff --git a/roles/tuned/tasks/configure-custom-profile.yml b/roles/tuned/tasks/configure-custom-profile.yml index 73c114d..6f1286a 100644 --- a/roles/tuned/tasks/configure-custom-profile.yml +++ b/roles/tuned/tasks/configure-custom-profile.yml @@ -1,5 +1,6 @@ --- - name: create custom tuned profile directory + become: true file: path: "/etc/tuned/{{ tuned_custom_profile.name }}" state: directory @@ -8,16 +9,14 @@ mode: 0755 - name: copy custom profile configuration file + become: true template: src: custom_profile.conf.j2 dest: "/etc/tuned/{{ tuned_custom_profile.name }}/tuned.conf" owner: root group: root mode: 0644 - notify: restart tuned + notify: + - restart tuned + - enable tuned profile register: tuned_custom_profile_template - -- name: set custom tuned profile - command: "/usr/sbin/tuned-adm profile {{ tuned_custom_profile.name }}" - when: - - tuned_custom_profile_template is changed diff --git a/roles/tuned/tasks/main.yml b/roles/tuned/tasks/main.yml index 62b1542..c75baee 100644 --- a/roles/tuned/tasks/main.yml +++ b/roles/tuned/tasks/main.yml @@ -1,31 +1,35 @@ --- - name: update apt caches + become: true apt: - update_cache: yes + update_cache: true when: (ansible_os_family in ["Debian"] ) - name: install packages + become: true package: name: "{{ item }}" - state: latest + state: present with_items: - - tuned - - tuned-utils -# - tuned-profiles-realtime # only on Fedora? not on centos 8 stream + - tuned + - tuned-utils +# - tuned-profiles-realtime # only on Fedora? not on centos 8 stream - name: start service + become: true service: name: tuned - enabled: yes + enabled: true state: started - name: get active tuned profile + become: true command: /usr/sbin/tuned-adm active register: tuned_active changed_when: false ignore_errors: true -- name: deploy {{ tuned_custom_profile }} based on {{ tuned_base_profile }} - include: configure-custom-profile.yml +- 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)