From cb30558a41a0ebd06534d94d59706429afee50cb Mon Sep 17 00:00:00 2001
From: Matt Clay <matt@mystile.com>
Date: Fri, 2 Sep 2016 18:19:29 -0700
Subject: [PATCH] Make async_wrapper ignore '_' as an argsfile. (#4678)

This provides support for passing additional positional parameters to async_wrapper.
Additional parameters will be used by the upcoming async support for Windows.
---
 lib/ansible/modules/utilities/logic/async_wrapper.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/lib/ansible/modules/utilities/logic/async_wrapper.py b/lib/ansible/modules/utilities/logic/async_wrapper.py
index 05452b4e2cc..320b3c5895a 100644
--- a/lib/ansible/modules/utilities/logic/async_wrapper.py
+++ b/lib/ansible/modules/utilities/logic/async_wrapper.py
@@ -120,7 +120,7 @@ def _run_module(wrapped_cmd, jid, job_path):
 ####################
 if __name__ == '__main__':
 
-    if len(sys.argv) < 3:
+    if len(sys.argv) < 5:
         print(json.dumps({
             "failed" : True,
             "msg"    : "usage: async_wrapper <jid> <time_limit> <modulescript> <argsfile>.  Humans, do not call directly!"
@@ -130,8 +130,9 @@ if __name__ == '__main__':
     jid = "%s.%d" % (sys.argv[1], os.getpid())
     time_limit = sys.argv[2]
     wrapped_module = sys.argv[3]
-    if len(sys.argv) >= 5:
-        argsfile = sys.argv[4]
+    argsfile = sys.argv[4]
+    # consider underscore as no argsfile so we can support passing of additional positional parameters
+    if argsfile != '_':
         cmd = "%s %s" % (wrapped_module, argsfile)
     else:
         cmd = wrapped_module