Disable host key checking when triggering Ansible from Python app

Hello everyone,

I’m trying to trigger Ansible run from a Python application and I can’t disable host key checking.

I’ve already tried:

  • passing parameter via extra_vars in the same manner as from CLI, and then transforming it into a dictionary the same way as in ansible-playbook
  • assembling a dictionary with the parameters

It keeps asking if I want to continue connecting to the host.

extra_vars is evaluated like this now: {u’host_key_checking’: u’no’, u’record_host_keys’: u’no’}

Could anyone advise please?

Kind regards,
Pavel Chunyayev

In the future these types of questions should probably go to ansible-devel, not ansible-project.

You can do this by manipulating the “constant”.

import ansible.constants as C
C.HOST_KEY_CHECKING = False