package_facts¶
Collection Note
This module is part of the ansible.builtin collection. To install the collection, use:
Added in version2.5.
You need further requirements to be able to use this module, see the Requirements section for details.
Synopsis¶
- Return information about installed packages as facts.
Requirements¶
The following Python packages are needed on the host that executes this module:
Parameters¶
| Parameter | Defaults / Choices | Comments |
|---|---|---|
| manager list / elements=str |
Default: ['auto'] Choices: apk, apt, auto, dnf, dnf5, openbsd_pkg, pacman, pkg, pkg5, pkg_info, pkgng, portage, rpm, yum, zypper |
The package manager(s) used by the system so we can query the package information. This is a list and can support multiple package managers per system, since version 2.8. The V(portage) and V(pkg) options were added in version 2.8. The V(apk) option was added in version 2.11. The V(pkg_info) option was added in version 2.13. Aliases were added in 2.18, to support using C(manager={{ansible_facts['pkg_mgr']}}) |
| strategy str |
Default: first Choices: all, first |
This option controls how the module queries the package managers on the system. Version Added: 2.8 |
Examples¶
- name: Gather the package facts
ansible.builtin.package_facts:
manager: auto
- name: Print the package facts
ansible.builtin.debug:
var: ansible_facts.packages
- name: Check whether a package called foobar is installed
ansible.builtin.debug:
msg: "{{ ansible_facts.packages['foobar'] | length }} versions of foobar are installed!"
when: "'foobar' in ansible_facts.packages"
Return Values¶
| Key | Data Type | Description | Returned |
|---|---|---|---|
| ansible_facts | complex | Facts to add to ansible_facts. | always |
Authors¶
- Matthew Jones (@matburt)
- Brian Coca (@bcoca)
- Adam Miller (@maxamillion)