On Monday, December 3, 2018 at 4:48:43 PM UTC-7, Piotr Owcarz wrote:
>
> Hi
> Read the file contents with the 'file' lookup 
> https://docs.ansible.com/ansible/2.6/plugins/lookup/file.html then run 
> regexp filter on the lookup result: 
> https://docs.ansible.com/ansible/2.5/user_guide/playbooks_filters.html#regular-expression-filters
> eg: "{{ lookup('file', '/path/to/file') | regex_findall('(\w+.img)') }}"
>
> Piotr
>
>
>
> wt., 4 gru 2018 o 00:33 John Harmon <[email protected] <javascript:>> 
> napisaƂ(a):
>
>> I have a file, as an example, with the following content:
>> disk = [file:/OVS/Repositories/0004fb0000030000df2ee11376f1cd94/
>> VirtualDisks/b7558d7745c14b02806d08f8003906e1.img,xvda,w,phy:/OVS/
>> Repositories/0004fb0000030000df2ee11376f1cd94/VirtualDisks/
>> 0004fb0000120000049ec392e534e039,xvdb,w,file:/OVS/Repositories/
>> 0004fb0000030000df2ee11376f1cd94/VirtualDisks/
>> 0004fb0000120000843bb7e2fe395f24.img,xvdc,w]
>>
>> I wish to find all instances of image files, and build a list with them.  
>> Here is my regexp:
>> (\w+.img)
>>
>> Here is a regexp tester with all of the above:
>> https://regex101.com/r/UKcYIa/3
>>
>> I know that I can do this with shell, or similar modules, but I wish to 
>> do this in a more ansible-native way (if there is one).   Is there a module 
>> that will allow me to search a file with a regular expression and then 
>> register the results to a variable?  I just want to build a list of *img 
>> files (can be more than 1 and probably wont exceed 10) so that I can 
>> manipulate them later.
>>
>> -- 
>> 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:>.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/fca87b68-ce68-4c14-840c-ecfba3a7664b%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/ansible-project/fca87b68-ce68-4c14-840c-ecfba3a7664b%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
Great!  Thank you. 

-- 
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/8bb963ff-c6b0-4e93-8355-897b2152a66a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to