【发布时间】:2016-04-17 20:06:28
【问题描述】:
当我从顶级 Vagrantfile 目录执行我的 cp-sshkey.yml 剧本(以我自己而不是 vagrant 用户身份登录)时...
ansible-playbook cp-sshkey.yml
我收到此错误:
TASK: [authorized_key user=vagrant key="{{ lookup('file', './files/id_rsa_vagrant.pub') }}"] ***
fatal: [web1] => Failed to template user=vagrant key="{{ lookup('file', './files/id_rsa_vagrant.pub') }}": could not locate file in lookup: ./files/id_rsa_vagrant.pub
我不明白为什么会发生此错误。这是一个非常简单的剧本,公钥文件就是我所说的:
.
├── .vagrant
│ └── machines
├── Vagrantfile
├── ansible.cfg
├── bootstrap-mgmt.sh
├── files
│ └── id_rsa_vagrant.pub
├── inventory.ini
├── secrets.yml
├── site.yml
├── website
└── cp-sshkey.yml
这是我的配置和主机文件以及剧本:
# ansible.cfg
[defaults]
hostfile = inventory.ini
remote_user = vagrant
private_key_file = .vagrant/machines/default/virtualbox/private_key
host_key_checking = False
# inventory.ini
[local]
localhost ansible_connection=local
[web]
web1 ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222
# cp-sshkey.yml
- name: Install vagrant's public key on VM
hosts: web1
sudo: True
tasks:
- authorized_key: user=vagrant key="{{ lookup('file', './files/id_rsa_vagrant.pub') }}"
我在这里做错了什么?谢谢。
【问题讨论】:
-
你绝对应该用
ansible以及你正在使用的客户操作系统来标记这个问题。 -
你的 ansible 版本是什么?我相信在 1.9 分支中也报告了同样的情况
-
我使用的是 Ansible 1.9.2。
-
不是专家,但您不应该复制您的个人公钥而不是 vagrant 密钥吗?看起来您正在尝试将公钥复制到已经包含该密钥的虚拟机/帐户中?
-
你能ping通流浪机器吗? web1 ansible_ssh_host=127.0.0.1 ansible_ssh_port=2222 ansible_ssh_user=vagrant
标签: ssh debian vagrant ansible ssh-keys