Re: [ansible-project] Listing installed packages

2021-10-14 Thread Dick Visser
This very question was asked (and answered) a few weeks ago:

https://groups.google.com/g/ansible-project/c/FsrlY_57hfo/m/x8jt7LMuBQAJ



On Thu, 14 Oct 2021 at 19:21, lift...@gmail.com  wrote:

> I know I can use the package_facts module to retrieve a list of installed
> packages, but I'm having trouble formatting these.  I'd like to format it
> similar to the following:
>
> Package:   Version: 
>
> Currently I'm doing the following (I'm showing only httpd but ultimately
> I'd like to list out ALL installed packages:
>
> ---
> - hosts: localhost
>   become: true
>   become_method: sudo
>   gather_facts: no
>
>   tasks:
>
>   - name: Get installed packages
> package_facts:
> register: packages
>
>   - name: Debug output
> debug:
>   msg: "{{ packages.ansible_facts.packages['httpd'] }}"
>
> The debug print is giving me the following:
>
> TASK [Debug output]
> **
> ok: [localhost] => {
> "msg": [
> {
> "arch": "x86_64",
> "epoch": null,
> "name": "httpd",
> "release": "97.el7_9",
> "source": "rpm",
> "version": "2.4.6"
> }
> ]
> }
>
> Any ideas?
>
> Thanks,
> Harry
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ansible Project" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to ansible-project+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/ansible-project/3908f91f-2a4d-493d-9bf7-a3f3edde4309n%40googlegroups.com
> 
> .
>


-- 
Dick Visser
Trust & Identity Service Operations Manager
GÉANT

-- 
You received this message because you are subscribed to the Google Groups 
"Ansible Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/CAL8fbwO-O8oZu%2B55%3DBq8s9gco1FfcBxT2Owp2iuNQXM1dSaQrQ%40mail.gmail.com.


Re: [ansible-project] Listing installed packages

2021-10-14 Thread 'Jean-Yves LENHOF' via Ansible Project

Le 2021-10-14 19:21, lift...@gmail.com a écrit :

I know I can use the package_facts module to retrieve a list of
installed packages, but I'm having trouble formatting these.  I'd like
to format it similar to the following:

Package:   Version: 

Currently I'm doing the following (I'm showing only httpd but
ultimately I'd like to list out ALL installed packages:

---
- hosts: localhost
  become: true
  become_method: sudo
  gather_facts: no

  tasks:

  - name: Get installed packages
package_facts:
register: packages

  - name: Debug output

debug:
  msg: "{{ packages.ansible_facts.packages['httpd'] }}"

The debug print is giving me the following:

TASK [Debug output]
**
ok: [localhost] => {
"msg": [
{
"arch": "x86_64",
"epoch": null,
"name": "httpd",
"release": "97.el7_9",
"source": "rpm",
"version": "2.4.6"
}
]
}

Any ideas?

Thanks,
Harry


You can use templating to have it on one line...

But be careful :
- you can have more than one version of a package installed. Example: 
kernel
- you can have one x86_64 and one i686 or i386 version of a package 
installed


Regards,


--
Jean-Yves LENHOF

--
You received this message because you are subscribed to the Google Groups "Ansible 
Project" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to ansible-project+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/ansible-project/c35818c74a992704b45ffa2bc82c755e%40lenhof.eu.org.