Skip to content

Instantly share code, notes, and snippets.

@AnatomicJC
Created August 9, 2023 11:12
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 AnatomicJC/73d059d35cd751a39605a2f794d5b293 to your computer and use it in GitHub Desktop.
Save AnatomicJC/73d059d35cd751a39605a2f794d5b293 to your computer and use it in GitHub Desktop.
Ansible: Add keys to known host with ssh-keyscan
- name: Update ~/.ssh/known_hosts file
  hosts: all
  gather_facts: false
  become: false
  tasks:
    - name: Update ~/.ssh/known_hosts
      ansible.builtin.known_hosts:
        name: "{{ inventory_hostname }}"
        key: "{{ lookup('pipe', 'ssh-keyscan ' + inventory_hostname) }}"
      delegate_to: localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment