%PDF- %PDF-
| Direktori : /lib/python3.9/site-packages/ansible/modules/__pycache__/ |
| Current File : //lib/python3.9/site-packages/ansible/modules/__pycache__/package_facts.cpython-39.opt-1.pyc |
a
�)g�F � @ s d dl mZmZmZ eZdZdZdZd dl Z d dl
mZmZ d dl
mZmZ d dlmZ d d lmZ d d
lmZmZmZ d dlmZmZmZ G dd
� d
e�ZG dd� de�ZG dd� de�ZG dd� de�ZG dd� de�Z G dd� de�Z!G dd� de�Z"dd� Z#e$dk�re#� dS )� )�absolute_import�division�print_functiona8
module: package_facts
short_description: Package information as facts
description:
- Return information about installed packages as facts.
options:
manager:
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.
default: ['auto']
choices: ['auto', 'rpm', 'apt', 'portage', 'pkg', 'pacman', 'apk', 'pkg_info']
type: list
elements: str
strategy:
description:
- This option controls how the module queries the package managers on the system.
C(first) means it will return only information for the first supported package manager available.
C(all) will return information for all supported and available package managers on the system.
choices: ['first', 'all']
default: 'first'
type: str
version_added: "2.8"
version_added: "2.5"
requirements:
- For 'portage' support it requires the C(qlist) utility, which is part of 'app-portage/portage-utils'.
- For Debian-based systems C(python-apt) package must be installed on targeted hosts.
- For SUSE-based systems C(python3-rpm) package must be installed on targeted hosts.
This package is required because SUSE does not include RPM Python bindings by default.
author:
- Matthew Jones (@matburt)
- Brian Coca (@bcoca)
- Adam Miller (@maxamillion)
extends_documentation_fragment:
- action_common_attributes
- action_common_attributes.facts
attributes:
check_mode:
support: full
diff_mode:
support: none
facts:
support: full
platform:
platforms: posix
a�
- 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"
a�
ansible_facts:
description: Facts to add to ansible_facts.
returned: always
type: complex
contains:
packages:
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
type: dict
contains:
name:
description: The package's name.
returned: always
type: str
version:
description: The package's version.
returned: always
type: str
source:
description: Where information on the package came from.
returned: always
type: str
sample: |-
{
"packages": {
"kernel": [
{
"name": "kernel",
"source": "rpm",
"version": "3.10.0",
...
},
{
"name": "kernel",
"source": "rpm",
"version": "3.10.0",
...
},
...
],
"kernel-tools": [
{
"name": "kernel-tools",
"source": "rpm",
"version": "3.10.0",
...
}
],
...
}
}
# Sample rpm
{
"packages": {
"kernel": [
{
"arch": "x86_64",
"epoch": null,
"name": "kernel",
"release": "514.26.2.el7",
"source": "rpm",
"version": "3.10.0"
},
{
"arch": "x86_64",
"epoch": null,
"name": "kernel",
"release": "514.16.1.el7",
"source": "rpm",
"version": "3.10.0"
},
{
"arch": "x86_64",
"epoch": null,
"name": "kernel",
"release": "514.10.2.el7",
"source": "rpm",
"version": "3.10.0"
},
{
"arch": "x86_64",
"epoch": null,
"name": "kernel",
"release": "514.21.1.el7",
"source": "rpm",
"version": "3.10.0"
},
{
"arch": "x86_64",
"epoch": null,
"name": "kernel",
"release": "693.2.2.el7",
"source": "rpm",
"version": "3.10.0"
}
],
"kernel-tools": [
{
"arch": "x86_64",
"epoch": null,
"name": "kernel-tools",
"release": "693.2.2.el7",
"source": "rpm",
"version": "3.10.0"
}
],
"kernel-tools-libs": [
{
"arch": "x86_64",
"epoch": null,
"name": "kernel-tools-libs",
"release": "693.2.2.el7",
"source": "rpm",
"version": "3.10.0"
}
],
}
}
# Sample deb
{
"packages": {
"libbz2-1.0": [
{
"version": "1.0.6-5",
"source": "apt",
"arch": "amd64",
"name": "libbz2-1.0"
}
],
"patch": [
{
"version": "2.7.1-4ubuntu1",
"source": "apt",
"arch": "amd64",
"name": "patch"
}
],
}
}
# Sample pkg_info
{
"packages": {
"curl": [
{
"name": "curl",
"source": "pkg_info",
"version": "7.79.0"
}
],
"intel-firmware": [
{
"name": "intel-firmware",
"source": "pkg_info",
"version": "20210608v0"
}
],
}
}
N)� to_native�to_text)�
AnsibleModule�missing_required_lib)�get_best_parsable_locale)�get_bin_path)�
has_respawned�probe_interpreters_for_module�respawn_module)�LibMgr�CLIMgr�get_all_pkg_managersc s0 e Zd ZdZdd� Zdd� Z� fdd�Z� ZS )�RPM�rpmc C s | j �� �� S �N)�_libZTransactionSetZdbMatch��self� r �A/usr/lib/python3.9/site-packages/ansible/modules/package_facts.py�list_installed� s zRPM.list_installedc C s: t || jj || jj || jj || jj || jj d�S )N)�name�version�releaseZepoch�arch)�dictr ZRPMTAG_NAMEZRPMTAG_VERSIONZRPMTAG_RELEASEZRPMTAG_EPOCHZRPMTAG_ARCH�r �packager r r �get_package_details s
�zRPM.get_package_detailsc st t t| ��� }zNtd� |sBt� sBg d�}t|| j�}|rBt|� |sZt� dt
| j� � W n tyn Y n0 |S )zh we expect the python bindings installed, but this gives warning if they are missing and we have rpm clir )z/usr/libexec/platform-python�/usr/bin/python3�/usr/bin/python2zFound "rpm" but %s)�superr �is_availabler
r r �LIBr
�module�warnr �
ValueError)r �we_have_lib�interpreters�interpreter_path�� __class__r r r% s
zRPM.is_available)�__name__�
__module__�__qualname__r&