如何显示长期运行的Ansible任务的进度? [英] How can I show progress for a long-running Ansible task?

查看:575
本文介绍了如何显示长期运行的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任务的进度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆