Regular Expressions 101

Community Patterns

For VM - Match on grub if elevator=noop is present or not

0

Regular Expression
Python

r"
^(GRUB_CMDLINE_LINUX_DEFAULT=(?!.*elevator=noop).*)\"
"
gm

Description

  • name: OPITMIZ | GRUB | Set DISK Scheduler a elevator=noop lineinfile: dest: /etc/default/grub regexp: '^(GRUB_CMDLINE_LINUX_DEFAULT=(?!.elevator=noop).)"' line: '\1 elevator=noop"' backrefs: yes register: shceduler notify: update-grub tags: optimization,disk,scheduler,test

  • name: OPITMIZ | VERIF | Get list of block devices to test shell: ls /sys/block/ | egrep '^([shv]|xv])d[a-z]$' register: block_devs changed_when: no tags: optimization,disk,scheduler,test

  • name: OPITMIZ | VERIF | Test if block device using noop i/o scheduler shell: cat /sys/block/{{ item }}/queue/scheduler with_items: '{{ block_devs.stdout }}' register: noop_test tags: optimization,disk,scheduler,test

  • name: OPITMIZ | VERIF | Check eleavtor status debug: var=noop_test.results[0].stdout tags: optimization,disk,scheduler,test

Submitted by Pintax - 7 years ago