Ansible:如何解决"sudo:需要密码";错误? [英] Ansible: how to solve "sudo: a password is required" error?
问题描述
我有9台服务器,我正在尝试使用ansible安装软件包,我能够使用密码ssh进入其中的5台服务器,而其他4台服务器却不询问任何密码.
I have 9 servers and i am trying to install a package using ansible, i am able to ssh into 5 of the servers using a password and other 4 does not ask any password while ssh'ng into them.
但是我已将id_rsa.pub密钥复制到所有9台服务器中.
However i have copied id_rsa.pub key to all the 9 servers.
现在ansible脚本在5台服务器上正常工作,但在剩下的4台服务器上,我收到以下错误消息.
Now the ansible script is working fine for 5 server but w remaining 4 i am getting the following error message.
致命:[xxx0?]:失败! => {已更改":false,失败":true,"module_stderr":与xxx0的连接已关闭?\ r \ n","module_stdout":"sudo:需要密码\ r \ n","msg:"模块故障," rc:1}
fatal: [xxx0?]: FAILED! => {"changed": false, "failed": true, "module_stderr": "Connection to xxx0? closed.\r\n", "module_stdout": "sudo: a password is required\r\n", "msg": "MODULE FAILURE", "rc": 1}
我的Ansible.cfg
My Ansible.cfg
[defaults]
filter_plugins =./filter_plugins
roles_path = ./roles
sudo_user = root
host_key_checking = False
retry_files_enabled = False
password = ~/password.txt
timeout = 25
[ssh_connection]
ssh_args = -F ~/.ssh/config -o ControlMaster=no -o ControlPersist=30m
control_path = ~/.ssh/ansible-%%r@%%h:%%p
〜/.ssh/config
~/.ssh/config
Host xx0? xx0? xx0? xx0? xx0? xx0? xx0? xx0? xx0? .xyz.com
User yyy
Port 22
ansible版本= ansible 2.3.1.0
ansible version = ansible 2.3.1.0
我该如何解决此错误?
推荐答案
您收到错误:
sudo :需要密码
这并不意味着您无法连接到目标计算机,这意味着您需要提供密码才能运行具有提升权限的命令(或者您不能完全运行具有提升权限的命令).
It doesn't mean you can't connect to the target machine it means you need to provide a password to run a command with elevated permissions (or that you can't run a command with elevated permissions altogether).
相反,这意味着建立连接没有问题.
On the contrary, it means the connection is being established with no problems.
在受影响的计算机上修复您的sudoers
配置.
Fix your sudoers
configuration on the affected machines.
这篇关于Ansible:如何解决"sudo:需要密码";错误?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!