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

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