# How to start a background task in Ansible 2.x through the API?

**URL:** <https://forum.ansible.com/t/how-to-start-a-background-task-in-ansible-2-x-through-the-api/23718>\
**Category:** Ansible Project\
**Created:** [February 13, 2017, 1:48pm UTC](https://forum.ansible.com/t/how-to-start-a-background-task-in-ansible-2-x-through-the-api/23718 "2017-02-13T13:48:34Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![fhd](https://avatars.discourse-cdn.com/v4/letter/f/3bc359/32.png) [@fhd](https://forum.ansible.com/u/fhd)\
**Post date:** [February 13, 2017, 1:48pm UTC](https://forum.ansible.com/t/how-to-start-a-background-task-in-ansible-2-x-through-the-api/23718/1 "2017-02-13T13:48:34Z")

</div>

Before Ansible 2, one could run a background module like so:

self.runner = ansible.runner.Runner(  
module\_name=self.module\_name,  
module\_args=self.module\_args,  
pattern=self.pattern,  
forks=self.forks,  
sudo=True,  
background=self.background)

How can I get the same background functionality in Ansible 2? I’ve looked at all of the possible Options params and can’t seem to find it.

---

<div class="post-metadata">

**Author:** ![sivel](https://sea1.discourse-cdn.com/ansible/user_avatar/forum.ansible.com/sivel/32/1198_2.png) [@sivel](https://forum.ansible.com/u/sivel)\
**Post date:** [February 14, 2017, 3:57pm UTC](https://forum.ansible.com/t/how-to-start-a-background-task-in-ansible-2-x-through-the-api/23718/2 "2017-02-14T15:57:20Z")

</div>

In the example at [http://docs.ansible.com/ansible/dev\_guide/developing\_api.html#python-api-2-0](http://docs.ansible.com/ansible/dev_guide/developing_api.html#python-api-2-0)

You would use `async` in building your tasks defined in the `play_source` dict. Effectively in 2.x you are building a play, and that play is where you put those options.
