CentOS 6.6 上的 sudo 和 --ask-sudo-pass

CentOS 6.6 上的 sudo 和 --ask-sudo-pass

我正在运行命令:

[[email protected] ]# ansible example.com -a "sudo id" --ask-sudo-pass
sudo password:
example.com | FAILED >> {
"failed": true,
"msg": "[sudo] password for kamil: \r\n{\"changed\": true, \"end\": \"2015-02-05 12:06:16.612869\", \"stdout\": \"\", \"cmd\": [\"sudo\", \"id\"], \"start\": \"2015-02-05 12:01:16.533325\", \"delta\": \"0:05:00.079544\", \"stderr\": \"\", \"rc\": 1, \"warnings\": []}\r\nOpenSSH_5.3p1, OpenSSL 1.0.1e-fips 11 Feb 2013\ndebug1: Reading configuration data /etc/ssh/ssh_config\r\ndebug1: Applying options for *\r\ndebug1: auto-mux: Trying existing master\r\ndebug2: fd 3 setting O_NONBLOCK\r\ndebug2: mux_client_hello_exchange: master version 4\r\ndebug3: mux_client_request_forwards: requesting forwardings: 0 local, 0 remote\r\ndebug3: mux_client_request_session: entering\r\ndebug3: mux_client_request_alive: entering\r\ndebug3: mux_client_request_alive: done pid = 21782\r\ndebug3: mux_client_request_session: session request sent\r\ndebug1: mux_client_request_session: master session id: 3\r\ndebug1: mux_client_request_session: master session id: 3\r\ndebug3: mux_client_read_packet: read header failed: Broken pipe\r\ndebug2: Received exit status from master 0\r\nShared connection to example.com closed.\r\n",
"parsed": false
}

例如,针对 Debian 运行的相同命令正在运行。

答案1

尝试这个;

ansible example -a "id" --sudo -K

这将使用 ansible 内置的 sudo 函数运行命令,该函数将使用 -K(ask-sudo-pass)标志。如果您尝试在命令中运行 sudo,它将不会使用 -K(--ask-sudo-pass)密码。

相关内容