I think the issue is Ansible doesn't gather facts from hosts that aren't in the play.
We have a central log/graphite server that all hosts wired their monitoring agents into, and in our case just using an inventory hostname wasn't enough since traffic needed to flow over a dedicated instrumentation network, so we'd have to figure out the IP of the interface connected to that subnet. This was a pretty big stack so when you changed something on a specific group of servers, a quick 'limit run' saved a few minutes and we constantly forgot to add the monitoring servers into the limit list. Best workaround I found was to limit the amount of hostvars I used and replace them with inventory variables. These were physical servers so keeping specific data in the inventory was practical, that may be more difficult on e.g. AWS. Another way would be to break your main playbook into smaller sub-playbooks and explicitly gather the required facts at the top of them. On 25 September 2015 at 20:04, Anubhav Gupta <[email protected]> wrote: > Hi, > > When I run the ansible playbook with a --limit option (in order to restrict > the nodes on which the install would happen), the hostvars object does not > contain the variables for the hosts not specified in the --limit option. > Some of my playbook templates use hostvars for all the hosts in the > inventory, and as a result these template rules fail when I run with the > --limit option. What is the best way to get around this problem? > > Thanks, > Anubhav > > -- > 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/70581c57-2b68-404b-b60e-a0a27ad1d92c%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- 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/CAK5eLPR2f7UfaZgGhiqyNUnQ3WjsyrCJa7ZZ8VTt9nWmqeHnUg%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.
