修正Playbook中的错误后,如何继续执行失败的任务? [英] How to continue execution on failed task after fixing error in playbook?

查看:442
本文介绍了修正Playbook中的错误后,如何继续执行失败的任务?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

编写和调试Ansible剧本时,典型的工作流程如下:

When writing and debugging Ansible playbooks, typical workflow is as follows:

  1. ansible-playbook ./main.yaml
  2. Playbook无法完成某些任务
  3. 修复此任务并重复第1行,等待所有先前的任务再次执行.这需要很多时间

理想情况下,我想继续执行失败的任务,并收集库存和以前任务收集的所有事实.可能吗?如何使剧本的编写/调试速度更快?

Ideally, i'd like to resume execution on failed task, having inventory and all facts collected by previous tasks. Is it even possible? How to make playbook writing/debugging faster?

推荐答案

看看 http://docs.ansible.com/playbooks_startnstep.html . 如果要开始执行特定任务的剧本,可以使用--start-at-task选项:

Take a look at http://docs.ansible.com/playbooks_startnstep.html. If you want to start executing your playbook at a particular task, you can do so with the --start-at-task option:

ansible-playbook playbook.yml --start-at-task="install packages"

上面的代码将在名为安装程序包" 的任务上开始执行您的剧本.

The above will start executing your playbook at a task named "install packages".

或者,看看前面的答案如何在ansible剧本中只执行一项任务?

Alternatively, take a look at this previous answer How to run only one task in ansible playbook?

最后,当播放失败时,通常会为您提供以下内容:

Finally, when a play fails, it usually gives you something along the lines of:

PLAY RECAP ******************************************************************** 
           to retry, use: --limit @/home/user/site.retry

使用该--limit命令,它应该从失败的任务中重试.

Use that --limit command and it should retry from the failed task.

这篇关于修正Playbook中的错误后,如何继续执行失败的任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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