Can't disable Ansible's host key checking

16,501

Solution 1

You'll need to set it via the Vagrantfile of the project. When the Vagrant Ansible provisioner makes the call to ansible-playbook it always sets the value of the ANSIBLE_HOST_KEY_CHECKING environment variable.

Ansible itself takes the value of the environment variable if present. Therefore Vagrant will override the value used in your ansible.cfg.

Therefore you just need something like:

machine.vm.provision :ansible do |ansible|
  ansible.host_key_checking = false
  # etc.
end

Solution 2

Probably not your problem, but worth a shot: I was stalled on this, until I realized I added

host_key_checking = False

under a session that was not [defaults]. Once I actually moved it to under [defaults], changed host keys did not stop anything anymore.

Share:
16,501

Related videos on Youtube

Slava Fomin II
Author by

Slava Fomin II

Slava Fomin II is an entrepreneur and a passionate full-stack web-developer. Through his everyday work, he tries to make the World a better place by combining great design with the cutting-edge technology and knowledge. Homepage / Resume

Updated on June 30, 2022

Comments

  • Slava Fomin II
    Slava Fomin II almost 2 years

    I'm using Ansible 1.5.4 to provision my Vagrant 1.4.3 box on Ubuntu 14.04 LTS.

    I'm getting the following error message in verbose mode:

    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    

    I can do: export ANSIBLE_HOST_KEY_CHECKING=False and I have following lines in my ~/.ansible.cfg:

    [defaults]
    host_key_checking = False
    

    But it doesn't help.

    What could be the problem? Thank you!

    UPDATE #1

    I'm calling it directly like this (without using vagrant command):

    ansible-playbook playbook.yml -i inventory.ini --user=vagrant --ask-pass -vvvv
    

    The inventory is:

    [default]
    localhost:2222
    
  • Slava Fomin II
    Slava Fomin II about 10 years
    Thank you for your answer! I've forgot to mention that I'm running this playbook using ansible-playbook command without invoking Vagrant itself. I've updated my question (see UPD#1). By the way I also have this line in the Vagrantfile.
  • Tchevass
    Tchevass almost 9 years
    Thank you very much ! I can now do my ansible command without accepting the key fingerprint