On Mar 31, 2015, at 8:18 AM, Adrian Paraschiv
<[email protected]> wrote:
>
> I modified it to suit my hosts:
>
> ---
> - name: test hostvars host1
> hosts: LBL
> tasks:
> - command: "ls /bin"
> register: ls_out
>
> - name: test hostvars host2
> hosts: LM
> tasks:
> - debug:
> var: "{{ hostvars['LBL']['ls_out']['stdout'] }}"
>
> and it doesn't work:
<snip>
> FATAL: all hosts have already failed -- aborting
>
> the ls /bin is been executed but it's the same error
> this is the content of my hosts file:
>
> [LBL]
> 10.104.148.136
> [LM]
> 10.104.148.138
LBL is the name of the group, not the host. You'd want something like
var: "{{ hostvars['10.104.148.136']['ls_out']['stdout'] }}"
You can also get the list of hosts in a group, using {{ groups['LBL'] }}, if
you'd rather just get the first host from there or if you want to iterate over
the entire group.
There's more info and examples about this on the link posted earlier in this
thread:
http://docs.ansible.com/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts
-A
--
Adam Herzog
[email protected]
--
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/8A0F6BAD-3260-40CC-8DF4-741A0D8B019F%40adamherzog.com.
For more options, visit https://groups.google.com/d/optout.