Also don't forget to add the "ignore_errors: yes" parameter, otherwise your 
play will just exit in error if the string isn't found.

On Friday, May 2, 2014 at 12:11:19 AM UTC+10, Peter Leggett wrote:
>
>  Hi,
>
> how can i execute a ansible task only if a file contains a specfic regexp ?
> I was hoping to use the when: statement as follows :-
>
> - name: do this task only if file contains fred
>   command: some command
>   when: file contains "fred"
>
> Can something like this work ? Thanks for any help.
>
> Pete
>
>

-- 
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/46302287-9503-4ebd-94a4-a510395946dd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to