---
# tasks file for ansible-role-disk-scheduler
#
 - name: get list of block devices to test
   shell: ls /sys/block/ | egrep '^([shv]|xv)d[a-z]$'
   register: block_devs
   changed_when: no
   check_mode: no

 - name: test if block device using variable disk_scheduler as i/o scheduler
   shell: cat /sys/block/{{ item }}/queue/scheduler | egrep -q '\[{{ disk_scheduler }}\]'
   with_items: "{{ block_devs.stdout_lines }}"
   register: noop_test
   changed_when: noop_test.rc == 1
   failed_when: noop_test.rc == 2

 - name: set block device to use variable disk_scheduler as i/o scheduler
   become: yes
   shell: echo {{ disk_scheduler }} > /sys/block/{{ item }}/queue/scheduler
   with_items: "{{ block_devs.stdout_lines }}"
   when: noop_test.changed


---
# tasks file for ansible-role-disk-scheduler
#
 - name: get list of block devices to test
   shell: ls /sys/block/ | egrep '^(([shv]|xv)d[a-z])|(nvme[0-9a-z]+)$'
   register: block_devs
   changed_when: no
   check_mode: no

 - name: test if block device using variable disk_scheduler as i/o scheduler
   shell: cat /sys/block/{{ item }}/queue/scheduler | egrep -q '\[{{ disk_scheduler }}\]'
   with_items: "{{ block_devs.stdout_lines }}"
   register: noop_test
   changed_when: noop_test.rc == 1
   failed_when: noop_test.rc == 2

 - name: set block device to use variable disk_scheduler as i/o scheduler
   become: yes
   shell: echo {{ disk_scheduler }} > /sys/block/{{ item }}/queue/scheduler
   with_items: "{{ block_devs.stdout_lines }}"
   when: noop_test.changed


Add support for NVMe disks
Add support for NVMe disks