From 5183417de865419d1352ddb107a45749966d78f1 Mon Sep 17 00:00:00 2001 From: Daniel Hokka Zakrisson Date: Sun, 18 Nov 2012 18:25:10 +0100 Subject: [PATCH] Reinstate ANSIBLE_KEEP_REMOTE_FILES Fixes #1395. --- lib/ansible/constants.py | 1 + lib/ansible/runner/__init__.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index 26d4bbb4b8b..85e33277646 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -89,6 +89,7 @@ DEFAULT_TRANSPORT = get_config(p, DEFAULTS, 'transport', 'ANSIBLE DEFAULT_SCP_IF_SSH = get_config(p, 'ssh_connection', 'scp_if_ssh', 'ANSIBLE_SCP_IF_SSH', False) DEFAULT_MANAGED_STR = get_config(p, DEFAULTS, 'ansible_managed', None, 'Ansible managed: {file} modified on %Y-%m-%d %H:%M:%S by {uid} on {host}') DEFAULT_SYSLOG_FACILITY = get_config(p, DEFAULTS, 'syslog_facility', 'ANSIBLE_SYSLOG_FACILITY', 'LOG_USER') +DEFAULT_KEEP_REMOTE_FILES = get_config(p, DEFAULTS, 'keep_remote_files', 'ANSIBLE_KEEP_REMOTE_FILES', '0') DEFAULT_ACTION_PLUGIN_PATH = shell_expand_path(get_config(p, DEFAULTS, 'action_plugins', None, '/usr/share/ansible_plugins/action_plugins')) DEFAULT_CALLBACK_PLUGIN_PATH = shell_expand_path(get_config(p, DEFAULTS, 'callback_plugins', None, '/usr/share/ansible_plugins/callback_plugins')) diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py index 2ec86c3cfb0..3a151a868c9 100644 --- a/lib/ansible/runner/__init__.py +++ b/lib/ansible/runner/__init__.py @@ -217,7 +217,7 @@ class Runner(object): raise errors.AnsibleError("module is missing interpreter line") cmd = shebang.replace("#!","") + " " + cmd - if tmp.find("tmp") != -1: + if tmp.find("tmp") != -1 and C.DEFAULT_KEEP_REMOTE_FILES == '1': cmd = cmd + "; rm -rf %s >/dev/null 2>&1" % tmp res = self._low_level_exec_command(conn, cmd, tmp, sudoable=True) return ReturnData(conn=conn, result=res)