0

I am on Ansible 2.9 Is there any way we can Hide/Skip these output from showing? ...ignoring tasks are always flooding the output.

I have tried the below options separately.

export ANSIBLE_DISPLAY_SKIPPED_HOSTS=false
display_skipped_hosts = False
stdout_callback = full_skip

Example Output:

TASK [Load domain based var file if it exists] ****************************************************************************************************************************************************************************************************************
fatal: [example-host1]: FAILED! => {"ansible_facts": {}, "ansible_included_var_files": [], "changed": false, "message": "Could not find or access 'example.com.yml'\nSearched in:\n\t/home/spidy/my_task/vars/example.com.yml\n\t/home/spidy/my_task/example.com.yml\n\t/home/spidy/my_task/vars/example.com.yml\n\t/home/spidy/my_task/example.com.yml on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"}
...ignoring

fatal: [example-host2]: FAILED! => {"ansible_facts": {}, "ansible_included_var_files": [], "changed": false, "message": "Could not find or access 'example.com.yml'\nSearched in:\n\t/home/spidy/my_task/vars/example.com.yml\n\t/home/spidy/my_task/example.com.yml\n\t/home/spidy/my_task/vars/example.com.yml\n\t/home/spidy/my_task/example.com.yml on the Ansible Controller.\nIf you are using a module and expect the file to exist on the remote, see the remote_src option"}
...ignoring

I wish we have some option there to skip these annoying output :(.

Hope someone already came across this in their thoughts!

Anto
  • 3,128
  • 1
  • 20
  • 20
  • You cannot completely hide those sections in job log. But, Line "fatal: [example-host1]: FAILED! => {***" can be hidden, added `no_log: true` for the tasks – KrishnaR Apr 07 '22 at 13:44
  • It seems there is a lot of information missing, especially the task itself which produces the output. Can you provide a more detailed descruption? – U880D Apr 07 '22 at 13:58
  • @U880D I have long list of tasks, all kind which are using `ignore_errors: true`. So these output are expected. But I want to Hide it. So that the output would be more readable. – Anto Apr 07 '22 at 16:27
  • Can you show the source code of the tasks? Furthermore, if there is long list of tasks and for all of them you are expecting errors and just ignore them currently, then probably the logic and the [Error handling in playbooks](https://docs.ansible.com/ansible/latest/user_guide/playbooks_error_handling.html) is not as it should be. – U880D Apr 07 '22 at 16:46
  • @U880D I will try with your below recommendation (failed_when ) wherever possible. Also, I think I can't use it everywhere. – Anto Apr 12 '22 at 05:26

1 Answers1

0

Because of the message ...ignoring I assume you are using ignore_errors: true to "Ignoring failed commands" completly. Instead of that you may Define failure and what it means by using failed_when: ... and already because of

The ignore_errors directive only works when the task is able to run and returns a value of failed. It does not make Ansible ignore undefined variable errors, connection failures, execution issues ...

Further Q&A

U880D
  • 8,601
  • 6
  • 24
  • 40