How to add a host to the known_host file with ansible?


I want to add the ssh key for my private git server to the known_hosts file with ansible 1.9.3 but it doesn’t work.

I have the following entry in my playbook:

I have copied /etc/ssh/ to and the file looks like:

If I run my playbook I always get the following error message:

What I am doing wrong?


Your copy of the remote host public key needs a name, that name needs to match what you specify for your known hosts.

In your case, prepend " " to your key file as follows:

Ansible known_hosts module, specifically the name parameter

Leave a Reply