summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael DeHaan <michael.dehaan@gmail.com>2012-03-06 04:23:56 +0100
committerMichael DeHaan <michael.dehaan@gmail.com>2012-03-06 04:23:56 +0100
commit0935506d6ff96614cdee3e2ab26ade2f432161ee (patch)
tree24d90d6f84807677d373cca749d28655efcacab5
parentParameterized include statements can see top level variables and also be pass... (diff)
downloadansible-0935506d6ff96614cdee3e2ab26ade2f432161ee.tar.xz
ansible-0935506d6ff96614cdee3e2ab26ade2f432161ee.zip
Templating as non-root should not require passing in the metadata= parameter.
-rwxr-xr-xlib/ansible/playbook.py2
-rwxr-xr-xlib/ansible/runner.py21
2 files changed, 20 insertions, 3 deletions
diff --git a/lib/ansible/playbook.py b/lib/ansible/playbook.py
index b3a99fd892..390b75b291 100755
--- a/lib/ansible/playbook.py
+++ b/lib/ansible/playbook.py
@@ -306,8 +306,6 @@ class PlayBook(object):
push_var_str=''
for (k,v) in vars.items():
push_var_str += "%s=%s " % (k,v)
- if user != 'root':
- push_var_str = "%s metadata=~/.ansible_setup" % (push_var_str)
# push any variables down to the system
setup_results = ansible.runner.Runner(
diff --git a/lib/ansible/runner.py b/lib/ansible/runner.py
index a0370e8a39..143822e12d 100755
--- a/lib/ansible/runner.py
+++ b/lib/ansible/runner.py
@@ -213,6 +213,16 @@ class Runner(object):
args = [ str(x) for x in module_args ]
args = " ".join(args)
inject_vars = self.setup_cache.get(conn._host,{})
+
+ # the metadata location for the setup module is transparently managed
+ # since it's an 'internals' module, kind of a black box. See playbook
+ # other modules are not allowed to have this kind of handling
+ if remote_module_path.endswith("/setup") and args.find("metadata=") == -1:
+ if self.remote_user == 'root':
+ args = "%s metadata=/etc/ansible/setup" % args
+ else:
+ args = "%s metadata=~/.ansible/setup" % args
+
template = jinja2.Template(args)
args = template.render(inject_vars)
@@ -227,7 +237,9 @@ class Runner(object):
because those require extra work.
'''
module = self._transfer_module(conn, tmp, self.module_name)
+
result = self._execute_module(conn, tmp, module, self.module_args)
+
# when running the setup module, which pushes vars to the host and ALSO
# returns them (+factoids), store the variables that were returned such that commands
# run AFTER setup use these variables for templating when executed
@@ -238,6 +250,7 @@ class Runner(object):
var_result = json.loads(result)
except:
var_result = {}
+
self._delete_remote_files(conn, tmp)
return self._return_from_module(conn, host, result)
@@ -293,7 +306,13 @@ class Runner(object):
options = self._parse_kv(self.module_args)
source = options['src']
dest = options['dest']
- metadata = options.get('metadata', '/etc/ansible/setup')
+ metadata = options.get('metadata', None)
+
+ if metadata is None:
+ if self.remote_user == 'root':
+ metadata = '/etc/ansible/setup'
+ else:
+ metadata = '~/.ansible/setup'
# first copy the source template over
tpath = tmp