Question:
I would like to provision with my three nodes from the last one by using Ansible.
My host machine is Windows 10.
My Vagrantfile looks like:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
Vagrant.configure("2") do |config| (1..3).each do |index| config.vm.define "node#{index}" do |node| node.vm.box = "ubuntu" node.vm.box = "../boxes/ubuntu_base.box" node.vm.network :private_network, ip: "192.168.10.#{10 + index}" if index == 3 node.vm.provision :setup, type: :ansible_local do |ansible| ansible.playbook = "playbook.yml" ansible.provisioning_path = "/vagrant/ansible" ansible.inventory_path = "/vagrant/ansible/hosts" ansible.limit = :all ansible.install_mode = :pip ansible.version = "2.0" end end end end end |
My playbook looks like:
1 2 3 4 5 6 7 8 9 10 |
--- # my little playbook - name: My little playbook hosts: webservers gather_facts: false roles: - create_user |
My hosts file looks like:
1 2 3 4 5 6 7 8 9 10 11 12 13 |
[webservers] 192.168.10.11 192.168.10.12 [dbservers] 192.168.10.11 192.168.10.13 [all:vars] ansible_connection=ssh ansible_ssh_user=vagrant ansible_ssh_pass=vagrant |
After executing vagrant up --provision
I got the following error:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Bringing machine 'node1' up with 'virtualbox' provider... Bringing machine 'node2' up with 'virtualbox' provider... Bringing machine 'node3' up with 'virtualbox' provider... ==> node3: Running provisioner: setup (ansible_local)... node3: Running ansible-playbook... PLAY [My little playbook] ****************************************************** TASK [create_user : Create group] ********************************************** fatal: [192.168.10.11]: FAILED! => {"failed": true, "msg": "ERROR! Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host."} fatal: [192.168.10.12]: FAILED! => {"failed": true, "msg": "ERROR! Using a SSH password instead of a key is not possible because Host Key checking is enabled and sshpass does not support this. Please add this host's fingerprint to your known_hosts file to manage this host."} PLAY RECAP ********************************************************************* 192.168.10.11 : ok=0 changed=0 unreachable=0 failed=1 192.168.10.12 : ok=0 changed=0 unreachable=0 failed=1 Ansible failed to complete successfully. Any error output should be visible above. Please fix these errors and try again. |
I extended my Vagrantfile with ansible.limit = :all
and added [all:vars]
to the hostfile, but still cannot get through the error.
Has anyone encountered the same issue?
Answer:
Create a file ansible/ansible.cfg
in your project directory (i.e. ansible.cfg
in the provisioning_path
on the target) with the following contents:
1 2 3 |
[defaults] host_key_checking = false |