I have Ansible role, for example
---
- name: Deploy app1
include: deploy-app1.yml
when: 'deploy_project == "{{app1}}"'
- name: Deploy app2
include: deploy-app2.yml
when: 'deploy_project == "{{app2}}"'
But I deploy only one app in one role call. When I deploy several apps, I call role several times. But every time there is a lot of skipped tasks output
(from tasks which do not pass condition), which I do not want to see. How can I avoid it?
If you are using roles, you can use
when
to cancel the include in main.ymlAnsible allows you to control its output by using custom callbacks.
In this case you can simply use the
skippy
callback which will not output anything on a skipped task.Since ansible 2.4, a callback plugin name full_skip was added to suppress the skipping of task names and skipping keyword in the ansible output. You can try the below ansible configuration:
I'm assuming you don't want to see the skipped tasks in the output while running Ansible.
Set this to false in the ansible.cfg file.
Note. It will still output the name of the task although it will not display "skipped" anymore.
UPDATE: by the way you need to make sure ansible.cfg is in the current working directory.
Taken from the ansible.cfg file.
So ensure you are setting
display_skipped_hosts = false
in the right ansible.cfg file.Let me know how you go
If you don't mind losing colours you can elide the skipped tasks by piping the output through sed: