Re: [ansible-project] Nested directory walking question

2014-07-24 Thread Michael DeHaan
I wouldn't shell out.

I'd call python's very handy os.path.walk with a custom function.  If you'd
like to talk about this, ansible-devel is probably a bit more on topic (and
I'm trying to spur that list into greater life).




On Thu, Jul 24, 2014 at 10:05 AM, Bill Lubanovic  wrote:

> Thanks, Michael. It looks like with_fileglob() only shows files, not
> directories, so that wouldn't work for me.
>
> I'm testing a workaround using "find" or "ls", then split() to grab ,
> , and . It would be nice to pass  and  as arguments to a task
> using the synchronize module.
>
> On Wednesday, July 23, 2014 5:18:21 PM UTC-5, Michael DeHaan wrote:
>
>> So there's already "with_fileglob" in Ansible
>>
>> - debug: msg={{ path }}
>>   with_fileglob: /path/to/files/*/*.tgz
>>
>> This isn't recursive however, despite being able to specify multiple
>> directories to read.
>>
>> It would be possible to make a lookup plugin that was, like a
>> "with_fileglob_recursive" that used the results of something like
>> os.path.walk.
>>
>> So basically yes, you need a new one.
>>
>> With_nested is for constructing nested loops and is something a bit
>> different.
>>
>>
>>
>>
>> On Wed, Jul 23, 2014 at 1:30 PM, Bill Lubanovic 
>> wrote:
>>
>>> I'd like to walk a directory hierarchy of the form ///. 
>>> is a fixed root directory, and isn't relevant. I have a number of 
>>> directories, which represent machine categories. Under each  are zero or
>>> more  directories, which are string values for that category. Finally,
>>>  is a directory hierarchy to copy to machines that match the parent
>>> / combination. For example:
>>>
>>> /tmp/test/color/red/etc/passwd
>>> /tmp/test/color/green/etc/motd
>>> /tmp/test/flavor/cinnamon/var/something
>>>
>>>  here is /tmp/test. There are two  categories (color and flavor):
>>> the first (color) has two  subdirectories (red and green) and the second
>>> (flavor) has one (cinnamon). Each  has a different  (file hierarchy)
>>> to be copied to machines that match /.
>>>
>>> How do I walk each , passing its value, its  subdirectories, and
>>> their  subdirectories to a task? I need to consider  and  together
>>> with other vars and facts (machine "colors" and "flavors") to pick target
>>> destinations for .
>>>
>>> I've looked at the various loop constructs, and see how to chain with
>>> register, but not how to populate the lists for with_nested.
>>>
>>> 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 ansible-proje...@googlegroups.com.
>>> To post to this group, send email to ansible...@googlegroups.com.
>>>
>>> To view this discussion on the web visit https://groups.google.com/d/
>>> msgid/ansible-project/5ec31b08-1b0d-4041-b867-
>>> 1c46f8c13c46%40googlegroups.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>  --
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/549f8410-17af-41a2-b7d8-5393e093d00b%40googlegroups.com
> 
> .
>
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgyUUfgeQLStOmt%2BGDHjFfRAyPZDZq1x6cyhyZzxJBJ4%3Dw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Nested directory walking question

2014-07-24 Thread Bill Lubanovic
Thanks, Michael. It looks like with_fileglob() only shows files, not 
directories, so that wouldn't work for me.

I'm testing a workaround using "find" or "ls", then split() to grab , 
, and . It would be nice to pass  and  as arguments to a task 
using the synchronize module.

On Wednesday, July 23, 2014 5:18:21 PM UTC-5, Michael DeHaan wrote:
>
> So there's already "with_fileglob" in Ansible
>
> - debug: msg={{ path }}
>   with_fileglob: /path/to/files/*/*.tgz
>
> This isn't recursive however, despite being able to specify multiple 
> directories to read.
>
> It would be possible to make a lookup plugin that was, like a 
> "with_fileglob_recursive" that used the results of something like 
> os.path.walk.
>
> So basically yes, you need a new one.
>
> With_nested is for constructing nested loops and is something a bit 
> different.
>
>
>
>
> On Wed, Jul 23, 2014 at 1:30 PM, Bill Lubanovic  > wrote:
>
>> I'd like to walk a directory hierarchy of the form ///.  
>> is a fixed root directory, and isn't relevant. I have a number of  
>> directories, which represent machine categories. Under each  are zero or 
>> more  directories, which are string values for that category. Finally, 
>>  is a directory hierarchy to copy to machines that match the parent 
>> / combination. For example:
>>
>> /tmp/test/color/red/etc/passwd
>> /tmp/test/color/green/etc/motd
>> /tmp/test/flavor/cinnamon/var/something
>>
>>  here is /tmp/test. There are two  categories (color and flavor): 
>> the first (color) has two  subdirectories (red and green) and the second 
>> (flavor) has one (cinnamon). Each  has a different  (file hierarchy) 
>> to be copied to machines that match /.
>>
>> How do I walk each , passing its value, its  subdirectories, and 
>> their  subdirectories to a task? I need to consider  and  together 
>> with other vars and facts (machine "colors" and "flavors") to pick target 
>> destinations for .
>>
>> I've looked at the various loop constructs, and see how to chain with 
>> register, but not how to populate the lists for with_nested.
>>
>> 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 ansible-proje...@googlegroups.com .
>> To post to this group, send email to ansible...@googlegroups.com 
>> .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/ansible-project/5ec31b08-1b0d-4041-b867-1c46f8c13c46%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/549f8410-17af-41a2-b7d8-5393e093d00b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: [ansible-project] Nested directory walking question

2014-07-23 Thread Michael DeHaan
So there's already "with_fileglob" in Ansible

- debug: msg={{ path }}
  with_fileglob: /path/to/files/*/*.tgz

This isn't recursive however, despite being able to specify multiple
directories to read.

It would be possible to make a lookup plugin that was, like a
"with_fileglob_recursive" that used the results of something like
os.path.walk.

So basically yes, you need a new one.

With_nested is for constructing nested loops and is something a bit
different.




On Wed, Jul 23, 2014 at 1:30 PM, Bill Lubanovic  wrote:

> I'd like to walk a directory hierarchy of the form ///.  is
> a fixed root directory, and isn't relevant. I have a number of 
> directories, which represent machine categories. Under each  are zero or
> more  directories, which are string values for that category. Finally,
>  is a directory hierarchy to copy to machines that match the parent
> / combination. For example:
>
> /tmp/test/color/red/etc/passwd
> /tmp/test/color/green/etc/motd
> /tmp/test/flavor/cinnamon/var/something
>
>  here is /tmp/test. There are two  categories (color and flavor):
> the first (color) has two  subdirectories (red and green) and the second
> (flavor) has one (cinnamon). Each  has a different  (file hierarchy)
> to be copied to machines that match /.
>
> How do I walk each , passing its value, its  subdirectories, and
> their  subdirectories to a task? I need to consider  and  together
> with other vars and facts (machine "colors" and "flavors") to pick target
> destinations for .
>
> I've looked at the various loop constructs, and see how to chain with
> register, but not how to populate the lists for with_nested.
>
> 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 ansible-project+unsubscr...@googlegroups.com.
> To post to this group, send email to ansible-project@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/5ec31b08-1b0d-4041-b867-1c46f8c13c46%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CA%2BnsWgxrgvXCEKzTOUhcNTOXHM-JAoFgctsYSiFWkYGO_3v3EA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Nested directory walking question

2014-07-23 Thread Bill Lubanovic
I'd like to walk a directory hierarchy of the form ///.  is 
a fixed root directory, and isn't relevant. I have a number of  
directories, which represent machine categories. Under each  are zero or 
more  directories, which are string values for that category. Finally, 
 is a directory hierarchy to copy to machines that match the parent 
/ combination. For example:

/tmp/test/color/red/etc/passwd
/tmp/test/color/green/etc/motd
/tmp/test/flavor/cinnamon/var/something

 here is /tmp/test. There are two  categories (color and flavor): the 
first (color) has two  subdirectories (red and green) and the second 
(flavor) has one (cinnamon). Each  has a different  (file hierarchy) 
to be copied to machines that match /.

How do I walk each , passing its value, its  subdirectories, and 
their  subdirectories to a task? I need to consider  and  together 
with other vars and facts (machine "colors" and "flavors") to pick target 
destinations for .

I've looked at the various loop constructs, and see how to chain with 
register, but not how to populate the lists for with_nested.

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 ansible-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/5ec31b08-1b0d-4041-b867-1c46f8c13c46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.