Ansible: How to get the IP address of another host of previous play in the playbook?

Created on 5 Jan 2017  路  1Comment  路  Source: ansible/ansible

ISSUE TYPE
  • Documentation Report

In docs http://docs.ansible.com/ansible/playbooks_variables.html#fact-caching

My inventory hosts like IP list, without hostnames.

[name-first]
192.168.1.2
[name-second]
192.168.1.3

And i can refer to "hostvars" only by IP. But how i refer to higher(previous) "play" to get the IP address?... By _name_ for example

hostvars[groups.<name>.0].ansible_default_ipv4.address

Nothing is easier?


You preach, write IP only in inventory. But now I have to write IP to get _hostvars_?.. Better yet, if I need to get it.

>All comments

List Information

Hi!

Thanks very much for your interest in Ansible. It sincerely means a lot to us.

This appears to be a user question, and we'd like to direct these kinds of things to either the mailing list or the IRC channel.

If you can stop by there, we'd appreciate it. This allows us to keep the issue tracker for bugs, pull requests, RFEs and the like.

Thank you once again and we look forward to seeing you on the list or IRC. Thanks!

Was this page helpful?
0 / 5 - 0 ratings