Sorry to dig out an old post but Michael would an enhancement to the regex 
plugin to do multi line be accepted? Seems like pretty useful functionality 
and the re module in python has a find_iter for just the task...



On Saturday, January 4, 2014 11:25:24 PM UTC+5:30, Philippe Eveque wrote:
>
> another way not as optimal as using sed like proposed by Michael is 
> to do it via 2 tasks.
>
> tasks 1: count the number of lines to replace (via shell module using and 
> grep -E <regexp> | wc -l )
>  using register to remember the linecounted
>
> task 2: using lineinfile and with_sequence: linecounted
>
> one caveat is that with sequence does not accept a 0 count ( a potential 
> future improvement ?) 
>
> so just add  1 to the count (you do not care about doing it one more time)
>
> then you can run those 2 tasks multiples times
>
> works for me on grub.conf 
>
>
>
>
>
>
>
>
> 2014/1/4 Michael DeHaan <[email protected] <javascript:>>
>
>> It seems you would just use the shell module and invoke sed.
>>
>>
>>
>> On Sat, Jan 4, 2014 at 1:04 AM, eskhool <[email protected] 
>> <javascript:>> wrote:
>>
>>> Hi,
>>>  If we don't have the option to use templates as the file may vary 
>>> across system, is there a way to find and replace multiple lines based on a 
>>> regex...something like an option in lineinfile such as 'all'. What other 
>>> mechanism can be recommended? Any reason to not have this option? And if 
>>> contributed will such a change be accepted in ansible core?
>>>
>>> Thanks
>>>
>>> -- 
>>> 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 [email protected] <javascript:>.
>>> To post to this group, send email to [email protected] 
>>> <javascript:>.
>>> For more options, visit https://groups.google.com/groups/opt_out.
>>>
>>
>>
>>
>> -- 
>> Michael DeHaan <[email protected] <javascript:>>
>> CTO, AnsibleWorks, Inc.
>> http://www.ansibleworks.com/
>>
>>  -- 
>> 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 [email protected] <javascript:>.
>> To post to this group, send email to [email protected] 
>> <javascript:>.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>
>

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c42cc74a-15be-4e8a-b049-9801b0e1126e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to