Not being helpful, but re-enforcing the (mis)behaviour using Ansible 2.0.2 For my case I was calling sts_assume_role on localhost (hosts:localhost) for get a different aws id, key and token seeing it's only an api call, then setting then using set_facts to set variables. In another play in the same playbook I called it against another host (host:foobar) and tried to reference hostvars['localhost']['aws_cred_id'] .The variable is not defined was my result.
I managed to work around it just by calling the sts_assume_role task on the remote host. Is this the expected behaviour? I thought magic variables could be used for this? is it only for retrieving group file variables? http://docs.ansible.com/ansible/playbooks_variables.html#magic-variables-and-how-to-access-information-about-other-hosts On 12 April 2016 at 13:12, Larry Fast <[email protected]> wrote: > > I'm trying to dynamically build the group of hosts that will be used in a > play. I'm doing this within a hosts: localhost play. However hostvars > seems to be undefined when evaluating the - hosts: line. Suggestions? > > -- > 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/cf79d4c8-480f-4120-8229-464666702a92%40googlegroups.com > <https://groups.google.com/d/msgid/ansible-project/cf79d4c8-480f-4120-8229-464666702a92%40googlegroups.com?utm_medium=email&utm_source=footer> > . > For more options, visit https://groups.google.com/d/optout. > -- Steve -- 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/CA%2Bemtqvwor%3DFfZSr%2B8NT9SUdWmFHLeK_nOaG3fQmuzyUqs0-cw%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
