known_hosts

Collection: builtin

Full Name: parallax.builtin.known_hosts

Aliases: ansible.builtin.known_hosts, known_hosts

Synopsis

Add or remove entries in a known_hosts file

Parameters

NameTypeRequiredDefaultDescription
namestringyesThe host to add or remove (must match a host specified in key)
keystringThe SSH public host key, as a string
pathstring~/.ssh/known_hostsThe known_hosts file to edit
hash_hostboolfalseHash the hostname in the known_hosts file
statestringpresentWhether the given host’s fingerprint should be added or removed Choices: absent, present

Example

- name: Trust the build server host key
  known_hosts:
    name: build.example.com
    key: "build.example.com ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIExampleKeyMaterialHere"
    path: /etc/ssh/ssh_known_hosts
    state: present