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

11 views
Skip to first unread message

coach...@gmail.com

unread,
Nov 14, 2017, 12:07:32 AM11/14/17
to Ansible Project
 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...


Kai Stian Olstad

unread,
Nov 14, 2017, 9:44:51 AM11/14/17
to ansible...@googlegroups.com
On Tuesday, 14 November 2017 06.07.32 CET coach...@gmail.com wrote:
> 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.


--
Kai Stian Olstad
Reply all
Reply to author
Forward
0 new messages