Skip to content
Snippets Groups Projects
Commit e05803e5 authored by Jupiter Hu's avatar Jupiter Hu
Browse files

Set all interfaces to known_host

parent 4fdd3e66
No related branches found
No related tags found
No related merge requests found
{% 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 %}
{% 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 node -f /etc/ssh/known_hosts and not ssh-keygen -F hostvars[node]['ansible_'+desktop.interface]['ipv4']['address'] -f /etc/ssh/known_hosts %}
{% set host = {name: node, ip: hostvars[node]['ansible_'+desktop.interface]['ipv4']['address']} %}
{% if nodelist.append(host) %}
{% endif %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% for host in nodelist|unique %}
echo "{{ host.name }} {{ host.ip }}"
#ssh-keyscan -t rsa {{ host.name }} >> /etc/ssh/known_hosts
#ssh-keyscan -t rsa {{ host.ip }} >> /etc/ssh/known_hosts
{% endfor %}
{% set nodelist = [] %}
{% for desktop in desktopNodeList %}
{% for node in groups[desktop.name] %}
{% if hostvars[node]['ansible_'+desktop.interface] is defined %}
{% set host = {'name': node, 'ip': hostvars[node]['ansible_'+desktop.interface]['ipv4']['address']} %}
{% if nodelist.append(host) %}
{% endif %}
{% endif %}
{% endfor %}
{% endfor %}
{% for host in nodelist|unique %}
echo "{{ host.name }} {{ host.ip }}"
#ssh-keyscan -t rsa {{ host.name }} >> /etc/ssh/known_hosts
#ssh-keyscan -t rsa {{ host.ip }} >> /etc/ssh/known_hosts
{% endfor %}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment