Ansible is telling me that the HostVars object has no element, but when I run setup I see the object!
setup:
“ansible_eth1”: {
“active”: true,
“device”: “eth1”,
“ipv4”: {
“address”: “10.209.169.109”,
“netmask”: “255.255.224.0”,
“network”: “10.209.160.0”
playbook run:
TASK: [hibbert_db | Create a new database user for hibbert_backend.* with name hibbert_user and all privileges from local] ***
<10.209.169.109> ESTABLISH CONNECTION FOR USER: mozart on PORT 22 TO 10.209.169.109
fatal: [s-mysql01] => One or more undefined variables: ansible.runner.HostVars object has no element [0, ‘s-mysql01’]
the task:
- name: Create a new database user for {{ db_name }}.* with name {{ db_user }} and all privileges from local
tags: - user
- permissions
mysql_user: host={{ hostvars[item][‘ansible_eth1’][‘ipv4’][‘address’] }} name={{ db_user }} password={{ db_password }} priv={{ db_root_name }}.*:ALL state=present
with_indexed_items: groups[‘hibbert_db’]
sudo: yes
Does anyone have any ideas? Google has been no help.