Need help with playbook to gather info from inventory and direct to a file

Hi All,

Need some help with creating a playbook to gather hostname, OS and package information from the inventory and output the result to a file in below format.

“Hostname, OS, Package”

I was able to come up with below playbook but it does not give the desired output.

Use the template module, with Jinja you can have loops and loop over the variables.