仅从ansible剧本中运行一个任务和处理程序 [英] Run only one task and handler from ansible playbook
问题描述
我如何从Ansible剧本中运行单个任务,以及如何在该任务成功完成时获得通知的处理程序,同时跳过相关剧本中的所有其他任务?
How can I run a single task from an Ansible playbook and the handler that gets notified when that task completes successfully, while skipping all other tasks in the relevant playbook?
当前,我执行以下操作:
Currently I execute the following:
ansible-playbook --start-at-task "task1" --step -K -i hosts playbook.yml
,然后在任务完成后按 Ctrl + c .但是,这也会跳过处理程序.
and then press Ctrl+c after the task has finished. This will also skip the handler however.
I know I can add a tag to the task and use that, as in How to run only one task in ansible playbook?, but I would prefer being able to do this without adding a tag. Is that possible?
推荐答案
ansible-playbook目前没有任何东西可以让您运行单个任务,例如-task
.因此,对我来说,标记和-tags
选项一起是您的最佳解决方案.
There's currently nothing coming with ansible-playbook to allow you to run a single task, like --task
. Thus, to me, the tag along with the --tags
option is your best solution here.
这篇关于仅从ansible剧本中运行一个任务和处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!