仅从 ansible playbook 运行一项任务和处理程序 [英] Run only one task and handler from ansible playbook

查看:29
本文介绍了仅从 ansible playbook 运行一项任务和处理程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何从 Ansible playbook 运行单个任务以及在该任务成功完成时收到通知的处理程序,同时跳过相关 playbook 中的所有其他任务?

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?

目前我执行以下操作:

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.

我知道我可以向任务添加标签并使用它,如 如何在 ansible playbook 中只运行一项任务?,但我希望能够在不添加标签的情况下执行此操作.这可能吗?

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 playbook 运行一项任务和处理程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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