修复剧本中的错误后如何继续执行失败的任务? [英] How to continue execution on failed task after fixing error in playbook?
问题描述
在编写和调试 Ansible playbook 时,典型的工作流程如下:
When writing and debugging Ansible playbooks, typical workflow is as follows:
ansible-playbook ./main.yaml
- Playbook 在某些任务上失败
- 修复此任务并重复第 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?
推荐答案
看一看 执行故障排除手册.如果您想在特定任务上开始执行您的剧本,您可以使用 --start-at-task
选项:
Take a look at Executing playbooks for troubleshooting.
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 playbook 中只运行一项任务?
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.
这篇关于修复剧本中的错误后如何继续执行失败的任务?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!