From afed19e036bfd57c425c58fa7c845f1bdb3ef9ad Mon Sep 17 00:00:00 2001 From: Chris Hammer Date: Mon, 1 Jul 2024 17:21:59 -0400 Subject: [PATCH] restore lineinfile method --- tasks/cleanup.yml | 22 ++++++---------------- tasks/main.yml | 28 +++++++++------------------- 2 files changed, 15 insertions(+), 35 deletions(-) diff --git a/tasks/cleanup.yml b/tasks/cleanup.yml index 8b2ee13..45527ec 100644 --- a/tasks/cleanup.yml +++ b/tasks/cleanup.yml @@ -1,17 +1,7 @@ --- -# - name: Cleanup /etc/default/grub to remove fsck -# ansible.builtin.replace: -# path: /etc/default/grub -# regexp: '(GRUB_CMDLINE_LINUX=".*)\s+(fsck\.mode=force)\s+(fsck.repair=yes)(.*")' -# replace: '\1\4' -# notify: Update_Grub - -- name: Remove fsck args from Grub - ansible.builtin.command: - cmd: grubby --remove-args="fsck.mode=force fsck.repair=yes" --update-kernel=ALL - changed_when: false - register: autofsck_grubby_rm_args - -- name: Debug autofsck_grubby_rm_args - ansible.builtin.debug: - var: autofsck_grubby_rm_args +- name: Cleanup /etc/default/grub to remove fsck + ansible.builtin.replace: + path: /etc/default/grub + regexp: '(GRUB_CMDLINE_LINUX=".*)\s+(fsck\.mode=force)\s+(fsck.repair=yes)(.*")' + replace: '\1\4' + notify: Update_Grub diff --git a/tasks/main.yml b/tasks/main.yml index 25c2e02..5aafc17 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,20 +1,10 @@ --- -# - name: Configure /etc/default/grub for fsck -# ansible.builtin.lineinfile: -# state: present -# dest: /etc/default/grub -# backrefs: true -# regexp: '^(GRUB_CMDLINE_LINUX=(?!.* fsck)\"[^\"]+)(\".*)' -# line: '\1 fsck.mode=force fsck.repair=yes\2' -# backup: true -# notify: Update_Grub - -- name: Configure Grub args for fsck - ansible.builtin.command: - cmd: grubby --args="fsck.mode=force fsck.repair=yes" --update-kernel=ALL - changed_when: false - register: autofsck_grubby_add_args - -- name: Debug autofsck_grubby_add_args - ansible.builtin.debug: - var: autofsck_grubby_add_args +- name: Configure /etc/default/grub for fsck + ansible.builtin.lineinfile: + state: present + dest: /etc/default/grub + backrefs: true + regexp: '^(GRUB_CMDLINE_LINUX=(?!.* fsck)\"[^\"]+)(\".*)' + line: '\1 fsck.mode=force fsck.repair=yes\2' + backup: true + notify: Update_Grub