ansible / ansible.builtin / v2.16.5 / module / package_facts Package information as facts | "added in version" 2.5 of ansible.builtin" Authors: Matthew Jones (@matburt), Brian Coca (@bcoca), Adam Miller (@maxamillion)ansible.builtin.package_facts (v2.16.5) — module
pip
Install with pip install ansible-core==2.16.5
Return information about installed packages as facts.
- 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"
manager: choices: - auto - rpm - apt - portage - pkg - pacman - apk - pkg_info default: - auto description: - 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. - The 'apk' option was added in version 2.11. - The 'pkg_info' option was added in version 2.13. elements: str type: list strategy: choices: - first - all default: first description: - This option controls how the module queries the package managers on the system. V(first) means it will return only information for the first supported package manager available. V(all) will return information for all supported and available package managers on the system. type: str version_added: '2.8' version_added_collection: ansible.builtin
ansible_facts: contains: packages: contains: name: description: The package's name. returned: always type: str source: description: Where information on the package came from. returned: always type: str version: description: The package's version. returned: always type: str description: - Maps the package name to a non-empty list of dicts with package information. - Every dict in the list corresponds to one installed version of the package. - The fields described below are present for all package managers. Depending on the package manager, there might be more fields for a package. returned: when operating system level package manager is specified or auto detected manager sample: "{\n \"packages\": {\n \"kernel\": [\n {\n \"name\"\ : \"kernel\",\n \"source\": \"rpm\",\n \"version\": \"3.10.0\"\ ,\n ...\n },\n {\n \"name\": \"kernel\",\n \ \ \"source\": \"rpm\",\n \"version\": \"3.10.0\",\n ...\n \ \ },\n ...\n ],\n \"kernel-tools\": [\n {\n \"name\"\ : \"kernel-tools\",\n \"source\": \"rpm\",\n \"version\": \"\ 3.10.0\",\n ...\n }\n ],\n ...\n }\n}\n# Sample rpm\n{\n\ \ \"packages\": {\n \"kernel\": [\n {\n \"arch\": \"x86_64\"\ ,\n \"epoch\": null,\n \"name\": \"kernel\",\n \"release\"\ : \"514.26.2.el7\",\n \"source\": \"rpm\",\n \"version\": \"\ 3.10.0\"\n },\n {\n \"arch\": \"x86_64\",\n \"epoch\"\ : null,\n \"name\": \"kernel\",\n \"release\": \"514.16.1.el7\"\ ,\n \"source\": \"rpm\",\n \"version\": \"3.10.0\"\n },\n\ \ {\n \"arch\": \"x86_64\",\n \"epoch\": null,\n \ \ \"name\": \"kernel\",\n \"release\": \"514.10.2.el7\",\n \ \ \"source\": \"rpm\",\n \"version\": \"3.10.0\"\n },\n {\n\ \ \"arch\": \"x86_64\",\n \"epoch\": null,\n \"name\"\ : \"kernel\",\n \"release\": \"514.21.1.el7\",\n \"source\"\ : \"rpm\",\n \"version\": \"3.10.0\"\n },\n {\n \"\ arch\": \"x86_64\",\n \"epoch\": null,\n \"name\": \"kernel\"\ ,\n \"release\": \"693.2.2.el7\",\n \"source\": \"rpm\",\n \ \ \"version\": \"3.10.0\"\n }\n ],\n \"kernel-tools\": [\n\ \ {\n \"arch\": \"x86_64\",\n \"epoch\": null,\n \ \ \"name\": \"kernel-tools\",\n \"release\": \"693.2.2.el7\",\n \ \ \"source\": \"rpm\",\n \"version\": \"3.10.0\"\n }\n \ \ ],\n \"kernel-tools-libs\": [\n {\n \"arch\": \"x86_64\"\ ,\n \"epoch\": null,\n \"name\": \"kernel-tools-libs\",\n \ \ \"release\": \"693.2.2.el7\",\n \"source\": \"rpm\",\n \ \ \"version\": \"3.10.0\"\n }\n ],\n }\n}\n# Sample deb\n{\n \"\ packages\": {\n \"libbz2-1.0\": [\n {\n \"version\": \"1.0.6-5\"\ ,\n \"source\": \"apt\",\n \"arch\": \"amd64\",\n \"\ name\": \"libbz2-1.0\"\n }\n ],\n \"patch\": [\n {\n \ \ \"version\": \"2.7.1-4ubuntu1\",\n \"source\": \"apt\",\n \ \ \"arch\": \"amd64\",\n \"name\": \"patch\"\n }\n ],\n \ \ }\n}\n# Sample pkg_info\n{\n \"packages\": {\n \"curl\": [\n {\n\ \ \"name\": \"curl\",\n \"source\": \"pkg_info\",\n \ \ \"version\": \"7.79.0\"\n }\n ],\n \"intel-firmware\": [\n\ \ {\n \"name\": \"intel-firmware\",\n \"source\": \"\ pkg_info\",\n \"version\": \"20210608v0\"\n }\n ],\n }\n\ }" type: dict description: Facts to add to ansible_facts. returned: always type: complex