When sudo'ing to root, keep the setup file location as /etc/ansible/setup

This commit is contained in:
Michael DeHaan 2012-07-07 09:29:03 -04:00
parent c592fdf838
commit 0d28466b22

View file

@ -263,16 +263,16 @@ class Runner(object):
if type(args) == dict: if type(args) == dict:
is_dict = True is_dict = True
# TODO: keep this as a dict through the whole path to simplify this code # TODO: make a _metadata_path function
if not is_dict: if not is_dict:
if args.find("metadata=") == -1: if args.find("metadata=") == -1:
if self.remote_user == 'root': if self.remote_user == 'root' or (self.sudo and self.sudo_user == 'root'):
args = "%s metadata=/etc/ansible/setup" % args args = "%s metadata=/etc/ansible/setup" % args
else: else:
args = "%s metadata=%s/setup" % (args, C.DEFAULT_REMOTE_TMP) args = "%s metadata=%s/setup" % (args, C.DEFAULT_REMOTE_TMP)
else: else:
if not 'metadata' in args: if not 'metadata' in args:
if self.remote_user == 'root': if self.remote_user == 'root' or (self.sudo and self.sudo_user == 'root'):
args['metadata'] = '/etc/ansible/setup' args['metadata'] = '/etc/ansible/setup'
else: else:
args['metadata'] = "%s/setup" % C.DEFAULT_REMOTE_TMP args['metadata'] = "%s/setup" % C.DEFAULT_REMOTE_TMP