Commit 2b909b4e by Brian Coca

Merge pull request #11888 from zfil/fix-patch-plugin

patch runner action plugin in ansible 1.9.x is broken with remote source patch file
parents 6e430651 74bf6704
...@@ -16,6 +16,7 @@ ...@@ -16,6 +16,7 @@
import os import os
from ansible import utils from ansible import utils
import ansible.constants as C
from ansible.runner.return_data import ReturnData from ansible.runner.return_data import ReturnData
class ActionModule(object): class ActionModule(object):
...@@ -32,7 +33,7 @@ class ActionModule(object): ...@@ -32,7 +33,7 @@ class ActionModule(object):
src = options.get('src', None) src = options.get('src', None)
dest = options.get('dest', None) dest = options.get('dest', None)
remote_src = utils.boolean(options.get('remote_src', 'yes')) remote_src = utils.boolean(options.get('remote_src', 'no'))
if src is None: if src is None:
result = dict(failed=True, msg="src is required") result = dict(failed=True, msg="src is required")
...@@ -47,12 +48,13 @@ class ActionModule(object): ...@@ -47,12 +48,13 @@ class ActionModule(object):
else: else:
src = utils.path_dwim(self.runner.basedir, src) src = utils.path_dwim(self.runner.basedir, src)
tmp_src = tmp + src tmp_path = self.runner._make_tmp_path(conn)
tmp_src = tmp_path + 'patch_source'
conn.put_file(src, tmp_src) conn.put_file(src, tmp_src)
if self.runner.become and self.runner.become_user != 'root': if self.runner.become and self.runner.become_user != 'root':
if not self.runner.noop_on_check(inject): if not self.runner.noop_on_check(inject):
self.runner._remote_chmod(conn, 'a+r', tmp_src, tmp) self.runner._remote_chmod(conn, 'a+r', tmp_src, tmp_path)
new_module_args = dict( new_module_args = dict(
src=tmp_src, src=tmp_src,
...@@ -63,4 +65,8 @@ class ActionModule(object): ...@@ -63,4 +65,8 @@ class ActionModule(object):
module_args = utils.merge_module_args(module_args, new_module_args) module_args = utils.merge_module_args(module_args, new_module_args)
return self.runner._execute_module(conn, tmp, 'patch', module_args, inject=inject, complex_args=complex_args) data = self.runner._execute_module(conn, tmp, 'patch', module_args, inject=inject, complex_args=complex_args)
if not C.DEFAULT_KEEP_REMOTE_FILES:
self.runner._remove_tmp_path(conn, tmp_path)
return data
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment