Can lineinfile append a string at a end of a particular line

598 views
Skip to first unread message

txa...@marketshare.com

unread,
May 26, 2015, 7:14:39 AM5/26/15
to ansible...@googlegroups.com
Hi All,

I'm new to ansible can you please help to append a string at the end of a particular line in server.xml file


String=  packetSize="65536"

line=  <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" />

I need something like this

<Connector port="8009" protocol="AJP/1.3" redirectPort="8443" packetSize="65536" />

Many Thanks
Thomas Xavier

Toshio Kuratomi

unread,
May 26, 2015, 12:45:35 PM5/26/15
to ansible...@googlegroups.com
lineinfile cannot do that but I believe the replace module can:

http://docs.ansible.com/replace_module.html

Maybe something like this:

- replace: dest=/file/name regexp='(\s+<Connector .*)(/>)$'
replace='\1 packetSize="65536" \2'

-Toshio
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-proje...@googlegroups.com.
> To post to this group, send email to ansible...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/4d5f6572-6f86-4648-b269-2e5cafcac0ac%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages