问题描述
我正在尝试在 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-1]:失败!=> {"msg": "等待权限超时(12s)升级提示:"}
相同的剧本适用于不同的虚拟机,但尝试将用户切换到 root 时的提示只是Passowrd"
The same playbook works on a different VM but the prompt while trying to switch user to root is simply "Passowrd"
感谢您在这方面的帮助.
Appreciate your help on this.
顺便说一下,我在 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 playbook 失败:等待提权提示超时(12 秒):"}的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!