本文介绍了ansible剧本失败:超时(12s)等待特权升级提示:"}的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在VM上自动化一些手动任务.因此,我的VM没有直接的root访问权限.因此,我必须使用其他用户,然后升级到root用户.当我尝试切换为root用户时,密码提示与默认提示不同.我看到的提示如下所示

I'm trying to automate some of my manual tasks on a VM.As part of that my VM doesn't have direct root access.So I've to use a different user and then escalate to root.When I try to switch to root user, the password prompt is different than the default prompt.The prompt I see is as shown below

==================[user1 @ vm-1 tmp] $ su-root

==================[user1@vm-1 tmp]$ su - root

我写了一本剧本来测试连通性.该剧如下所示

I wrote a playbook to test the connectivity. The play looks as below

 hosts: vm-1
 any_errors_fatal: true
 become: true
 become_method: su
 become_user: root
 gather_facts: no
 vars:
 ansible_become_pass: "r00t"
 tasks:
 name: Test me
 command: 'echo works'

===================================

=====================================

localhost ansible_ssh_extra_args='-o StrictHostKeyChecking=no'
vm-1 ansible_ssh_host=1.2.3.4
ansible_connection=ssh
ansible_ssh_user=user1
ansible_ssh_pass=password
ansible_ssh_extra_args='-o StrictHostKeyChecking=no'

===================================

=====================================

使用此配置,当我尝试运行播放时,我遇到了错误

With this config, when I try to run the play, I'm getting below error

同一本剧本可以在其他VM上运行,但是尝试将用户切换为root时的提示只是"Passowrd"

The same playbook works on a different VM but the prompt while trying to switch user to root is simply "Passowrd"

感谢您的帮助.

通过我在ansible 2.4、2.5版本中尝试过的方式.在这两个版本中,我都遇到相同的错误.

By the way I tried this in ansible 2.4, 2.5 versions. In both the releases I got the same error.

先谢谢了.拉木

推荐答案

我很难找到一张打开的票,但是这是一张已关闭的票,有一些变通办法和某些解决方案可能对您不起作用: https://github.com/ansible/ansible/issues/14426

I had difficulties tracking down an open ticket but here is one that is closed and has some workarounds and some solutions that may or may not work for you:https://github.com/ansible/ansible/issues/14426

我至少有两台机器,列出的解决方案均无法正常工作.它还会在没有Ansible的情况下减慢直接SSH的速度,并且重新启动将不起作用.我无法找出问题,所以现在我只是重建机器.

I have had at least two machines where none of the listed solutions work. It also slows down a direct SSH without Ansible and a reboot does not work. I was unable to figure out the issue so now I just rebuild the machine.

正如@AHT所说,您可以将ansible.cfg中的超时时间增加到30秒,但是,我认为这只是暂时的,因为它掩盖了更大的问题.

As @AHT said, you could just increase the timeout to 30 seconds in ansible.cfg, however, I think this should only be temporary being it is masking the bigger issue.

这篇关于ansible剧本失败:超时(12s)等待特权升级提示:"}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-01 21:52