暂停 ansible playbook 以供用户确认,是否运行 rest 任务 [英] pause ansible playbook for user confirmation, whether to run rest tasks
问题描述
我正在运行一个 ansible-playbook
,其中列出了许多任务.所有这些都用来一个一个地运行,但我想在特定任务之后 pause
playbook 询问用户是否要继续运行其余的任务或退出.我已经看到了 ansible 的 pause 模块
,但看不到任何询问用户是或否的示例,然后相应地继续或退出 ansible-playbook.
I am running an ansible-playbook
which have many tasks listed. All of them use to get run one by one, but I want to pause
the playbook after a particular tasks to asks the user if he wants to continue running the rest of the tasks or exit. I have seen the pause module
of ansible but couldn't see any example which asks users for yes or no which in turn continue or exit the ansible-playbook accordingly.
推荐答案
pause
模块实际上就是这样做的.但是它没有给你一个选项来回答yes
或no
.相反,它希望用户按 Ctrl+C 然后按 a 中止.要继续,用户只需按 Enter.
The pause
module actually does exactly that. But it does not give you an option to answer yes
or no
. Instead it expects the user to press Ctrl+C and then a for abort. To continue the user simply needs to press Enter.
由于这对用户来说不是很明显,您可以在 prompt
参数中对其进行描述.
Since this is not perfectly obvious to the user you can describe it in the prompt
parameter.
- name: Exterminate mankind
pause:
prompt: Please confirm you want to exterminate mankind! Press return to continue. Press Ctrl+c and then "a" to abort
这篇关于暂停 ansible playbook 以供用户确认,是否运行 rest 任务的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!