diff options
author | Suren A. Chilingaryan <csa@suren.me> | 2017-04-01 04:53:28 +0200 |
---|---|---|
committer | Suren A. Chilingaryan <csa@suren.me> | 2017-04-01 04:53:28 +0200 |
commit | e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86 (patch) | |
tree | 444778102e4f73b83ef9462235b7f614b004b264 /playbooks/local.yml | |
download | ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.tar.gz ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.tar.bz2 ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.tar.xz ands-e7ed329bd81c2273c03e94c93c9ce9c1d01cdc86.zip |
Initial import
Diffstat (limited to 'playbooks/local.yml')
-rw-r--r-- | playbooks/local.yml | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/playbooks/local.yml b/playbooks/local.yml new file mode 100644 index 0000000..9e6ca38 --- /dev/null +++ b/playbooks/local.yml @@ -0,0 +1,22 @@ +- name: Store known hosts of 'all' the hosts in the inventory file + hosts: localhost + connection: local + + vars: + ssh_known_hosts_command: "ssh-keyscan -T 10" + ssh_known_hosts_file: "{{ lookup('env','HOME') + '/.ssh/known_hosts' }}" + ssh_known_hosts: "{{ groups['all'] }}" + + tasks: + - name: For each host, scan for its ssh public key + shell: "ssh-keyscan {{ item }},`dig +short {{ item }}`" + with_items: "{{ ssh_known_hosts }}" + register: ssh_known_host_results + ignore_errors: yes + + - name: Add/update the public key in the '{{ ssh_known_hosts_file }}' + known_hosts: + name: "{{ item.item }}" + key: "{{ item.stdout }}" + path: "{{ ssh_known_hosts_file }}" + with_items: "{{ ssh_known_host_results.results }}" |