package_facts – package information as facts

New in version 2.5.

Synopsis

  • Return information about installed packages as facts

Requirements

The below requirements are needed on the host that executes this module.

  • For ‘portage’ support it requires the qlist utility, which is part of ‘app-portage/portage-utils’.
  • For Debian-based systems python-apt package must be installed on targeted hosts.

Parameters

Parameter Choices/Defaults Comments
manager
list
    Choices:
  • auto ←
  • rpm
  • apt
  • portage
  • pkg
Default:
["auto"]
The package manager used by the system so we can query the package information.
Since 2.8 this is a list and can support multiple package managers per system.
The 'portage' and 'pkg' options were added in version 2.8.
strategy
-
added in 2.8
    Choices:
  • first ←
  • all
This option controls how the module queries the package managers on the system. first means it will return only information for the first supported package manager available. all will return information for all supported and available package managers on the system.

Examples

- name: Gather the rpm package facts
  package_facts:
    manager: auto

- name: Print the rpm package facts
  debug:
    var: ansible_facts.packages

Returned Facts

Facts returned by this module are added/updated in the hostvars host facts and can be referenced by name just like any other host fact. They do not need to be registered in order to use them.

Fact Returned Description
packages
dictionary
when operating system level package manager is specified or auto detected manager
list of dicts with package information



Status

Authors

  • Matthew Jones (@matburt)
  • Brian Coca (@bcoca)
  • Adam Miller (@maxamillion)

Hint

If you notice any issues in this documentation, you can edit this document to improve it.