# run\_once bug in 1.7.2

**URL:** <https://forum.ansible.com/t/run-once-bug-in-1-7-2/16353>\
**Category:** Ansible Project\
**Created:** [September 26, 2014, 7:30am UTC](https://forum.ansible.com/t/run-once-bug-in-1-7-2/16353 "2014-09-26T07:30:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [September 26, 2014, 7:30am UTC](https://forum.ansible.com/t/run-once-bug-in-1-7-2/16353/1 "2014-09-26T07:30:25Z")

</div>

Hi List,

We still have some issues with this bug: [https://github.com/ansible/ansible/issues/7432](https://github.com/ansible/ansible/issues/7432)

The error message itself:

```auto
TASK: [fd4_config | backup database] ****************************************** 
skipping: [ISUFD4ACCIMP01 -> {{ fd4_config_database }}]
Traceback (most recent call last):
  File "/usr/bin/ansible-playbook", line 4, in <module>
    __import__ ('pkg_resources').run_script('ansible==1.7.2', 'ansible-playbook')
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 534, in run_script
    self.require(requires)[0].run_script(script_name, ns)
  File "/usr/lib/python2.6/site-packages/pkg_resources.py", line 1438, in run_script
    execfile(script_filename, namespace, namespace)
  File "/usr/lib/python2.6/site-packages/ansible-1.7.2-py2.6.egg/EGG-INFO/scripts/ansible-playbook", line 309, in <module>
    sys.exit(main(sys.argv[1:]))
  File "/usr/lib/python2.6/site-packages/ansible-1.7.2-py2.6.egg/EGG-INFO/scripts/ansible-playbook", line 249, in main
    pb.run()
  File "/usr/lib/python2.6/site-packages/ansible-1.7.2-py2.6.egg/ansible/playbook/ __init__.py", line 339, in run
    if not self._run_play(play):
  File "/usr/lib/python2.6/site-packages/ansible-1.7.2-py2.6.egg/ansible/playbook/ __init__.py", line 695, in _run_play
    if not self._run_task(play, task, False):
  File "/usr/lib/python2.6/site-packages/ansible-1.7.2-py2.6.egg/ansible/playbook/ __init__.py", line 471, in _run_task
    results = self._run_task_internal(task)
  File "/usr/lib/python2.6/site-packages/ansible-1.7.2-py2.6.egg/ansible/playbook/ __init__.py", line 435, in _run_task_internal
    self.runner_callbacks.on_async_ok(host, res, poller.runner.vars_cache[host]['ansible_job_id'])
KeyError: 'ansible_job_id'

```

And this is the command beeing run:

```auto
- name: backup database
  shell: /usr/bin/mylvmbackup --vgname={{ fd4_config_vgname }} --lvname={{ fd4_config_lvname }} --backupdir=/tmp/mysql-backup --quiet --backuptype=tar &
  async: 90000
  poll: 0
  when: fd4_config_do_db_backup is defined
  run_once: true
  delegate_to: "{{ fd4_config_database }}"
  tags:
    - alert_web
    - importer_web
    - admin_web
    - root_web
    - war

```

It runs well on the first try, but on the second “visit” the **run\_once** simply crashes.

Ansible version: 1.7.2

I’m trying to see if there’s a workaround, in the meantime: should I re-open the ticket?

Thanks,  
Mark Maas

​

---

<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:** [September 26, 2014, 12:00pm UTC](https://forum.ansible.com/t/run-once-bug-in-1-7-2/16353/2 "2014-09-26T12:00:14Z")

</div>

This fix was applied to the development branch (1.8), not 1.7.1,and did not happen to appear in the 1.7.2 dot release.

So you could use the development branch, otherwise it’s not fixed on 1.7.1

---

<div class="post-metadata">

**Author:** ![Mark\_Maas](https://avatars.discourse-cdn.com/v4/letter/m/7c8e57/32.png) [@Mark\_Maas](https://forum.ansible.com/u/Mark_Maas)\
**Post date:** [September 26, 2014, 12:12pm UTC](https://forum.ansible.com/t/run-once-bug-in-1-7-2/16353/3 "2014-09-26T12:12:48Z")

</div>

Ah ok, excellent.

For the record (Help to someone else)

I made a task that uses run\_once and notifies a handler that would do the asynchronous poll thing.  
And then I do: - meta: flush\_handlers to get it to run then and there.
