# Can a Callback change the output of a module

**URL:** <https://forum.ansible.com/t/can-a-callback-change-the-output-of-a-module/22376>\
**Category:** Ansible Developer\
**Created:** [August 24, 2016, 11:16pm UTC](https://forum.ansible.com/t/can-a-callback-change-the-output-of-a-module/22376 "2016-08-24T23:16:02Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Damien\_Garros](https://avatars.discourse-cdn.com/v4/letter/d/73ab20/32.png) [@Damien\_Garros](https://forum.ansible.com/u/Damien_Garros)\
**Post date:** [August 24, 2016, 11:16pm UTC](https://forum.ansible.com/t/can-a-callback-change-the-output-of-a-module/22376/1 "2016-08-24T23:16:02Z")

</div>

Hi

I’m trying to build my own Callback plugin and I’m still struggling to understand if it’s possible to modify the JSON structured returned by a module within a Callback plugin or not.  
I would like to collect information from all tasks and process them at the end to determine if a specific task should return PASS or FAIL

BTW, is there an API doc available for the Callback plugin ? that would be very useful.

Thanks  
Damien

---

<div class="post-metadata">

**Author:** ![James\_Cammarata](https://avatars.discourse-cdn.com/v4/letter/j/7c8e57/32.png) [@James\_Cammarata](https://forum.ansible.com/u/James_Cammarata)\
**Post date:** [August 25, 2016, 3:12am UTC](https://forum.ansible.com/t/can-a-callback-change-the-output-of-a-module/22376/2 "2016-08-25T03:12:50Z")

</div>

Short answer: no. Callbacks were designed to receive data, not feed data back into the executor engine. Now, some users have found ways to make callbacks do some tricky things, but it’s definitely not their intended purpose.

As for docs, unfortunately not yet. We’ve got better developer docs on the top of our documentation todo list, as well as API documentation, so hopefully we’ll see some improvement there within the next couple of releases.

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [August 25, 2016, 6:58am UTC](https://forum.ansible.com/t/can-a-callback-change-the-output-of-a-module/22376/3 "2016-08-25T06:58:15Z")

</div>

Callbacks really seem to be intended for reporting and generating specific output but this sounds like an interesting thing that you are attempting to achieve - can you describe it any more detail just in case there’s another way to solve the problem?

From what you’ve said it might be possible that failed\_when meets your needs: [http://docs.ansible.com/ansible/playbooks\_error\_handling.html](http://docs.ansible.com/ansible/playbooks_error_handling.html) although I get the impression you are trying something more sophisticated.

Jon

---

<div class="post-metadata">

**Author:** ![Brian\_Coca](https://avatars.discourse-cdn.com/v4/letter/b/6de8d8/32.png) [@Brian\_Coca](https://forum.ansible.com/u/Brian_Coca)\
**Post date:** [August 25, 2016, 12:54pm UTC](https://forum.ansible.com/t/can-a-callback-change-the-output-of-a-module/22376/4 "2016-08-25T12:54:21Z")

</div>

changed\_when/failed\_when are there to deal with modifying a task output status, callbacks execute AFTER this happens, so even if you modify the data it won’t modify the actual status of the tasks.
