Tan*_*har 6 ssh vagrant ansible
我无法找到实际问题所在.我用私钥在playbook下执行:
---
- hosts: localhost
gather_facts: false
sudo: yes
tasks:
- name: Install package libpcre3-dev
apt: name=libpcre3-dev state=latest
Run Code Online (Sandbox Code Playgroud)
但我在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
Run Code Online (Sandbox Code Playgroud)
可能的建议是什么?
你正在localhost使用SSH连接运行一个剧本(默认在Ansible中),这就失败了.很可能是因为您从未在计算机上配置帐户以接受自身的密钥.使用默认值,您需要添加~/.ssh/id_rsa.pub到~/.ssh/authorized_keys.
相反,要在本地运行添加connection: local到播放:
---
- hosts: localhost
connection: local
tasks:
- debug:
Run Code Online (Sandbox Code Playgroud)
它会给你一个正确的回应:
TASK [debug] *******************************************************************
ok: [localhost] => {
"msg": "Hello world!"
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
2730 次 |
| 最近记录: |