大网数据广告活动
服务器运维问答

Easiest way to exit Ansible playbook while debugging

· 52CE 我爱测

Say I'm debugging an Ansible playbook and want to quit after a given task (and not run through all of the following tasks). Is there any one-line magic command available, or do I have to manually create an exit/assert task? From …

问题原文

原帖链接 · s g · CC BY-SA 3.0

Say I'm debugging an Ansible playbook and want to quit after a given task (and not run through all of the following tasks). Is there any one-line magic command available, or do I have to manually create an exit/assert task?

From the ansible-playbook manual, I see that there is a --start-at-task=START_AT flag, but I don't see anything like an 'end-at' counterpart.

已采纳解答

原帖链接 · xddsg · CC BY-SA 3.0

Using - pause: might suit.

Pauses playbook execution for a set amount of time, or until a prompt is acknowledged. All parameters are optional. The default behavior is to pause with a prompt. You can use ctrl+c if you wish to advance a pause earlier than it is set to expire or if you need to abort a playbook run entirely. To continue early: press ctrl+c and then c. To abort a playbook: press ctrl+c and then a.

http://docs.ansible.com/pause_module.html

Or just a straight - fail: if you will certainly not want to continue.

If you want a block of tasks to execute, you can use tags and --with-tags:. Ansible v2 will have proper code blocks so you can use a single when: for multiple tasks.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2015-06-05)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。