regex – Ansible lineinfile regexp line with many spaces
I have a line in a configuration file that I would like to change by removing the comment.
/etc/pam.d/su
#%PAM-1.0
auth sufficient pam_rootok.so
# Uncomment the following line to implicitly trust users in the "wheel" group.
#auth sufficient pam_wheel.so trust use_uid
# Uncomment the following line to require a user to be in the "wheel" group.
#auth required pam_wheel.so use_uid
auth substack system-auth
auth include postlogin
account sufficient pam_succeed_if.so uid = 0 use_uid quiet
...
I need to remove the comment only from the line
#auth required pam_wheel.so use_uid
but regexp does not find the string if I write it completely with spaces.
I use the below code:
- name: Modify PAM
ansible.builtin.lineinfile:
path: /etc/pam.d/su
regexp: '^#auth required pam_wheel.so use_uid'
line: 'auth required pam_wheel.so use_uid'
backrefs: true
backup: true
If I remove backrefs, the line is created below, but I would like to replace the line.
Read more here: Source link
