Skip to content

Instantly share code, notes, and snippets.

@gtirloni
Created January 9, 2023 18:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gtirloni/413a3a3d7972c934ffa63690764ea885 to your computer and use it in GitHub Desktop.
Save gtirloni/413a3a3d7972c934ffa63690764ea885 to your computer and use it in GitHub Desktop.
known_hosts.yml
- hosts: all
gather_facts: false
become: false
tasks:
- name: Populate ~/.ssh/known_hosts
delegate_to: localhost
known_hosts:
key: "{{ lookup('pipe', 'ssh-keyscan ' + inventory_hostname + ' 2>/dev/null') }}"
name: "{{ inventory_hostname }}"
state: present
ignore_errors: true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment