Hello.
I'm trying to set up application with database.
My current (simplified) version looks like this:
site.yml:
- include db.yml
- include app.yml
db.yml
- hosts: db
- roles: foo.install_db
app.yml
- hosts: app
- roles: bar.install_app
In the group_var/db I have settings:
db_address: '{{ansible_eth2.address}}'
And I want to use for app:
group_var/app:
database_address: '{{db_address}}'
But it (non-)obviously does not work.
I've tried to use {{hostvar...}}, but it works with hosts, not with groups.
I feel like I'm doing something strange, but I don't know how to do it right. I need to (in runtime) get ip address of server, based on it group/role, and use it in other role. And this IP can not be hardcoded, because eth2 is not configured by ansible and can be only found in runtime...
Please help, Thanks!