我正在 Raspberry PI 2 上探索新安装的 Archlinux 安装,如下所示:
ansible -i PI2 arch -m setup -c paramiko -k -u alarm -vvvv
这对我来说是:针对与用户“警报”连接的 IP 触发设置模块,要求输入该特定用户的密码。然而,最终尝试连接的用户是“root”。
这是调试响应:
Loaded callback minimal of type stdout, v2.0
<192.168.1.18> ESTABLISH CONNECTION FOR USER: root on PORT 22 TO 192.168.1.18
192.168.1.18 | UNREACHABLE! => {
"changed": false,
"msg": "ERROR! Authentication failed.",
"unreachable": true
}
库存如下所示:
[arch]
192.168.1.18
以下是一些可能相关或不相关的事情:
- 不允许通过 root 进行 ssh 登录
- sudo 未安装
- 默认用户和通行证是“警报”:“警报”
- 没有 ssh 密钥被复制到机器,因此 paramiko 连接尝试
未被忽略并导致连接成功的是添加ansible_user=alarm
到清单文件中的 IP 行。
编辑 在官方文档中找到了这个有趣的段落:http://docs.ansible.com/ansible/playbooks_variables.html#variable-precedence-where-should-i-put-a-variable指出:
Another important thing to consider (for all versions) is that connection specific variables override config, command line and play specific options and directives. For example:
ansible_user will override
-uand
远程用户:`
原来的问题似乎仍然存在。清单中没有提及ansible_user
,为什么使用 root 而不是明确提到的用户 via - u
?
EDIT_END
这是预期的行为吗?
谢谢