Ansible async module issue

49 views
Skip to first unread message

Aditya

unread,
Mar 26, 2020, 5:06:14 AM3/26/20
to Ansible Development
I am working on an ansible playbook, which runs a shell script in async ( poll = 0 ) mode.

This shell script, which runs on remote host #1, calls a python program on remote host #2, which runs for a long duration.

So the flow is something like:  ansible ----> shell script on remote host #1 ----> python script on remote host #2 ( could run for a long duration )

After the python script is done executing, it writes data into files, and those file are to be copied into the #1 host from #2 using the same shell script triggered on #1 host, using "wait" command in shell script.

The #1 host shell script executes thoroughly when run from the terminal manually, and the files are copied.

But when I try this using async, and provide and async: 100 seconds time, the shell script on #1 host runs only for 100 seconds, and the shell script stops, while the python script could run for more than that duration.

Is this behavior expected?  Is there a way to "fire and forget" the shell script, so that it runs for more than the async duration?

Adam Miller

unread,
Apr 2, 2020, 12:25:36 PM4/2/20
to Aditya, Ansible Development
Yes, this is expected. The async: parameter is the timeout value
meaning "this is the longest I should wait for that async task to
complete before moving on" however the "moving on" part of that often
has implications on the remote host because the parent process should
go away when the module executing on the remote machine exits after
the timeout value is met.

If you want to allow it to run for a very long time, just jump that
number up to a high number like 14400 which would be 4 hours (in
seconds).

-AdamM

>
> --
> You received this message because you are subscribed to the Google Groups "Ansible Development" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to ansible-deve...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/ansible-devel/f87ad3e0-af76-4e8a-93c8-ab73bb1f80b0%40googlegroups.com.



--
Adam Miller
Senior Principal Software Engineer
Ansible Engineering, Red Hat Inc.
RHCP# 110-008-810
Mobile: (817) 205-3226
GitHub: maxamillion

Reply all
Reply to author
Forward
0 new messages