-
-
Save hardcore/97de020736e6585abcfac74a274fcf61 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--- | |
- name: Test regex | |
hosts: localhost | |
connection: local | |
become: true | |
vars: | |
default_grub_line: balancing=disable | |
tasks: | |
- name: Disable balancing | |
ansible.builtin.lineinfile: | |
path: /etc/default/grub | |
backrefs: true | |
regexp: '^(GRUB_DEFAULT=)"(?!.*\b{{ default_grub_line }}\b)(root=/dev/sda)"$' | |
line: '\1"{{ default_grub_line }} \2"' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
BEFORE:
GRUB_DEFAULT="root=/dev/sda"
AFTER:
GRUB_DEFAULT="balancing=disable root=/dev/sda"