blockinfile (new in ansible 2.0) - how to insert block before the first match of specified regular expression?

199 views
Skip to first unread message

rell...@gmail.com

unread,
Mar 4, 2016, 12:38:20 AM3/4/16
to Ansible Project
Hi, all

I notice that ansible 2.0 has new module - blockinfile. I want to use it to insert a block into remote xml file. 

My requirement is to insert block before the first match of specified regular expression, one xml tag.

But the document of blockinfile says the block will be inserted before the last match of specified regular expression. 

If I make this specified regular expression is unique, the expression would be two lines. It seems not work.

If blockinfile can define the insert place with the first match or the last match, it would be better.

So far, do you have any suggestion to implement my requirement with ansible?

-- Rella
Reply all
Reply to author
Forward
0 new messages