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

How do I avoid showing skipped Ansible tasks?

· 52CE 我爱测

The output of my playbooks are always completely swamped with useless output regarding which tasks have been skipped, which makes it annoying and time consuming to go through and find specific information I'm looking for. Here's …

问题原文

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

The output of my playbooks are always completely swamped with useless output regarding which tasks have been skipped, which makes it annoying and time consuming to go through and find specific information I'm looking for.

Here's an example of a playbook

- name: Stopping Puppet Agent
  service: name=pe-puppet state=stopped
  ignore_errors: true
  register: result
- include: rollback/restart-pe-puppet.yml
  when: result|failed

And the associated output:

TASK: [name | Stopping Puppet Agent] **************************************
<server.name> REMOTE_MODULE service name=pe-puppet state=stopped
changed: [server.name] => {"changed": true, "name": "pe-puppet",     "state":"stopped"}

TASK: [name | judge_log msg='Restarting pe-puppet'] ***********************
skipping: [server.name]

TASK: [name | starting pe-puppet] *****************************************
skipping: [server.name]

TASK: [name | judge_log msg='pe-puppet restart successful'] ***************
skipping: [sserver.name]

TASK: [name | judge_log msg='pe-puppet restart failed' sec=FATAL] *********
skipping: [server.name]

TASK: [name | fail msg="Failed to start pe-puppet."] **********************
skipping: [server.name]

TASK: [name | judge_log msg='{{APP_NAME | capitalize}} deployment failed.'] ***
skipping: [server.name]

TASK: [name | fail msg="The {{APP_NAME | capitalize}} deployment failed."] ***
skipping: [server.name]

Almost all of that output is useless to me. The display_skipped_hosts says it still causes the task header to appear. Is there any way to omit skipped tasks completely?

已采纳解答

原帖链接 · Nelson G. · CC BY-SA 3.0

I use another way without changing any code:

Ansible use 'default' callback plugin to display output, but you can use 'skippy' callback plugin instead of 'default'. 'skippy' use 'default' except for skipped tasks.

To use 'skipped' plugin, add following line (or uncomment it) in your ansible.cfg file:

stdout_callback = skippy

To localize you ansible.cfg, use command:

ansible --version

If you don't have this file, get example file from ansible sources and copy it in your working folder from where you call ansible.

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

资料来源与适用范围

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

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

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