Posts

Showing posts from September, 2020

Ansible and aws: adding hosts to known_hosts

Background Ansible uses SSH to control hosts. SSH (by default) expects the user to verify the identity of a server upon initially connecting to it. When connecting to a host for the 1st time, you will be prompted: Are you sure you want to continue connecting (yes/no/[fingerprint])? If you type yes in the above dialog, the host's public key and DNS name are added to a file called known_hosts The problem is that in many cloud environments, the DNS name for an instance is modified at each boot. Ansible, being reliant on SSH to connect to hosts, will fail if the host is not already in the known_hosts file, instead prompting the user to add the host to known_hosts. There are a few ways to solve this. You can instruct ansible to not verify the server's identity - but that defeats the ability of this mechanism to protect you fro