Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save hermes-pimentel/7d8a542e50d2d455c1d3c5b58f9ec2f8 to your computer and use it in GitHub Desktop.
Save hermes-pimentel/7d8a542e50d2d455c1d3c5b58f9ec2f8 to your computer and use it in GitHub Desktop.
Ansible role to set 'noop' i/o scheduler (CentOS 7)
---
- name: test if grub configured for noop i/o scheduler
command: egrep -q 'elevator=noop' /boot/grub2/grub.cfg
register: grub
changed_when: no
failed_when: grub_test.rc == 2
- name: configure grub for noop i/o scheduler
sudo: yes
command: grubby --update-kernel=ALL --args=elevator=noop
when: grub_test.rc == 1
- name: get list of block devices to test
shell: ls /sys/block/ | egrep '^([shv]|xv])d[a-z]$'
register: block_devs
changed_when: no
- name: test if block device using noop i/o scheduler
shell: cat /sys/block/{{ item }}/queue/scheduler | egrep -q '\[noop\]'
with_items: block_devs.stdout
register: noop_test
changed_when: noop_test.rc == 1
failed_when: noop_test.rc == 2
- name: set block device to use noop i/o scheduler
sudo: yes
shell: echo noop > /sys/block/{{ item }}/queue/scheduler
with_items: block_devs.stdout
when: noop_test.changed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment