how to use lineinfile to change and also move a line using regexp

Hi ,

Is there a way that we can change the value of few lines and remove few lines using only one lineinfile module.
for example using the regexp we find the line “GSSAPIAuthentication No” and using the line we change line: “GSSAPIAuthentication yes” and few more lines to change regexp:"GSSAPIStrictAcceptorCheck yes " to
line: "GSSAPIStrictAcceptorCheck no "
But i want to remove few line in the same lineinfile like for example “PubkeyAuthentication” line should be removed…

Thanks for looking into it…

Is there a way that we can change the value of few lines and remove few
lines using only one lineinfile module.
for example using the regexp we find the line "GSSAPIAuthentication No"
and using the line we change line: "GSSAPIAuthentication yes" and few more
lines to change regexp:"GSSAPIStrictAcceptorCheck yes " to
line: "GSSAPIStrictAcceptorCheck no "

That is what lineinfile do, there are examples in the documentation.

But i want to remove few line in the same lineinfile like for example
"PubkeyAuthentication" line should be removed..

state: absent on lineinfile will make sure the line does not exist.