我的主机文件
[all]
192.168.77.10
192.168.77.11
192.1680.77.12
这是我的剧本。yml
---
- hosts: all
tasks:
- name: Add the Google signing key
apt_key : url=https://packages.cloud.google.com/apt/doc/apt-key.gpg state=present
- name: Add the k8s APT repo
apt_repository: repo='deb http://apt.kubernetes.io/ kubernetes-xenial main' state=present
- name: Install packages
apt :
name: "{{ packages }}"
vars:
packages:
- vim
- htop
- tmux
- docker.io
- kubelet
- kubeadm
- kubectl
- kubernetes-cni
我跑步时
ansible-playbook -i hosts playbook.yml
发生意外的身份验证问题。
The authenticity of host '192.168.77.11 (192.168.77.11)' can't be established.
ECDSA key fingerprint is SHA256:mgX/oadP2cL6g33u7xzrEblvga9CGfpW13K2YUdeKsE.
Are you sure you want to continue connecting (yes/no)? The authenticity of host '192.168.77.10 (192.168.77.10)' can't be established.
ECDSA key fingerprint is SHA256:ayWHzp/yquIuQxw7MKGR0+NbtrzHY86Z8PdIPv7r6og.
Are you sure you want to continue connecting (yes/no)? fatal: [192.1680.77.12]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname 192.1680.77.12: Name or service not known\r\n", "unreachable": true}
^C [ERROR]: User interrupted execution
我正在遵循DevOps书中的示例,我复制了原始代码。我的操作系统是Ubuntu 18.04。
telnet hosts
telnet: could not resolve hosts/telnet: Temporary failure in name resolution
VM ls输出
vagrant@ubuntu-bionic:~$ ls
hosts playbook.retry playbook.yml
我通过添加False选项来编辑/etc/ansible/ansible.cfg。 无论如何,它不再起作用
fatal: [192.1680.77.12]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname 192.1680.77.12: Name or service not known\r\n", "unreachable": true}
fatal: [192.168.77.10]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Warning: Permanently added '192.168.77.10' (ECDSA) to the list of known hosts.\r\nvagrant@192.168.77.10: Permission denied (publickey).\r\n", "unreachable": true}
fatal: [192.168.77.11]: UNREACHABLE! => {"changed": false, "msg": "Failed to connect to the host via ssh: Warning: Permanently added '192.168.77.11' (ECDSA) to the list of known hosts.\r\nvagrant@192.168.77.11: Permission denied (publickey).\r\n", "unreachable": true}
to retry, use: --limit @/home/vagrant/playbook.retry
PLAY RECAP *************************************************************************************************************************************************************************************************
192.168.77.10 : ok=0 changed=0 unreachable=1 failed=0
192.168.77.11 : ok=0 changed=0 unreachable=1 failed=0
192.1680.77.12 : ok=0 changed=0 unreachable=1 failed=0
如何解决此问题?
答案 0 :(得分:2)
您有几种选择。当然,一种方法是SSH到主机,然后将它们添加到Ansible服务器的已知主机文件中。另一种选择是将环境变量ANSIBLE_HOST_KEY_CHECKING
设置为false。第三种选择是使用ansible.cfg配置文件:
[defaults]
host_key_checking = False