Dashboard
PHP:
8.2.30
OS:
Linux
User:
dh_nv8b2m
/
/
usr
/
local
/
lib
/
python3.10
/
dist-packages
/
ansible
/
modules
/
__pycache__
📤 Upload
📝 New File
📁 New Folder
Close
Editing: dnf.cpython-310.pyc
o O�h� � @ s� d dl mZ dZdZd dlZd dlZd dlmZmZ d dl m Z d dlmZ d dl mZ d d lmZ d d lmZmZmZ d dlmZmZ daG dd � d e�Zdd� Zedkr[e� dS dS )� )�annotationsa�* --- module: dnf version_added: 1.9 short_description: Manages packages with the I(dnf) package manager description: - Installs, upgrade, removes, and lists packages and groups with the I(dnf) package manager. options: use_backend: description: - Backend module to use. default: "auto" choices: auto: Automatically select the backend based on the C(ansible_facts.pkg_mgr) fact. yum: Alias for V(auto) (see Notes) dnf: M(ansible.builtin.dnf) yum4: Alias for V(dnf) dnf4: Alias for V(dnf) dnf5: M(ansible.builtin.dnf5) type: str version_added: 2.15 name: description: - "A package name or package specifier with version, like C(name-1.0). When using state=latest, this can be '*' which means run: dnf -y update. You can also pass a url or a local path to an rpm file. To operate on several packages this can accept a comma separated string of packages or a list of packages." - Comparison operators for package version are valid here C(>), C(<), C(>=), C(<=). Example - C(name >= 1.0). Spaces around the operator are required. - You can also pass an absolute path for a binary which is provided by the package to install. See examples for more information. aliases: - pkg type: list elements: str default: [] list: description: - Various (non-idempotent) commands for usage with C(/usr/bin/ansible) and I(not) playbooks. Use M(ansible.builtin.package_facts) instead of the O(list) argument as a best practice. type: str state: description: - Whether to install (V(present), V(latest)), or remove (V(absent)) a package. - Default is V(None), however in effect the default action is V(present) unless the O(autoremove) option is enabled for this module, then V(absent) is inferred. choices: ['absent', 'present', 'installed', 'removed', 'latest'] type: str enablerepo: description: - I(Repoid) of repositories to enable for the install/update operation. These repos will not persist beyond the transaction. When specifying multiple repos, separate them with a ",". type: list elements: str default: [] disablerepo: description: - I(Repoid) of repositories to disable for the install/update operation. These repos will not persist beyond the transaction. When specifying multiple repos, separate them with a ",". type: list elements: str default: [] conf_file: description: - The remote dnf configuration file to use for the transaction. type: str disable_gpg_check: description: - Whether to disable the GPG checking of signatures of packages being installed. Has an effect only if O(state) is V(present) or V(latest). - This setting affects packages installed from a repository as well as "local" packages installed from the filesystem or a URL. type: bool default: 'no' installroot: description: - Specifies an alternative installroot, relative to which all packages will be installed. version_added: "2.3" default: "/" type: str releasever: description: - Specifies an alternative release from which all packages will be installed. version_added: "2.6" type: str autoremove: description: - If V(true), removes all "leaf" packages from the system that were originally installed as dependencies of user-installed packages but which are no longer required by any such package. Should be used alone or when O(state) is V(absent) type: bool default: "no" version_added: "2.4" exclude: description: - Package name(s) to exclude when state=present, or latest. This can be a list or a comma separated string. version_added: "2.7" type: list elements: str default: [] skip_broken: description: - Skip all unavailable packages or packages with broken dependencies without raising an error. Equivalent to passing the --skip-broken option. type: bool default: "no" version_added: "2.7" update_cache: description: - Force dnf to check if cache is out of date and redownload if needed. Has an effect only if O(state) is V(present) or V(latest). type: bool default: "no" aliases: [ expire-cache ] version_added: "2.7" update_only: description: - When using latest, only update installed packages. Do not install packages. - Has an effect only if O(state) is V(latest) default: "no" type: bool version_added: "2.7" security: description: - If set to V(true), and O(state=latest) then only installs updates that have been marked security related. - Note that, similar to C(dnf upgrade-minimal), this filter applies to dependencies as well. type: bool default: "no" version_added: "2.7" bugfix: description: - If set to V(true), and O(state=latest) then only installs updates that have been marked bugfix related. - Note that, similar to C(dnf upgrade-minimal), this filter applies to dependencies as well. default: "no" type: bool version_added: "2.7" enable_plugin: description: - I(Plugin) name to enable for the install/update operation. The enabled plugin will not persist beyond the transaction. version_added: "2.7" type: list elements: str default: [] disable_plugin: description: - I(Plugin) name to disable for the install/update operation. The disabled plugins will not persist beyond the transaction. version_added: "2.7" type: list default: [] elements: str disable_excludes: description: - Disable the excludes defined in DNF config files. - If set to V(all), disables all excludes. - If set to V(main), disable excludes defined in [main] in dnf.conf. - If set to V(repoid), disable excludes defined for given repo id. version_added: "2.7" type: str validate_certs: description: - This only applies if using a https url as the source of the rpm. e.g. for localinstall. If set to V(false), the SSL certificates will not be validated. - This should only set to V(false) used on personally controlled sites using self-signed certificates as it avoids verifying the source site. type: bool default: "yes" version_added: "2.7" sslverify: description: - Disables SSL validation of the repository server for this transaction. - This should be set to V(false) if one of the configured repositories is using an untrusted or self-signed certificate. type: bool default: "yes" version_added: "2.13" allow_downgrade: description: - Specify if the named package and version is allowed to downgrade a maybe already installed higher version of that package. Note that setting allow_downgrade=True can make this module behave in a non-idempotent way. The task could end up with a set of packages that does not match the complete list of specified packages to install (because dependencies between the downgraded package and others can cause changes to the packages which were in the earlier transaction). type: bool default: "no" version_added: "2.7" install_repoquery: description: - This is effectively a no-op in DNF as it is not needed with DNF. - This option is deprecated and will be removed in ansible-core 2.20. type: bool default: "yes" version_added: "2.7" download_only: description: - Only download the packages, do not install them. default: "no" type: bool version_added: "2.7" lock_timeout: description: - Amount of time to wait for the dnf lockfile to be freed. required: false default: 30 type: int version_added: "2.8" install_weak_deps: description: - Will also install all packages linked by a weak dependency relation. type: bool default: "yes" version_added: "2.8" download_dir: description: - Specifies an alternate directory to store packages. - Has an effect only if O(download_only) is specified. type: str version_added: "2.8" allowerasing: description: - If V(true) it allows erasing of installed packages to resolve dependencies. required: false type: bool default: "no" version_added: "2.10" nobest: description: - This is the opposite of the O(best) option kept for backwards compatibility. - Since ansible-core 2.17 the default value is set by the operating system distribution. required: false type: bool version_added: "2.11" best: description: - When set to V(true), either use a package with the highest version available or fail. - When set to V(false), if the latest version cannot be installed go with the lower version. - Default is set by the operating system distribution. required: false type: bool version_added: "2.17" cacheonly: description: - Tells dnf to run entirely from system cache; does not download or update metadata. type: bool default: "no" version_added: "2.12" extends_documentation_fragment: - action_common_attributes - action_common_attributes.flow attributes: action: details: dnf has 2 action plugins that use it under the hood, M(ansible.builtin.dnf) and M(ansible.builtin.package). support: partial async: support: none bypass_host_loop: support: none check_mode: support: full diff_mode: support: full platform: platforms: rhel notes: - When used with a C(loop:) each package will be processed individually, it is much more efficient to pass the list directly to the I(name) option. - Group removal doesn't work if the group was installed with Ansible because upstream dnf's API doesn't properly mark groups as installed, therefore upon removal the module is unable to detect that the group is installed (https://bugzilla.redhat.com/show_bug.cgi?id=1620324) - While O(use_backend=yum) and the ability to call the action plugin as M(ansible.builtin.yum) are provided for syntax compatibility, the YUM backend was removed in ansible-core 2.17 because the required libraries are not available for any supported version of Python. If you rely on this functionality, use an older version of Ansible. requirements: - "python >= 2.6" - python-dnf - for the autoremove option you need dnf >= 2.0.1" author: - Igor Gnatenko (@ignatenkobrain) <i.gnatenko.brain@gmail.com> - Cristian van Ee (@DJMuggs) <cristian at cvee.org> - Berend De Schouwer (@berenddeschouwer) - Adam Miller (@maxamillion) <admiller@redhat.com> aR - name: Install the latest version of Apache ansible.builtin.dnf: name: httpd state: latest - name: Install Apache >= 2.4 ansible.builtin.dnf: name: httpd >= 2.4 state: present - name: Install the latest version of Apache and MariaDB ansible.builtin.dnf: name: - httpd - mariadb-server state: latest - name: Remove the Apache package ansible.builtin.dnf: name: httpd state: absent - name: Install the latest version of Apache from the testing repo ansible.builtin.dnf: name: httpd enablerepo: testing state: present - name: Upgrade all packages ansible.builtin.dnf: name: "*" state: latest - name: Update the webserver, depending on which is installed on the system. Do not install the other one ansible.builtin.dnf: name: - httpd - nginx state: latest update_only: yes - name: Install the nginx rpm from a remote repo ansible.builtin.dnf: name: 'http://nginx.org/packages/centos/6/noarch/RPMS/nginx-release-centos-6-0.el6.ngx.noarch.rpm' state: present - name: Install nginx rpm from a local file ansible.builtin.dnf: name: /usr/local/src/nginx-release-centos-6-0.el6.ngx.noarch.rpm state: present - name: Install Package based upon the file it provides ansible.builtin.dnf: name: /usr/bin/cowsay state: present - name: Install the 'Development tools' package group ansible.builtin.dnf: name: '@Development tools' state: present - name: Autoremove unneeded packages installed as dependencies ansible.builtin.dnf: autoremove: yes - name: Uninstall httpd but keep its dependencies ansible.builtin.dnf: name: httpd state: absent autoremove: no - name: Install a modularity appstream with defined stream and profile ansible.builtin.dnf: name: '@postgresql:9.6/client' state: present - name: Install a modularity appstream with defined stream ansible.builtin.dnf: name: '@postgresql:9.6' state: present - name: Install a modularity appstream with defined profile ansible.builtin.dnf: name: '@postgresql/client' state: present N)� to_native�to_text)� fetch_file)�LooseVersion)� AnsibleModule)�get_best_parsable_locale)� has_respawned�probe_interpreters_for_module�respawn_module)�YumDnf�yumdnf_argument_specc s� e Zd ZdZ� fdd�Zdd� Zdd� Zdd � Zd d� Zd)dd�Z dd� Z dd� Zdd� Zdd� Z dd� Zd*dd�Zdd� Zdd � Zd!d"� Zd#d$� Zd%d&� Zd'd(� Z� ZS )+� DnfModulez4 DNF Ansible module back-end implementation c sJ t t| ��|� | �� d| _ztjj| _W d S t y$ d| _Y d S w )N�dnfF) �superr �__init__�_ensure_dnf�pkg_mgr_namer �base�WITH_MODULES�with_modules�AttributeError)�self�module�� __class__� �>/usr/local/lib/python3.10/dist-packages/ansible/modules/dnf.pyr � s �zDnfModule.__init__c C s. t d�t |�v st d�t |�v rd�|�S |S )z� For unhandled dnf.exceptions.Error scenarios, there are certain error messages we want to filter in an install scenario. Do that here. �no package matched�No match for argument:�No package {0} available.)r �format�r �spec�errorr r r �_sanitize_dnf_error_msg_install� s z)DnfModule._sanitize_dnf_error_msg_installc C s. dt |�v sdt |�v rdd�|�fS d|fS )z� For unhandled dnf.exceptions.Error scenarios, there are certain error messages we want to ignore in a removal scenario as known benign failures. Do that here. r r Fz{0} is not installedT)r r! r"