# facts and callback behaviour

**URL:** <https://forum.ansible.com/t/facts-and-callback-behaviour/15639>\
**Category:** Ansible Project\
**Created:** [July 9, 2014, 9:57pm UTC](https://forum.ansible.com/t/facts-and-callback-behaviour/15639 "2014-07-09T21:57:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lupindeterd](https://avatars.discourse-cdn.com/v4/letter/l/f4b2a3/32.png) [@lupindeterd](https://forum.ansible.com/u/lupindeterd)\
**Post date:** [July 9, 2014, 9:57pm UTC](https://forum.ansible.com/t/facts-and-callback-behaviour/15639/1 "2014-07-09T21:57:15Z")

</div>

Hi,

I’m testing the callback feature and somehow they data I’m after(facts) aren’t showing up anymore after couple of run. It appears that the setup module wasn’t being called anymore.

Appreciate for any pointer/hints.

`

```auto
setup/facts stopped working after a few run testing on callback feature.

####sample playbook###

[root@localhost ansible]# cat local.yml
---
- hosts: 127.0.0.1

  gather_facts: True
  tasks:

  - name: testing
    command: uptime

[root@localhost ansible]# ansible-playbook -i hosts local.yml
 
PLAY [127.0.0.1] **************************************************************

GATHERING FACTS ***************************************************************
ok: [127.0.0.1]

TASK: [testing] ***************************************************************
changed: [127.0.0.1]

PLAY RECAP ********************************************************************
127.0.0.1 : ok=2 changed=1 unreachable=0 failed=0

############ callback testing code ########

def runner_on_ok(self, host, res):
        invocation = res.get('invocation', None)
        facts = res.get('ansible_facts', None)
        with open('/tmp/runner_ok.out', 'w') as infile:
            #if invocation.get('module_name') == 'setup':
            infile.write("running on %s" % host)
            infile.write("result is %s" % invocation)
            infile.write("facts are %s" % facts)
            infile.write("results are %s" % res)

```

[root@localhost ansible]# cat /tmp/runner\_ok.out  
running on 127.0.0.1  
result is {‘module\_name’: ‘command’, ‘module\_args’: ‘uptime’}  
facts are None  
results are {u’changed’: True, u’end’: u’2014-07-09 14:52:57.339048’, u’stdout’: u’ 14:52:57 up 1:11, 1 user, load average: 0.00, 0.00, 0.00’, u’cmd’: [u’uptime’], u’rc’: 0, u’start’: u’2014-07-09 14:52:57.335572’, u’stderr’: u’‘, u’delta’: u’0:00:00.003476’, ‘invocation’: {‘module\_name’: ‘command’, ‘module\_args’: ‘uptime’}}

`

TIA,  
Lupin

---

<div class="post-metadata">

**Author:** ![Michael\_DeHaan1](https://avatars.discourse-cdn.com/v4/letter/m/5e9695/32.png) [@Michael\_DeHaan1](https://forum.ansible.com/u/Michael_DeHaan1)\
**Post date:** [July 9, 2014, 10:47pm UTC](https://forum.ansible.com/t/facts-and-callback-behaviour/15639/2 "2014-07-09T22:47:57Z")

</div>

Hmm, don’t see why that would be the case.

Reading this - there is a on “on\_setup” callback, but the “on\_runner\_ok” one should still fire.

[https://github.com/ansible/ansible/blob/devel/lib/ansible/callbacks.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/callbacks.py)

Better topic for ansible-devel in the future, BTW, if you don’t mind.

---

<div class="post-metadata">

**Author:** ![lupindeterd](https://avatars.discourse-cdn.com/v4/letter/l/f4b2a3/32.png) [@lupindeterd](https://forum.ansible.com/u/lupindeterd)\
**Post date:** [July 10, 2014, 1:49am UTC](https://forum.ansible.com/t/facts-and-callback-behaviour/15639/3 "2014-07-10T01:49:11Z")

</div>

> Hmm, don’t see why that would be the case.
> 
> Reading this - there is a on “on\_setup” callback, but the “on\_runner\_ok” one should still fire.
> 
> [https://github.com/ansible/ansible/blob/devel/lib/ansible/callbacks.py](https://github.com/ansible/ansible/blob/devel/lib/ansible/callbacks.py)
> 
> Better topic for ansible-devel in the future, BTW, if you don’t mind.

Thanks for reply and the good tool you provided :).

All this fault is all my doing, the “on\_runner\_ok” indeed fired for every successful module run thus overwrite the entry on my output file.

Cheers  
Lupin
