From c039aa091582cd31e206692df6f4f148394b41d6 Mon Sep 17 00:00:00 2001 From: Jim Richardson Date: Fri, 11 May 2012 17:55:13 -0700 Subject: [PATCH] cleanup and simplification of ANSIBLE_REMOTE_TMP feature --- bin/ansible-playbook | 1 - docs/man/man1/ansible-playbook.1.asciidoc.in | 1 - docs/man/man1/ansible.1.asciidoc.in | 2 -- lib/ansible/constants.py | 2 -- lib/ansible/playbook.py | 5 +---- lib/ansible/runner.py | 9 ++++----- 6 files changed, 5 insertions(+), 15 deletions(-) diff --git a/bin/ansible-playbook b/bin/ansible-playbook index e8ae432f989..da22164c753 100755 --- a/bin/ansible-playbook +++ b/bin/ansible-playbook @@ -77,7 +77,6 @@ def main(args): sudo=options.sudo, sudo_user=options.sudo_user, sudo_pass=sudopass, - basetmp=C.DEFAULT_REMOTE_TEMPDIR, extra_vars=extra_vars ) try: diff --git a/docs/man/man1/ansible-playbook.1.asciidoc.in b/docs/man/man1/ansible-playbook.1.asciidoc.in index 9a5eab77778..527ae091d19 100644 --- a/docs/man/man1/ansible-playbook.1.asciidoc.in +++ b/docs/man/man1/ansible-playbook.1.asciidoc.in @@ -90,7 +90,6 @@ ANSIBLE_HOSTS -- Override the default ansible hosts file ANSIBLE_LIBRARY -- Override the default ansible module library path -ANSIBLE_REMOTE_TMP -- Override the default ansible remote tmpdir AUTHOR ------ diff --git a/docs/man/man1/ansible.1.asciidoc.in b/docs/man/man1/ansible.1.asciidoc.in index 3337ceab919..f01dc549e5e 100644 --- a/docs/man/man1/ansible.1.asciidoc.in +++ b/docs/man/man1/ansible.1.asciidoc.in @@ -135,8 +135,6 @@ ANSIBLE_HOSTS -- Override the default ansible hosts file ANSIBLE_LIBRARY -- Override the default ansible module library path -ANSIBLE_REMOTE_TMP -- Override the default ansible remote tmpdir - AUTHOR ------ diff --git a/lib/ansible/constants.py b/lib/ansible/constants.py index 0a905f4523f..aee41669061 100644 --- a/lib/ansible/constants.py +++ b/lib/ansible/constants.py @@ -23,8 +23,6 @@ DEFAULT_HOST_LIST = os.environ.get('ANSIBLE_HOSTS', '/etc/ansible/hosts') DEFAULT_MODULE_PATH = os.environ.get('ANSIBLE_LIBRARY', '/usr/share/ansible') -DEFAULT_REMOTE_TEMPDIR = os.environ.get('ANSIBLE_REMOTE_TMP', - '/$HOME/.ansible/tmp') DEFAULT_MODULE_NAME = 'command' DEFAULT_PATTERN = '*' diff --git a/lib/ansible/playbook.py b/lib/ansible/playbook.py index 2d3cbc1df03..a8fe033df17 100644 --- a/lib/ansible/playbook.py +++ b/lib/ansible/playbook.py @@ -62,7 +62,6 @@ class PlayBook(object): stats = None, sudo = False, sudo_user = C.DEFAULT_SUDO_USER, - basetmp = C.DEFAULT_REMOTE_TEMPDIR, extra_vars = None): """ @@ -102,7 +101,6 @@ class PlayBook(object): self.sudo = sudo self.sudo_pass = sudo_pass self.sudo_user = sudo_user - self.basetmp = basetmp self.extra_vars = extra_vars self.global_vars = {} @@ -288,8 +286,7 @@ class PlayBook(object): setup_cache=SETUP_CACHE, basedir=self.basedir, conditional=only_if, callbacks=self.runner_callbacks, debug=self.debug, sudo=sudo, sudo_user=sudo_user, - transport=transport, sudo_pass=self.sudo_pass, - basetmp=self.basetmp, is_playbook=True + transport=transport, sudo_pass=self.sudo_pass, is_playbook=True ) if async_seconds == 0: diff --git a/lib/ansible/runner.py b/lib/ansible/runner.py index 6cba35a5326..fd6d8f830ae 100644 --- a/lib/ansible/runner.py +++ b/lib/ansible/runner.py @@ -79,7 +79,7 @@ class Runner(object): sudo_pass=C.DEFAULT_SUDO_PASS, background=0, basedir=None, setup_cache=None, transport=C.DEFAULT_TRANSPORT, conditional='True', callbacks=None, debug=False, sudo=False, sudo_user=C.DEFAULT_SUDO_USER, - module_vars=None, is_playbook=False, inventory=None,basetmp=C.DEFAULT_REMOTE_TEMPDIR): + module_vars=None, is_playbook=False, inventory=None): """ host_list : path to a host list file, like /etc/ansible/hosts @@ -96,7 +96,7 @@ class Runner(object): sudo_pass : sudo password if using sudo and sudo requires a password background : run asynchronously with a cap of this many # of seconds (if not 0) basedir : paths used by modules if not absolute are relative to here - basetmp : TMPDIR used on remote host + basetmp : TMPDIR used on remote host. Set with ENVAR ANSIBLE_REMOTE_TMP setup_cache : this is a internalism that is going away transport : transport mode (paramiko, local) conditional : only execute if this string, evaluated, is True @@ -120,7 +120,6 @@ class Runner(object): self.sudo_user = sudo_user self.transport = transport - self.basetmp = basetmp self.connector = ansible.connection.Connection(self, self.transport, self.sudo_user) if inventory is None: @@ -238,7 +237,7 @@ class Runner(object): def _add_setup_metadata(self, args): ''' automatically determine where to store variables for the setup module ''' - basetmp = self.basetmp + basetmp = os.environ.get('ANSIBLE_REMOTE_TMP','/$HOME/.ansible/tmp') is_dict = False if type(args) == dict: is_dict = True @@ -659,7 +658,7 @@ class Runner(object): # 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 = self.basetmp + basetmp = os.environ.get('ANSIBLE_REMOTE_TMP','/$HOME/.ansible/tmp') if self.remote_user == 'root': basetmp ="/var/tmp" cmd = "mktemp -d %s/ansible.XXXXXX" % basetmp