Anyone else stumbling upon this.
db_master_ip: "{{
hostvars['hostname.localdomain'].ansible_eth0.ipv4.address }}" was the
change that was needed.
Thanks to piffey on the IRC channel for the assist.
On Tuesday, June 16, 2015 at 10:47:42 AM UTC-5, Brad V wrote:
>
> 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/5a9de64f-d6a2-4c83-a37f-1f240702c4cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.