栏目分类:
子分类:
返回
名师互学网用户登录
快速导航关闭
当前搜索
当前分类
子分类
实用工具
热门搜索
名师互学网 > IT > 软件开发 > 后端开发 > Python

ansible问题记录--Timeout (12s) waiting for privilege escalation prompt

Python 更新时间: 发布时间: IT归档 最新发布 模块sitemap 名妆网 法律咨询 聚返吧 英语巴士网 伯小乐 网商动力

ansible问题记录--Timeout (12s) waiting for privilege escalation prompt

问题描述

在项目中使用ansible做批量操作,但是环境限制只能用非root用户访问,然后才能切root权限。配置好hostfile之后,使用报错:

10.219.19.116 | FAILED! => {
    "failed": true, 
    "msg": "Timeout (122s) waiting for privilege escalation prompt: "
}

ansible版本:2.3.0

问题原因

使用非root用户登录,然后用su方法切换,就会抛出这个问题, 属于ansible的一个bug。

解决办法

修改/usr/lib/python2.7/site-packages/ansible-2.3.0.0-py2.7.egg/ansible/plugins/connection/__init__.py 此路径取决于你的实际情况。

    def check_password_prompt(self, b_output):
        if self._play_context.prompt is None:
            return False
        elif isinstance(self._play_context.prompt, string_types):
            b_prompt = to_bytes(self._play_context.prompt).strip()
            b_lines = b_output.splitlines(True)
            if not b_lines:
                return False
            return b_lines[-1].strip().endswith(b_prompt) or b_lines[0].strip().endswith(b_prompt)
        # 新增下面的两行代码,解决上述bug
        else:
            return self._play_context.prompt(b_output)

修改之后,重新运行,可以正常使用了。

转载请注明:文章转载自 www.mshxw.com
本文地址:https://www.mshxw.com/it/341576.html
我们一直用心在做
关于我们 文章归档 网站地图 联系我们

版权所有 (c)2021-2022 MSHXW.COM

ICP备案号:晋ICP备2021003244-6号