我試探上樹莓派2新安裝的Archlinux安裝像這樣:Ansible 2.0.0.2:ansible不尊重「 - U」開關
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
有些事情可能會或可能不相關的有以下幾種:
- SSH不允許通過root登錄
- 須藤未安裝
- 默認用戶和傳球是「報警」:「報警」
- 沒有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
-u and
REMOTE_USER:`
原來的問題似乎依然不過。在清單中沒有提及ansible_user
,爲什麼使用root而不是通過- u
明確提及的用戶?
EDIT_END
這是預期的行爲?
感謝
「正在用root爲什麼...」這是因爲你是最有可能'在你的劇本中有「root:yes」 – sircapsalot
請記住,這是一個通過'ansible'而不是'ansible-playbook'進行的臨時執行。此外,在Ansible 2中,我認爲'ansible_ssh_user'已被重命名爲'ansible_user'。乾杯 – Ralph
我還是習慣了1.9 :)對不起我的無知2.0 – sircapsalot