Skip to content

0.8 -- make it possible to use with_items with the new $PIPE(cmd) syntax #983

Closed
mpdehaan opened this Issue Aug 31, 2012 · 7 comments

3 participants

@mpdehaan

It would be nice to iterate over local files.

This seems to be done best with a with_items like construct.

Proposing

with_items_from_filesystem: /path/*.foo

and maybe

with_items_from_filesystem_recursive: /path/*.foo

syntax TBD

@mpdehaan mpdehaan was assigned Aug 31, 2012
@mpdehaan

better: with_items_from_cmd: find . -name *.txt

@jpmens
jpmens commented Aug 31, 2012

with_items_from_pipe ? :)

@mpdehaan

probably better than arbitrarily dropping vowels :)

@tima
tima commented Sep 6, 2012

Why not just with_items_from?

I could see the need to have both files and commands/pipes. Try and execute the value. If that fails try and read it as a file.

@mpdehaan

new things available already are

$FILE($var) -- returns the contents of the file inline
$PIPE($cmd) -- runs a command -- may need some work

We can't use $PIPE(cmd) with with_items too well yet... I think what we want to do is detect that $PIPE is used in the with_items clause and if so, and if the stdout of the command includes a newline, convert the command results into a list.

@mpdehaan

I'm going to solve this a little differently and bring pluggable data sources forward a bit, and allow

with_items_glob: foo

where with_items_foo will look for a data module of type foo. Stay tuned, doing this now for 0.8.

$PIPE and $FILE will prob stay around for template usage, though this will be cleaner/easier.

@mpdehaan

called it with_fileglob instead, see examples/playbooks/loop_plugins.yml

@mpdehaan mpdehaan closed this Oct 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.