From 60d44e1a0188e30a86b15cd481f86f0d48673425 Mon Sep 17 00:00:00 2001 From: Michael DeHaan Date: Thu, 10 May 2012 01:50:22 -0400 Subject: [PATCH] Squashed commit of the following, plus some streamlining (MPD). commit e00368e7c65c65bed11fcaaf83fe8b093dbf492e Merge: 2ea7110 c039aa0 Author: Michael DeHaan Date: Thu May 10 01:43:10 2012 -0400 Merge branch 'devel' of https://github.com/weaselkeeper/ansible into weaselkeeper-devel commit c039aa091582cd31e206692df6f4f148394b41d6 Author: Jim Richardson Date: Fri May 11 17:55:13 2012 -0700 cleanup and simplification of ANSIBLE_REMOTE_TMP feature commit d87f15b796b799c375808edc7cc0932d7809d325 Merge: 5917aba 4c2fd25 Author: Jim Richardson Date: Fri May 11 17:30:16 2012 -0700 Merge branch 'devel' of github.com:weaselkeeper/ansible into devel commit 5917aba761af2e4163772d2d74e7efc0d169273a Author: Jim Richardson Date: Wed May 9 11:25:45 2012 -0700 ANSIBLE_REMOTE_TMP environment variable sets where ansible will stuf tmp files on remote host. Default is /var/tmp for root, and $HOME/.ansible/tmp for non-root commit 4c2fd2577769a6392187585828168bcb4a1476da Author: Jim Richardson Date: Wed May 9 11:25:45 2012 -0700 ANSIBLE_REMOTE_TMP environment variable sets where ansible will stuf tmp files on remote host. Default is /var/tmp for root, and $HOME/.ansible/tmp for non-root --- lib/ansible/constants.py | 2 ++ lib/ansible/runner.py | 14 +++++--------- 2 files changed, 7 insertions(+), 9 deletions(-) diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index aee4166906..a4c03420dc 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -23,6 +23,8 @@ DEFAULT_HOST_LIST = os.environ.get('ANSIBLE_HOSTS', '/etc/ansible/hosts') DEFAULT_MODULE_PATH = os.environ.get('ANSIBLE_LIBRARY', '/usr/share/ansible') +DEFAULT_REMOTE_TMP = os.environ.get('ANSIBLE_REMOTE_TMP', + '/$HOME/.ansible/tmp') DEFAULT_MODULE_NAME = 'command' DEFAULT_PATTERN = '*' diff --git a/lib/ansible/runner.py b/lib/ansible/runner.py index bb9e5964fc..730d8d7e41 100644 --- a/lib/ansible/runner.py +++ b/lib/ansible/runner.py @@ -247,13 +247,13 @@ class Runner(object): if self.remote_user == 'root': args = "%s metadata=/etc/ansible/setup" % args else: - args = "%s metadata=$HOME/.ansible/setup" % args + args = "%s metadata=%s/.ansible/setup" % (args, C.DEFAULT_REMOTE_TMP) else: if not 'metadata' in args: if self.remote_user == 'root': args['metadata'] = '/etc/ansible/setup' else: - args['metadata'] = "$HOME/.ansible/setup" + args['metadata'] = "%s/.ansible/setup" % C.DEFAULT_REMOTE_TMP return args # ***************************************************** @@ -667,13 +667,9 @@ class Runner(object): def _get_tmp_path(self, conn): ''' gets a temporary path on a remote box ''' - # The problem with this is that it's executed on the - # overlord, not on the target so we can't use tempdir and os.path - # Only support the *nix world for now by using the $HOME env var - - basetmp = "/var/tmp" - if self.remote_user != 'root': - basetmp = "$HOME/.ansible/tmp" + basetmp = C.DEFAULT_REMOTE_TMP + if self.remote_user == 'root': + basetmp ="/var/tmp" cmd = "mktemp -d %s/ansible.XXXXXX" % basetmp if self.remote_user != 'root': cmd = "mkdir -p %s && %s" % (basetmp, cmd)