Hello,
I try to understand how works looping overs subelements, after reading this loops_subelements I had copy & past the example and he doesn’t work :
TASK: [dbtier | debug msg=“name={{ item.0.user }} password={{ item.0.mysql.password }} host={{ item.1 }} priv={{ item.0.mysql.privs | join(‘/’) }}”] ***
fatal: [srv-lbn-tux5] => could not find ‘mysql.hosts’ key in iterated item ‘{‘authorized’: [’/tmp/alice/onekey.pub’, ‘/tmp/alice/twokey.pub’], ‘name’: ‘alice’, ‘mysql’: {‘password’: ‘mysql-password’, ‘hosts’: [‘%’, ‘127.0.0.1’, ‘::1’, ‘localhost’], ‘privs’: [‘.:SELECT’, ‘DB1.*:ALL’]}}’
FATAL: all hosts have already failed – aborting
my tasks:
- debug: msg=“name={{ item.0.user }} password={{ item.0.mysql.password }} host={{ item.1 }} priv={{ item.0.mysql.privs | join(‘/’) }}”
with_subelements: - users1
- mysql.hosts
tags: debug
vars_file:
users1:
- name: alice
authorized: - /tmp/alice/onekey.pub
- /tmp/alice/twokey.pub
mysql:
password: mysql-password
hosts: - “%”
- “127.0.0.1”
- “::1”
- “localhost”
privs: - “.:SELECT”
- “DB1.*:ALL”
- name: bob
authorized: - /tmp/bob/id_rsa.pub
mysql:
password: other-mysql-password
hosts: - “db1”
privs: - “.:SELECT”
- “DB2.*:ALL”
Ansible version:1.9.2
Can you explain me why ?