【问题标题】:how can i exceed time in my ansible playbook execution我如何在我的 ansible playbook 执行中超过时间
【发布时间】:2019-10-02 16:10:37
【问题描述】:

我正在使用命令模块执行剧本 当我手动运行命令时,该命令将执行 20 分钟相同的命令我正在执行 ansible playbook 我收到 ssh 会话超时错误我该如何克服这个错误

ansible-playbook -i hots test.yml -T 1500

ansible-playbook -i hots test.yml --timeout 1500

 

tasks:
  - name: executing the command
    command: -------------
    retries: 30

我已尝试使用 shell 或命令来执行 playbook

tasks:
  - name: executing the create foldr
    command: echo "hi"
  - name: executing the command
    command: -------------
    retries: 30

如何设置执行我的剧本 3o 分钟的时间段

或完成命令执行

在我的剧本中,我在我的剧本中运行了多个命令模块,所有模块都在简单执行中,但是一个命令模块需要时间来执行命令

【问题讨论】:

    标签: ansible ansible-inventory


    【解决方案1】:

    您应该寻找asyncpoll 选项。

    - name: executing the command
      command: "-------------"
      async: 30
      poll: 0
    

    如果您的要求是暂停剧本或等待某些特定条件,您也可以参考wait_for 选项

    【讨论】:

      【解决方案2】:

      我的建议是玩这个参数:

          # SSH timeout
          #timeout = 10
      

      在 /etc/ansible/ansible.cfg 中

      【讨论】:

        【解决方案3】:

        对于长时间运行的任务,建议将其设为异步,这样您就不会保持 ssh 连接处于打开状态,也不会因网络超时或其他原因而受到影响。 https://docs.ansible.com/ansible/latest/user_guide/playbooks_async.html

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2023-03-23
          • 2014-01-14
          • 1970-01-01
          • 2017-09-16
          • 1970-01-01
          相关资源
          最近更新 更多