# How to list installed and available versions of packages

**URL:** <https://forum.ansible.com/t/how-to-list-installed-and-available-versions-of-packages/35399>\
**Category:** Ansible Project\
**Created:** [June 23, 2021, 10:59pm UTC](https://forum.ansible.com/t/how-to-list-installed-and-available-versions-of-packages/35399 "2021-06-23T22:59:15Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ozgur\_G](https://avatars.discourse-cdn.com/v4/letter/o/f08c70/32.png) [@Ozgur\_G](https://forum.ansible.com/u/Ozgur_G)\
**Post date:** [June 23, 2021, 10:59pm UTC](https://forum.ansible.com/t/how-to-list-installed-and-available-versions-of-packages/35399/1 "2021-06-23T22:59:15Z")

</div>

Hi - I posted in ansible project group by mistake.

How can I iterate over variable yum\_output results?  
Task I want to script is roughly like this

- name: List installed and available versions of packages.  
yum:  
list: “{{ packages }}”  
vars:  
packages:

- libsss\_idmap

- openldap-clients

- glibc-common

- sssd-client  
register: yum\_output

- name: Print available package versions.  
debug:  
msg: “{{ item.version }}-{{ item.release }}”  
loop: “{{ yum\_output.results | selectattr(‘yumstate’, ‘equalto’, ‘available’) | list }}”

- debug: var=yum\_output

Any suggestions?

Many thanks,  
Ozgur
