tuned - add custom profile support, udev/io sched. example

This commit is contained in:
Josh Lay 2020-06-03 21:15:43 -05:00
parent a3cd18f090
commit 9406e7ddfb
6 changed files with 71 additions and 0 deletions

View file

@ -1,5 +1,22 @@
--- ---
- hosts: all - hosts: all
vars:
tuned_base_profile: "network-latency"
tuned_custom_profile:
name: tweaks
sections:
- name: main
params:
- option: summary
value: "Custom tuned profile created by jlay - virt. IO scheduler, TCP, etc"
- option: include
value: "{{ tuned_base_profile }}"
- name: disk
params:
- option: devices_udev_regex
value: "(ID_MODEL=QEMU_HARDDISK)|(ID_VENDOR=HC)"
- option: elevator
value: "mq-deadline"
roles: roles:
- {role: bootstrap} - {role: bootstrap}
- {role: tmp-mount-fix} - {role: tmp-mount-fix}

View file

@ -0,0 +1,3 @@
---
tuned_base_profile: "network-latency"
tuned_custom_profile: "default-custom-profile"

View file

@ -0,0 +1,5 @@
---
- name: restart tuned
service:
name: tuned
state: restarted

View file

@ -0,0 +1,25 @@
# borrowed from https://github.com/giovtorres/ansible-role-tuned/
# trivially changed based on style preferences
---
- name: create custom tuned profile directory
file:
path: "/etc/tuned/{{ tuned_custom_profile.name }}"
state: directory
owner: root
group: root
mode: 0755
- name: copy custom profile configuration file
template:
src: custom_profile.conf.j2
dest: "/etc/tuned/{{ tuned_custom_profile.name }}/tuned.conf"
owner: root
group: root
mode: 0644
notify: restart tuned
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

View file

@ -13,3 +13,12 @@
name: tuned name: tuned
enabled: yes enabled: yes
state: started state: started
- name: get active tuned profile
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

View file

@ -0,0 +1,12 @@
{{ ansible_managed | comment }}
#
# tuned '{{ tuned_custom_profile.name }}' configuration
#
{% for section in tuned_custom_profile.sections %}
[{{ section.name }}]
{% for item in section.params %}
{{ item.option }}={{ item.value }}
{% endfor %}
{% endfor %}