Register shell output in a variable

132 views
Skip to first unread message

Ivo Hechmann

unread,
May 9, 2016, 8:53:15 AM5/9/16
to Ansible Project
Hello team ansible

How can I register the output of a script in a variable? Thus, not the script result object with all its attributes like stdout, stderr etc, but only catch the stdout and register as variable?

Thank you very much for any hints...

Ivo 

J Hawkesworth

unread,
May 9, 2016, 10:48:19 AM5/9/16
to Ansible Project
You could use set_fact to store just the stdout into another variable, but personally I wouldn't bother - you can just ignore the bits of the register output that you don't care about.

Petre Bandac

unread,
May 9, 2016, 10:51:23 AM5/9/16
to Ivo Hechmann
Register: 'x' = script.stdout or something? :)

Hab's irgendwo gemacht, schicke dir morn ein Bispiu

Gruss :)
--
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/25f9684c-4005-4b74-b1af-057ee6a3ad96%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Ivo Hechmann

unread,
May 10, 2016, 8:47:44 AM5/10/16
to Ansible Project
set_fact did the trick. We have splitted our playbooks in roles. Depending on the job, the "version" variable is defined or undefined (but required, and can be retrieved by another script). With set_fact I was able to define the variable as variable and not as task result.

Thank you
ivo
Reply all
Reply to author
Forward
0 new messages