puppetversion is a facter value you can query. If you're running puppetdb you can query for agents that have (or don't have) the value(s) you want.