我在 Ubuntu 16.x(ansible 版本 2.2.1.0 和 2.2.2.0)上运行这个 Ansible ad-hoc 命令
ansible host_alias -a "df -h" -u USER
其中 host_alias 是定义的 ansible hosts 文件(定义一个 ec2 实例及其 .pem 文件)。
主机文件如下所示:
[host_alias]
my_host.compute.amazonaws.com
private_key_file=/path/to/key/my_key.pem
我收到此错误:
private_key_file=/path/to/key/my_key.pem | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: ssh: Could not resolve hostname private_key_file=/path/to/key/my_key.pem: Name or service not known\r\n",
"unreachable": true
}
my_host.compute.amazonaws.com | UNREACHABLE! => {
"changed": false,
"msg": "Failed to connect to the host via ssh: Permission denied (publickey).\r\n",
"unreachable": true
当我 ssh(由 定义~/.ssh/config
)时,相同的主机和密钥工作正常。我已经三重确保密钥在那里并且具有读取权限。我还尝试ansible_user
在 Ansible 主机文件中设置。
有任何想法吗?