Re: [ansible-project] Inventory scripts: How to add debug info when run via Ansible?

2019-01-03 Thread Hugo Gonzalez

Hi Jimmy,

On 12/27/18 5:57 AM, Jimmy Htor wrote:

Hey,

The way I see it you either output to STDOUT, which would make debug 
output part of the inventory data, thus corrupt it. Or you output to 
STDERR and Ansible will treat is as actual errors (and show it using 
red color).


Is there another way to cleanly provide debug info during an Ansible 
run besides writing to a file?



JSON doesn't support comments, but you can create a dummy variable 
called _comment and put your debugging messages there, right in the 
JSON. An unused variable won't mess up your inventory data.



Another option is to use theĀ  syslog facility for whatever language 
you're writing the inventory script in.


In bash, it would be :

$ logger "spam and eggs happened"


Cheers,


Hugo



--

Hugo F. gonzalez

Senior Consultant

Red Hat LATAM 





--
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/ed62e50d-7450-efbc-bd9a-6c0598547d75%40redhat.com.
For more options, visit https://groups.google.com/d/optout.


[ansible-project] Inventory scripts: How to add debug info when run via Ansible?

2018-12-27 Thread Jimmy Htor
Hey,

The way I see it you either output to STDOUT, which would make debug output 
part of the inventory data, thus corrupt it. Or you output to STDERR and 
Ansible will treat is as actual errors (and show it using red color).

Is there another way to cleanly provide debug info during an Ansible run 
besides writing to a file?

Thx

-- 
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-project+unsubscr...@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c90a4a18-459b-45d7-8d48-3d4790595b46%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.