ansible 在“sudo yum install"中挂起步 [英] ansible hangs in "sudo yum install"' step

查看:39
本文介绍了ansible 在“sudo yum install"中挂起步的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置 ansible (2.0) 以在 linux 机器上安装软件

I am trying to setup ansible (2.0) for installing software on a linux box

ies-iesd-jktools 是具有 ansible 的机器.ies-iesd-git-06 是目标.用户帐户是 iesdgrid,可以在目标机器上执行 sudo.

ies-iesd-jktools is the machine with ansible. ies-iesd-git-06 is the target. User account is iesdgrid that can do sudo on target machine.

以下命令挂在远程:-

    ies-iesd-jktools:~/ansible$ ansible ies-iesd-git-06  \
           -i inventory  -m raw \
           -a "sudo yum install -y python-simplejson"   -vvvv

Using /usr/src/ansible/ansible.cfg as config file

SUDO password: <I type password here>

Loaded callback minimal of type stdout, v2.0
<ies-iesd-git-06> ESTABLISH CONNECTION FOR USER: None on PORT 22 TO ies-iesd-git-06
<ies-iesd-git-06> EXEC sudo yum install -y python-simplejson

这会在目标机器上启动 sudo,但不会像等待密码那样继续

This starts a sudo on target machine, but does not proceed as if it is waiting for password

$ hostname
ies-iesd-git-06
$
$ ps -ef| grep su
root       583   582  0 09:01 pts/1    00:00:00 sudo yum install -y python-simplejson
iesdgrid   811   771  0 09:05 pts/2    00:00:00 grep su

哪里出错了?

过了一会儿,我得到了

sudo: pam_authenticate: Conversation error

(手动登录到目标机器并 sudo 在那里工作.)

(manually login to the target machine and sudo there works. )

推荐答案

需要指定--become --become-user root --ask-become-pass 参数,因此 ansible 会在执行命令之前 sudo su 到 root.

You need to specify the --become --become-user root --ask-become-pass parameters so ansible will sudo su to root prior to executing the command.

ansible -m raw -a "yum install python-simplejson" testserver --ask-become-pass --become-user root --become
SUDO password:
testserver | SUCCESS | rc=0 >>

Loaded plugins: security
Setting up Install Process
Static_ol6_UEK2_latest                                   | 2.3 kB     00:00
Static_ol6_latest                                        | 2.3 kB     00:00
Package python-simplejson-2.0.9-3.1.el6.x86_64 already installed and latest version
Nothing to do

这篇关于ansible 在“sudo yum install"中挂起步的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆