---
- name: Generate known_hosts file
hosts: localhost
gather_facts: true
tasks:
- name: Run Keyscan
shell: "ssh-keyscan {{ groups['all'] | map('extract', hostvars, 'inventory_hostname') | list | join(' ') }} | sort >| ../known_hosts"