Skip to content

Instantly share code, notes, and snippets.

@jhedden
Created July 11, 2013 15:09
Show Gist options
  • Save jhedden/5976292 to your computer and use it in GitHub Desktop.
Save jhedden/5976292 to your computer and use it in GitHub Desktop.
Ansible ssh_known_hosts template
{% for host in groups['all'] %}
{% set hostnames_ips = hostvars[host]['ansible_fqdn'] + ',' + hostvars[host]['ansible_hostname'] + ',' + hostvars[host]['ansible_all_ipv4_addresses']|join(',') %}
{% if hostvars[host]['ansible_ssh_host_key_rsa_public'] %}
{{ hostnames_ips }} ssh-rsa {{ hostvars[host]['ansible_ssh_host_key_rsa_public'] }}
{% endif %}
{% if hostvars[host]['ansible_ssh_host_key_dsa_public'] %}
{{ hostname_ips }} ssh-dsa {{ hostvars[host]['ansible_ssh_host_key_dsa_public'] }}
{% endif %}
{% endfor %}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment