Automating Upgrades for Agents/Clients

I'm just wondering if there is some way to query for all attached agents. I'd like to generate a list of agents/servers for ansible so I can upgrade them all to their latest version.

Or if someone has a better solution to accomplish this that would be great too. I have 70+ clients I have to upgrade.

Thanks in advance,