{{ ansible_header | comment }} {% set hosts = query('ldap', 'query', 'ou=hosts,dc=crans,dc=org', 'one', 'objectClass=device') %} {% for host, device in hosts.items() | sort(attribute='0') %} {% set cns = query('ldap', 'all_cn', hosts[host].cn[0]) | sort %} {% set ips = query('ldap', 'all_ip', hosts[host].cn[0]) | sort %} {% for key in query('ldap', 'ssh_keys', hosts[host].cn[0]) | sort %} {{ cns | join(',') }},{{ ips | join(',') }} {{ key }} root@{{ hosts[host].cn[0] }} {% endfor %} {% endfor %}