Itβs hard for me to believe that in this case there is nothing to use, but my search turned out to be fruitless.
I have a line in /etc/fstab to install a disk that is no longer available:
//archive/Pipeline /pipeline/Archives cifs ro,credentials=/home/username/.config/cifs 0 0
I want to change it to
I used this
--- - hosts: slurm remote_user: root tasks: - name: Comment out pipeline archive in fstab lineinfile: dest: /etc/fstab regexp: '^//archive/pipeline' line: '#//archive/pipeline' state: present tags: update-fstab
expecting it to just insert a comment character (#), but instead it replaced the whole line, and I ended up with
is there a way glob-capture the rest of the line or just insert a single char comment?
regexp: '^//archive/pipeline *' line: '#//archive/pipeline *'
or
regexp: '^//archive/pipeline *' line: '#//archive/pipeline $1'
I am trying to wrap my head around lineinfile and from what I read, it seems that insertafter is what I am looking for, but "insert after" is not what I want?
source share