how to prevent Ansible from showing output on screen?
This can be done by judicious use of one of the Ansible callback plugins. Set the relevant configuration in your ansible.cfg file.

You have a few options... 

In order to print nothing to the screen, you can use the null callback:


  This callback prevents outputing events to screen


However, this may be overkill and doesn't do what you want, which is to write the output to a file. This can be done with either of the 


tree or
log_plays


modules.

I would probably suggest the log_plays module in your case.

Note: This is going straight from the documentation. I haven't used the tree or log_plays plugin myself, opting either for the yaml or profile_tasks one, to make things more readable. It also seems like you want to filter just a part of the output, not all of it. You may want to use a combination of filters in order to get the desired effect.