I have an inventory file like this:
[redisservers]
72.14.178.81
[webservers]
198.58.107.247
I'm trying to run this playbook against the redisservers group to allow
access to port 6379 for the webservers:
---
- name: Allow port 6379 (Redis) access to Web servers
ufw: rule=allow interface=eth0 direction=in port=6379 proto=tcp src="{{
hostvars[item]['ansible_eth0']['ipv4']['address'] }}"
with_items: groups['webservers']
But I'm getting this error:
TASK: [redis | Allow port 6379 (Redis) access to Web servers]
*****************
fatal: [72.14.178.81] => One or more undefined variables: 'dict object' has
no attribute 'ansible_eth0'
FATAL: all hosts have already failed -- aborting
I'm not sure what's going on as all servers definitely have an eth0
interface. When I run ansible all -m setup -i inventory, the output seems
to confirm that there is an ansible_eth0 fact available for all servers:
https://gist.github.com/abevoelker/7a3c18f10793a744e6da
I've tried simplifying the playbook to refer to the exact server in
question to remove the looping:
---
- name: Allow port 6379 (Redis) access to Web servers
ufw: rule=allow interface=eth0 direction=in port=6379 proto=tcp src="{{
hostvars[groups['webservers'][0]]['ansible_eth0']['ipv4']['address'] }}"
and also
---
- name: Allow port 6379 (Redis) access to Web servers
ufw: rule=allow interface=eth0 direction=in port=6379 proto=tcp src="{{
hostvars['198.58.107.247']['ansible_eth0']['ipv4']['address'] }}"
But I'm still getting the same error.
Any hints as to what I'm doing wrong or how I can continue to debug this?
I'm using Ansible 1.7.1.
--
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/77f5e683-2deb-45dd-9a12-ed56ce94b59a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.