On 19 February 2015 at 08:48, Jan-Piet Mens <[email protected]> wrote:
> Am I misunderstanding what hostvars _should_ contain?
>
AFAIK, hostvars should be a dict of dicts, where the keys are the
inventory_hostnames.
The fact that host variables are put directly in hostvars, is a bug, I
think.
Looking at the code, I think there was confusion between 'hostvars' as we
know to use it in playbooks and templates, which is a variable in the
'inject',
and hostvars, a host specific vari containg the hosts' variables, and used
in the Runner() object.
This might fix it:
diff --git a/lib/ansible/runner/__init__.py b/lib/ansible/runner/__init__.py
index 79a167c..501dc41 100644
--- a/lib/ansible/runner/__init__.py
+++ b/lib/ansible/runner/__init__.py
@@ -684,7 +684,8 @@ class Runner(object):
# and we save the HostVars in the injected dictionary so they
# may be referenced from playbooks/templates
- inject['hostvars'] = hostvars
+ inject['hostvars'] = {}
+ inject['hostvars'][host] = hostvars
host_connection = inject.get('ansible_connection', self.transport)
if host_connection in [ 'paramiko', 'ssh', 'accelerate' ]:
You can check out my branch here to test that:
https://github.com/srvg/ansible/tree/fix_inject_hostvars
Serge
--
You received this message because you are subscribed to the Google Groups
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/ansible-project/CAEhzMJCpp3Yd-GqNyb1pn4ivtNEsHhJMiW05Suo4puDt5C1J3g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.