There is such a playbook:
---
- hosts: [localhost]
remote_user: "max"
become: no
tasks:
- name: check packages
package_facts:
manager: auto
- name: print
debug:
msg: "{{ ansible_facts.packages['vim'][0]['name'] }} is {{ ansible_facts.packages['vim'][0]['version'] }}"
Output:
TASK [print] ****************************************************************************************************************************************************************
ok: [localhost] =>
msg: vim is 2:8.2.3995-1ubuntu2.17
How can I make it so that, instead of just vim, it iterates through a list of the names of the packages that I specify?