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
Register: ‘x’ = script.stdout or something?
Hab’s irgendwo gemacht, schicke dir morn ein Bispiu
Gruss
From: Ivo Hechmann
Sent: Monday, May 9, 2016 14:53
To: Ansible Project
Reply To: ansible-project@googlegroups.com
Subject: [ansible-project] Register shell output in a variable
|
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
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.
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