HiveBrain v1.2.0
Get Started
← Back to all entries
patternMajor

Can I bypass host key checking in Ansible?

Submitted by: @import:stackexchange-devops··
0
Viewed 0 times
canansiblecheckinghostbypasskey

Problem

I'm running an Ansible playbook with a subtle hack to work on an arbitrary port forwarded port (so I can use one machine with no direct access to lots of machines).

I've got a pre-task to change the ansible_port variable, so then when I start running my real tasks and roles, I get prompted to accept the hostkeys for localhost on some random port.

Because I am naive and don't care about security, I would like ssh to auto-accept and redirect to /dev/null (or another file for logging).

Is this possible?

Solution

This is typically done by setting the following value in ansible.cfg:

[defaults]
host_key_checking = False


If you don't want to modify ansible.cfg you can set an environment variable like so:

export ANSIBLE_HOST_KEY_CHECKING=False


Source: http://docs.ansible.com/ansible/intro_getting_started.html#host-key-checking

Code Snippets

[defaults]
host_key_checking = False
export ANSIBLE_HOST_KEY_CHECKING=False

Context

StackExchange DevOps Q#725, answer score: 37

Revisions (0)

No revisions yet.