How can I check for an installed packaged version on multiple linux hosts? i need to check more than 100 servers for the snapd package, but I don't like the output at all. I searched all day for different options without luck. Attached is the output of ansible-playbook. Any hints guys?  
---
 - hosts: centos
   become: true
   tasks:
    - name: Check Hostname
      command: /usr/bin/hostname

    - name: Check for package if is installed
      yum:
        list: snapd
      register: result

For checking the package version I tried with the following playbook but Ansible doesn't like the syntax:
---
 - hosts: test2
   become: true
   tasks:
    - name: Check Hostname
      command: /usr/bin/hostname

    - name: Check for package if is installed
      yum:
        list: snapd
      register: package_name_version

    - name: set package version
      set_fact:
        package_name_version: &quot;{{ package_name_version.results|selectattr('yumstate','equalto','installed')|map(attribute='version')|list|first }}&quot;

Thanks,
Juls
A simple way would be to do: 

ansible -i &lt;inventory&gt; &lt;target group, lets' say some CentOS systems&gt; -m shell -a "rpm -qa | grep &lt;package name&gt;"


That would display a list consisting of server name and package version.