我无法找到实际问题所在。我用我的私钥在剧本下面执行:
---
- hosts: localhost
gather_facts: false
sudo: yes
tasks:
- name: Install package libpcre3-dev
apt: name=libpcre3-dev state=latest
但是我在Vagrant Ubuntu机器上收到以下错误:
PLAY [localhost]
*********************************************************************
TASK [Install package ]
***************************************************
fatal: [vagrant]: UNREACHABLE! => {"changed": false, "msg": "Failed to
connect to the host via ssh: Permission denied (publickey,password).\r\n",
"unreachable": true}
to retry, use: --limit @/home/vagrant/playbooks/p1.retry
PLAY RECAP
*********************************************************************
vagrant : ok=0 changed=0 unreachable=1 failed=0
可能的建议是什么?
答案 0 :(得分:5)
您正在使用SSH连接(默认为Ansible)运行针对localhost
的剧本,但此操作失败。很可能是因为您从未在计算机上配置帐户以接受自身的密钥。使用默认值,您需要将~/.ssh/id_rsa.pub
添加到~/.ssh/authorized_keys
。
相反,要在本地运行,请将connection: local
添加到游戏中:
---
- hosts: localhost
connection: local
tasks:
- debug:
它会给你一个正确的答案:
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "Hello world!"
}