Ansible设置错误!无法使用SSH密码而不是密钥 [英] Ansible provisioning ERROR! Using a SSH password instead of a key is not possible
问题描述
我想通过使用Ansible从最后一个节点提供我的三个节点.
I would like to provision with my three nodes from the last one by using Ansible.
我的主机是Windows 10.
My host machine is Windows 10.
我的Vagrantfile看起来像:
My Vagrantfile looks like:
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 little playbook
- name: My little playbook
hosts: webservers
gather_facts: false
roles:
- create_user
我的主机文件如下:
[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
执行无用--provision
后,出现以下错误:
After executing vagrant up --provision
I got the following error:
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.
我用 ansible.limit =:all
扩展了Vagrantfile,并向主机文件添加了 [all:vars]
,但仍然无法解决错误.
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?
推荐答案
在您的项目目录中创建文件 ansible/ansible.cfg
(即, provisioning_path
on target)具有以下内容:
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:
[defaults]
host_key_checking = false
提供了您的Vagrant盒子已经安装了 sshpass
-尚不清楚,因为您问题中的错误消息表明它已安装(否则使用" ERROR!")(带有密码的"ssh"连接类型,则必须安装sshpass程序),但在您的答案中您可以显式添加它( sudo apt-get install sshpass
),就像不是那样
provided that your Vagrant box has sshpass
already installed - it's unclear, because the error message in your question suggests it was installed (otherwise it would be "ERROR! to use the 'ssh' connection type with passwords, you must install the sshpass program"), but in your answer you add it explicitly (sudo apt-get install sshpass
), like it was not
这篇关于Ansible设置错误!无法使用SSH密码而不是密钥的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!