# Inventory scripts: How to add debug info when run via Ansible?

**URL:** <https://forum.ansible.com/t/inventory-scripts-how-to-add-debug-info-when-run-via-ansible/29334>\
**Category:** Ansible Project\
**Created:** [December 27, 2018, 11:57am UTC](https://forum.ansible.com/t/inventory-scripts-how-to-add-debug-info-when-run-via-ansible/29334 "2018-12-27T11:57:41Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jimmy\_Htor](https://avatars.discourse-cdn.com/v4/letter/j/d07c76/32.png) [@Jimmy\_Htor](https://forum.ansible.com/u/Jimmy_Htor)\
**Post date:** [December 27, 2018, 11:57am UTC](https://forum.ansible.com/t/inventory-scripts-how-to-add-debug-info-when-run-via-ansible/29334/1 "2018-12-27T11:57:41Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Matthieu\_Ducorps](https://avatars.discourse-cdn.com/v4/letter/m/a8b319/32.png) [@Matthieu\_Ducorps](https://forum.ansible.com/u/Matthieu_Ducorps)\
**Post date:** [January 1, 2019, 8:37am UTC](https://forum.ansible.com/t/inventory-scripts-how-to-add-debug-info-when-run-via-ansible/29334/2 "2019-01-01T08:37:19Z")

</div>

Hello Jimmy,

Not sure if it’s what you are looking for, when you run a playbook you can use the [debugger](https://docs.ansible.com/ansible/latest/user_guide/playbooks_debugger.html?highlight=debugger)for the whole playbook or each task.

You can also use the [register variable](https://docs.ansible.com/ansible/latest/user_guide/playbooks_conditionals.html?highlight=register#register-variables) to do what every you want with what is Ansible-playbook run feedback

hope that help.

Matth

---

<div class="post-metadata">

**Author:** ![Francis\_Santos](https://avatars.discourse-cdn.com/v4/letter/f/49beb7/32.png) [@Francis\_Santos](https://forum.ansible.com/u/Francis_Santos)\
**Post date:** [January 3, 2019, 5:45pm UTC](https://forum.ansible.com/t/inventory-scripts-how-to-add-debug-info-when-run-via-ansible/29334/3 "2019-01-03T17:45:17Z")

</div>

Is this what you are looking for?

tasks:

- name: enabling consul  
service: name=consul enabled=yes state=started  
when:

- service: name=consul state=stopped  
**register: results ### stores output on a variable**  
ignore\_errors: yes

- name: show results of disabling consul

**debug: msg={{ results }} ### shows that output when ansible is played**

- name: logging the results  
**shell: echo {{ results }} \>\> /var/log/fixing ### saves that output in a log**

---

<div class="post-metadata">

**Author:** ![hugonz](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/hugonz/32/503_2.png) [@hugonz](https://forum.ansible.com/u/hugonz)\
**Post date:** [January 3, 2019, 9:41pm UTC](https://forum.ansible.com/t/inventory-scripts-how-to-add-debug-info-when-run-via-ansible/29334/4 "2019-01-03T21:41:47Z")

</div>

Hi Jimmy,
