I'm a bit stumped here.

I have a playbook setup that uses hostvars to fill in expressions in other 
places including jinja2 templates.  Whenever one of those variables is an 
IP address, I get the error 'dict' object has no attribute 'xx.xx.xx.xx'. 
when there's a var set to that value.

For example,

/install/vars/main.yml

db_master_ip: 
"{{hostvars['hostname.localdomain'][ansible_eth0.ipv4.address]}}"

is used in a later step as 

/install/tasks/main.yml

- include: standby.yml

/install/tasks/standby.yml
shell: pg_basebackup -h {{db_master_ip}} -D {{postgres_data_dir}} -U 
{{db_user}} -v -x

Ansible fails on that step with the 'dict' object has no attribute error. 
 Though it shows the correct IP address in the error message

If I change it to 

shell: pg_basebackup -h 
{{hostvars['hostname.localdomain'][ansible_eth0.ipv4.address]}} 

It works just fine, but that's definitely less than ideal as I use the {{ 
db_master_ip }} expression in quite a few places and would like to be able 
to easily modify it.

Alternatively, if I change 

db_master_ip: 192.168.1.2 

it also works.

I know it's got to be something with the way jinja2 is parsing the dict, 
but I have no idea where it would be going wrong or what I can do to fix 
it.  I've been googling around for the last day and haven't really come up 
with anything that makes sense to my situation.

-- 
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/437c53db-5d94-4c6c-b52b-f4cf2f64a1b6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to