【问题标题】:How to set an Ansible API tqm.run() timeout for MFA Users?如何为 MFA 用户设置 Ansible API tqm.run() 超时?
【发布时间】:2019-12-09 21:54:49
【问题描述】:

当 'ansible_user' 被错误地设置为 MFA 用户时,tqm 会无限期挂起。
我在这里的'task_queue_manager.py'中设置了一个断点:

play_return = strategy.run(iterator, play_context)

但我找不到任何可以用来停止、结束或出错的程序。
下面是 sudo 代码,代表猜测它是如何工作的。

timeout = 300
result = tqm.run(play)
if not result and timeout and tqm is not None:
    tqm.cleanup()

有没有人知道直接使用 tqm 的解决方案,甚至是我上面没有提到的解决方法?

【问题讨论】:

    标签: python ansible multi-factor-authentication ansible-api


    【解决方案1】:

    我通过使用 func_timeout 库找到了解决此问题的方法。将 tqm.run 包装在 try 块中并将其发送到超时 fcn 对我有用。

    try: exitstatus = func_timeout(self.tqm_timeout, tqm.run, args=(play,)) except FunctionTimedOut: msg = "tqm.run could not complete within {} seconds and was terminated.".format(self.tqm_timeout) raise Exception(msg) except Exception as e: raise Exception('exception in tqm was {}'.format(e))

    【讨论】:

      猜你喜欢
      • 2023-04-08
      • 2015-10-18
      • 1970-01-01
      • 2020-05-19
      • 2011-07-11
      • 1970-01-01
      • 2011-05-14
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多