本文介绍了如何显示长时间运行的 Ansible 任务的进度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一些 Ansible 任务,它们执行很长的操作——比如使用 S3 文件夹运行同步操作.并不总是很清楚它们是否在进行中,或者只是卡住了(或者 ssh 连接已经死亡),因此显示某种进度输出会很好.如果直接显示命令的 stdout/stderr,我会看到,但 Ansible 会捕获输出.

I have a some Ansible tasks that perform unfortunately long operations - things like running an synchronization operation with an S3 folder. It's not always clear if they're progressing, or just stuck (or the ssh connection has died), so it would be nice to have some sort of progress output displayed. If the command's stdout/stderr was directly displayed, I'd see that, but Ansible captures the output.

将输出回传是 Ansible 以当前形式解决的一个难题.但是,我可以使用任何 Ansible 技巧来提供某种指示,表明事情仍在进行中吗?

Piping output back is a difficult problem for Ansible to solve in its current form. But are there any Ansible tricks I can use to provide some sort of indication that things are still moving?

当前票是 https://github.com/ansible/ansible/issues/4870

推荐答案

Ansible 已经实现了以下内容:

Ansible has since implemented the following:

---
# Requires ansible 1.8+
- name: 'YUM - async task'
  yum:
    name: docker-io
    state: installed
  async: 1000
  poll: 0
  register: yum_sleeper

- name: 'YUM - check on async task'
  async_status:
    jid: "{{ yum_sleeper.ansible_job_id }}"
  register: job_result
  until: job_result.finished
  retries: 30

有关更多信息,请参阅有关该主题的官方文档(确保您选择的是您的 Ansible 版本).

For further information, see the official documentation on the topic (make sure you're selecting your version of Ansible).

这篇关于如何显示长时间运行的 Ansible 任务的进度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-16 06:00