我正在学习Ansible,而且我遇到了" apt"模块。 我写了ansible.cfg和库存文件,我可以正确运行
ansible testserver -m ping
现在我尝试在目标上安装NGinx,运行
ansible testserver -s -m apt -a name=nginx
但操作停止。这是" -vvv"的输出。标志
<IP> ESTABLISH CONNECTION FOR USER: user
<IP> REMOTE_MODULE apt name=nginx
<IP> EXEC ['ssh', '-C', '-tt', '-q', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/user/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', 'IP', "/bin/sh -c 'mkdir -p $HOME/.ansible/tmp/ansible-tmp-1445515245.75-119301060889986 && chmod a+rx $HOME/.ansible/tmp/ansible-tmp-1445515245.75-119301060889986 && echo $HOME/.ansible/tmp/ansible-tmp-1445515245.75-119301060889986'"]
<IP> PUT /tmp/tmpWaB4Lf TO /home/user/.ansible/tmp/ansible-tmp-1445515245.75-119301060889986/apt
<IP> EXEC ['ssh', '-C', '-tt', '-q', '-o', 'ControlMaster=auto', '-o', 'ControlPersist=60s', '-o', 'ControlPath=/home/user/.ansible/cp/ansible-ssh-%h-%p-%r', '-o', 'KbdInteractiveAuthentication=no', '-o', 'PreferredAuthentications=gssapi-with-mic,gssapi-keyex,hostbased,publickey', '-o', 'PasswordAuthentication=no', '-o', 'ConnectTimeout=10', 'IP', '/bin/sh -c \'sudo -k && sudo -H -S -p "[sudo via ansible, key=gakusrfbokzukkfpfgbvuseekjyqlllu] password: " -u root /bin/sh -c \'"\'"\'echo SUDO-SUCCESS-gakusrfbokzukkfpfgbvuseekjyqlllu; /usr/bin/python /home/user/.ansible/tmp/ansible-tmp-1445515245.75-119301060889986/apt; rm -rf /home/user/.ansible/tmp/ansible-tmp-1445515245.75-119301060889986/ >/dev/null 2>&1\'"\'"\'\'']
你知道问题的根源是什么吗?
谢谢
答案 0 :(得分:1)
我注意到你的结论是问题是sudo。只是为了让您知道,您没有 在您要定位的计算机上启用无密码sudo。运行Ansible playbook时可以使用--ask-sudo-pass
标志。