How to list installed and available versions of packages

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