On Wed, 29 Sep 2021 10:55:06 +0200
Dick Visser <
dick....@geant.org> wrote:
> try this
>
> - debug:
> msg: |
> {% for pkg in ansible_facts.packages|dict2items %}
> {{ pkg.value[0].name }} {{ pkg.value[0].version }}
> {% endfor %}
More versions of the same package might be installed. This is
the reason why the items of the dictionary *packages* are lists. The
code above will list only the first package from the lists. Iterate
the lists if you want to be sure you get all packages, e.g.
- debug:
msg: |
{% for l in ansible_facts.packages|dict2items %}
{% for pkg in l.value %}
{{
pkg.name }} {{ pkg.version }}
{% endfor %}
{% endfor %}
This can be simplified
- debug:
msg: |
{% for l in packages %}
{% for p in packages[l] %}
{{
p.name }} {{ p.version }}
{% endfor %}
{% endfor %}
--
Vladimir Botka