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

26 views
Skip to first unread message

fhd

unread,
Feb 13, 2017, 9:07:12 AM2/13/17
to Ansible Project
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.

Matt Martz

unread,
Feb 14, 2017, 10:58:13 AM2/14/17
to ansible...@googlegroups.com
In the example at 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.

--
You received this message because you are subscribed to the Google Groups "Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email to ansible-project+unsubscribe@googlegroups.com.
To post to this group, send email to ansible-project@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-project/4159d0b7-482b-4c98-8641-c9c0fb5a2f78%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Matt Martz
@sivel
sivel.net
Reply all
Reply to author
Forward
0 new messages