Help writing remote command result to file.

I am having problems doing something I think it should be really easy.

I am writting a rule that remote execs a command and I want the results stored locally. (It is an nmap command)

I think I could do it two rules, one command rule and one fetch rule to download de result, but I do not like it because I should find a temp original non used multiprocess safe remote path to store the result.

I know I can register one variable in rules file with stdout command result, but I do not find some way to store this variable in a local file, that is what i finally want.

Is there any way to do that?

thanks,
txemi

I’d be tempted to use the template module with a template that just outputs a variable, and pass the results.stdout as that variable.

If you have further questions, this is really a topic for ansible-project list rather than ansible-devel.

Will

Thanks, I will post nest questions in ansible-project.

"copy" module with "content" argument worked for me. The only thing is
that "ntop.stdout" was not raw "[" formatted instead and copy module
complaint about that.

- command: nmap -T4 -F -oX -
${ansible_eth0.ipv4.network}/${ansible_eth0.ipv4.netmask}
  register: nmap
- local_action: copy content="${nmap.stdout}"
dest=${rootdir}/data/nodes/${nodename}/scans/${filename}

complains:

failed: [192.168.57.101] => {"failed": true}
msg: this module requires key=value arguments (['content=<?xml version=1.0?...

Public service announcement:

Old style ${foo} variables are deprecated since 1.4 and should be expressed as {{ foo }}

The old style will no longer work in 1.6