{% set nodelist = [] %} {% for desktop in desktopNodeList %} {% for node in groups[desktop.name] %} {% if hostvars[node]['ansible_'+desktop.interface] is defined %} {% if not ssh-keygen -F hostvars[node] -f /etc/ssh/known_hosts and not ssh-keygen -F hostvars[node]['ansible_'+desktop.interface] -f /etc/ssh/known_hosts %} {% set host = {name: node, ip: hostvars[node]['ansible_'+desktop.interface]} %} {% if nodelist.append(host) %} {% endif %} {% endif %} {% endif %} {% endfor %} {% endfor %} {% for host in nodelist|unique %} ssh-keyscan -t rsa {{ host.name }} >> /etc/ssh/known_hosts ssh-keyscan -t rsa {{ host.ip }} >> /etc/ssh/known_hosts {% endfor %}