Newbie question - parsing filenames to fetch in output of command on remote host.

Hi,

I'm just starting to experiment with ansible. A simple use case (using ansible-0.9 on a RHEL 6 control node as root with a key trusted by clients)

I'm copying a source tarball from one host to a build server (RHEL6), where I'd like to su to a build user to run 'rpmbuild -tb foo.tar.gz' , redirecting stdout and stderr to a file.

The build takes a few minutes and generates a lot of output, but eventually spits out two RPMs whose names are tied to the kernel rev. The lines are fairly easy to parse:

   Wrote: /path/to/RPM1
   Wrote: /path/to/RPM2

I'd like to copy the resulting RPMs back. I'd prefer not to construct the filenames ahead of time and simply use what rpmbuild spits out. If it errors out before this, those lines would be absent.

I'm experimenting with a playbook that copies the tarball and gets as far as calling the shell module to run 'su - builduser -c "rpmbuild ..."' which seems to work. Howver, the parsing and tokenizing of output, followed by fetching the resulting files back to the control node, is what I'm not clear on.

So, how can I achieve this with ansible (in the most elegant way)?

Thanks,
VK

So, how can I achieve this with ansible (in the most elegant way)?

Check out this thread:

https://groups.google.com/forum/?fromgroups=#!topic/ansible-project/z9iIwQ9GyT8

It covers a few ways you might deal with this. One of the ways is how
Mr. Daniel Hokka Zakrisson suggests in the thread:

Yes, the way to do it is to list the files in one action, and then use

Thanks Romeo. I will give this a shot.