How To: Query servers, write output to file

I know I can script this, but I am wondering if there is a way via ansible to basically grab the contents of a file on a remote server, format it, and write it to a local file? For example, I want to gather all users/groups listed in the sudoers file, and format it as such:

DATE:
ServerA
root
userA

ServerB

ServerC
root
userA
%GroupA

I am not concerned about the regexp needed, mostly I am wanting to grab data, format it as above, and append contents to a file

fetch/slurp to grab the file

local_action: temlate ... and do the format generation in the jinaj2 template.

Thank you