Skip to content

Commit

Permalink
Only write DSA/RSA SSH keys in /etc/ssh/known_hosts if they are avail…
Browse files Browse the repository at this point in the history
…able to Ansible.

Fixes issue #184
  • Loading branch information
riccardomurri committed Dec 4, 2015
1 parent 5932436 commit 850fd71
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,19 +1,20 @@
{% if hosts %}
{% for host in hosts %}
{% if hostvars[host].ansible_ssh_host_key_dsa_public %}
{% if 'ansible_ssh_host_key_dsa_public' in hostvars[host] %}
{{ host }},{{ hostvars[host].ansible_default_ipv4.address }} ssh-dsa {{ hostvars[host].ansible_ssh_host_key_dsa_public }}
{% endif %}
{% if hostvars[host].ansible_ssh_host_key_rsa_public %}
{% if 'ansible_ssh_host_key_rsa_public' in hostvars[host] %}
{{ host }},{{ hostvars[host].ansible_default_ipv4.address }} ssh-rsa {{ hostvars[host].ansible_ssh_host_key_rsa_public }}
{% endif %}
{% endfor %}

{% else %}

{% for host in groups['all'] %}
{% if hostvars[host].ansible_ssh_host_key_dsa_public %}
{% if 'ansible_ssh_host_key_dsa_public' in hostvars[host] %}
{{ host }},{{ hostvars[host].ansible_default_ipv4.address }} ssh-dsa {{ hostvars[host].ansible_ssh_host_key_dsa_public }}
{% endif %}
{% if hostvars[host].ansible_ssh_host_key_rsa_public %}
{% if 'ansible_ssh_host_key_rsa_public' in hostvars[host] %}
{{ host }},{{ hostvars[host].ansible_default_ipv4.address }} ssh-rsa {{ hostvars[host].ansible_ssh_host_key_rsa_public }}
{% endif %}
{% endfor %}
Expand Down

0 comments on commit 850fd71

Please sign in to comment.