a ì)gŸèã@sÚddlmZmZmZeZdZdZddlZddl Z ddl Z ddl m Z m Z ddlmZddlmZmZddlmZdd lmZdd lmZdd lmZmZmZdd lmZmZda Gd d„deƒZ!dd„Z"e#dkrÖe"ƒdS)é)Úabsolute_importÚdivisionÚprint_functiona& --- 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: 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 a 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. required: true aliases: - pkg type: list elements: str 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 C(list) argument as a best practice. type: str state: description: - Whether to install (C(present), C(latest)), or remove (C(absent)) a package. - Default is C(None), however in effect the default action is C(present) unless the C(autoremove) option is enabled for this module, then C(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 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 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 state is I(present) or I(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 C(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 state is I(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 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 state is I(present) or I(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 state is I(latest) default: "no" type: bool version_added: "2.7" security: description: - If set to C(true), and C(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 C(true), and C(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 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 elements: str disable_excludes: description: - Disable the excludes defined in DNF config files. - If set to C(all), disables all excludes. - If set to C(main), disable excludes defined in [main] in dnf.conf. - If set to C(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 C(false), the SSL certificates will not be validated. - This should only set to C(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 C(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, but is an accepted parameter for feature parity/compatibility with the I(yum) module. 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 I(download_only) is specified. type: str version_added: "2.8" allowerasing: description: - If C(true) it allows erasing of installed packages to resolve dependencies. required: false type: bool default: "no" version_added: "2.10" nobest: description: - Set best option to False, so that transactions are not limited to best candidates only. required: false type: bool default: "no" version_added: "2.11" 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: In the case of dnf, it has 2 action plugins that use it under the hood, M(ansible.builtin.yum) 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) requirements: - "python >= 2.6" - python-dnf - for the autoremove option you need dnf >= 2.0.1" author: - Igor Gnatenko (@ignatenkobrain) - Cristian van Ee (@DJMuggs) - Berend De Schouwer (@berenddeschouwer) - Adam Miller (@maxamillion) 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)ÚPY2Ú text_type)Ú LooseVersion)Ú AnsibleModule)Úget_best_parsable_locale)Ú has_respawnedÚprobe_interpreters_for_moduleÚrespawn_module)ÚYumDnfÚyumdnf_argument_speccsÔeZdZdZ‡fdd„Zdd„Zdd„Zdd „Zd d „Zd d „Z dd„Z dd„Z dd„Z d3dd„Z dd„Zdd„Zdd„Zdd„Zd d!„Zd4d#d$„Zd%d&„Zd'd(„Zd)d*„Zd+d,„Zd-d.„Zd/d0„Zd1d2„Z‡ZS)5Ú DnfModulez4 DNF Ansible module back-end implementation csltt|ƒ |¡| ¡d|_d|_ztjj|_ Wnt yJd|_ Yn0|j j d|_ |j j d|_dS)Nz/var/cache/dnf/*_lock.pidÚdnfFÚ allowerasingÚnobest)ÚsuperrÚ__init__Ú _ensure_dnfZlockfileZ pkg_mgr_namerÚbaseZ WITH_MODULESÚ with_modulesÚAttributeErrorÚmoduleÚparamsrr)Úselfr©Ú __class__©ú7/usr/lib/python3.9/site-packages/ansible/modules/dnf.pyrs  zDnfModule.__init__cCsdS)NTr!©rr!r!r"Úis_lockfile_pid_validžszDnfModule.is_lockfile_pid_validcCs.tdƒt|ƒvs tdƒt|ƒvr*d |¡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_installcCs.dt|ƒvsdt|ƒvr&dd |¡fSd|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)rr(r)r!r!r"Ú_sanitize_dnf_error_msg_remove°s  ÿ þz(DnfModule._sanitize_dnf_error_msg_removecCsb|j|jt|jƒ|j|j|jdœ}djfi|¤Ž|d<|d|d<|jdkrVd|d<nd|d<|S) z3Return a dictionary of information for the package.)ÚnameÚarchÚepochÚreleaseÚversionÚrepoz){epoch}:{name}-{version}-{release}.{arch}ZenvraÚnevrarÚ availableZyumstateÚ installed) r.r/Ústrr0r1r2Úrepoidr(Z installtime)rÚpackageÚresultr!r!r"Ú _package_dictÀsú    zDnfModule._package_dictcCs8gd¢}| d¡\}}}|r0|r0||vr0||fS|dfS)N)@Zaarch64Z alphaev56Zalphaev5Z alphaev67Zalphaev6ZalphaZ alphapca56Zamd64Zarmv3lZarmv4bZarmv4lZ armv5tejlZarmv5telZarmv5tlZarmv6hlZarmv6lZarmv7hlZarmv7hnlZarmv7lZathlonZgeodeZi386Zi486Zi586Zi686Zia32eZia64Zm68kZmips64elZmips64Z mips64r6elZmips64r6ZmipselZmipsZmipsr6elZmipsr6ZnoarchZpentium3Zpentium4Zppc32dy4Z ppc64iseriesZppc64leZppc64Zppc64p7Z ppc64pseriesZppc8260Zppc8560Z ppciseriesZppcZ ppcpseriesZriscv64Zs390Zs390xZsh3Zsh4aZsh4ÚshZsparc64Zsparc64vZsparcZsparcv8Zsparcv9Zsparcv9vZx86_64Ú.)Ú rpartition)rÚ packagenameZredhat_rpm_archesr.Z delimiterr/r!r!r"Ú_split_package_archÚs  zDnfModule._split_package_archc Cs|dd…dkr|dd…}t d¡}zfd}| |¡\}}|rB|}| |¡}|r„| |¡ ¡\}}}} |r|| d¡d ¡sŠWdSnWdSWnBtyÎ} z*|jj d|t | ƒfdgd WYd} ~ n d} ~ 00|sØd }d |vr| d ¡} | d}d   | dd…¡}||| |d œ} | S)zœ Return a dictionary of information for a package name string or None if the package name doesn't contain at least all NVR elements éüÿÿÿNú.rpmz$(\S+)-(?:(\d*):)?(.*)-(~?\w+[\w.+]*)r=rz)Error attempting to parse package: %s, %sé)ÚmsgÚrcÚresultsÚ0ú:Ú)r.r0r1r2) ÚreÚcompiler@ÚmatchÚgroupsÚsplitÚisdigitrrÚ fail_jsonrÚjoin) rr?Z rpm_nevr_rer/ZnevrZrpm_nevr_matchr.r0r2r1ÚeZ epoch_namer:r!r!r"Ú_packagename_dictîs@    ý  üzDnfModule._packagename_dictcCsl|durd}nt|ƒ}t|ƒ}t|ƒ}|dur4d}nt|ƒ}t|ƒ}t|ƒ}tjj |||f|||f¡}|S)NrG)r7rZrpmZ labelCompare)rÚe1Zv1Zr1Úe2Zv2Zr2rEr!r!r"Ú _compare_evrszDnfModule._compare_evrcCsØt|jƒ}|tjd<tjd<|tjd<tjd<z8ddladdladdladdladdladdl ad}Wnt y€d}Yn0|rŠdSgd¢}t ƒs®t |d ƒ}|r®t |ƒ|jjd  tjtj d d ¡|¡gd dS)NÚLC_ALLÚ LC_MESSAGESÚLANGUAGEÚLANGrTF)z/usr/libexec/platform-pythonz/usr/bin/python3z/usr/bin/python2z/usr/bin/pythonrzÂCould not import the dnf python module using {0} ({1}). Please install `python3-dnf` or `python2-dnf` package or ensure you have specified the correct ansible_python_interpreter. (attempted {2})Ú rI©rDrF)r rÚosÚenvironrZdnf.cliZ dnf.constZdnf.exceptionsZ dnf.subjectZdnf.utilÚ ImportErrorr rrrPr(ÚsysÚ executabler2Úreplace)rÚlocaleZHAS_DNFZsystem_interpretersZ interpreterr!r!r"r2s4    ýûzDnfModule._ensure_dnfú/Tc CsT|j}|r2t |tj¡s,|jjd|gdn||_| ¡d|_| |_ | |_ d|_ ||_ ||_ |j |¡|jrt|jƒ}| |j¡||_|jr¼t|jƒ}|j|vr¼| |j¡||_|jdurÒ|j|jd<|j d¡durø|j d¡d|jd<|jrd|_|jrd|_|jr2d|_|jr2|j|_|j r@d|_ |j!|_"|j#|_#dS) zConfigure the dnf Base object.zcannot read configuration file)rDÚ conf_filerFrTNÚ releaseverzUUnable to detect release version (use "releasever" option to specify release version)rI)$Úconfr]ÚaccessÚR_OKrrPZconfig_file_pathÚreadZ debuglevelZgpgcheckZlocalpkg_gpgcheckZ assumeyesÚ sslverifyÚ installrootZ substitutionsZupdate_from_etcZexcludeÚlistÚextendZdisable_excludesÚappendrfÚgetÚwarnZ skip_brokenÚstrictrÚbestÚ download_onlyZ downloadonlyÚ download_dirÚdestdirZ cacheonlyÚ autoremoveZclean_requirements_on_removeZinstall_weak_deps) rrreÚdisable_gpg_checkrlrkrgZ _excludesZ_disable_excludesr!r!r"Ú_configure_base]sXþ        ÿ zDnfModule._configure_basecCs^| ¡|j}|D] }|r| |¡D] }| ¡q$q|D] }|r8| |¡D] }| ¡qJq8dS)z?Enable and disable repositories matching the provided patterns.N)Úread_all_reposÚreposZ get_matchingÚdisableÚenable)rrÚ disablerepoÚ enablerepor{Z repo_patternr3r!r!r"Ú_specify_repositoriesºs zDnfModule._specify_repositoriesc Cs(t ¡}| |||||¡z | ¡Wnty8Yn0z$| t|jƒt|jƒ¡|  ¡WntypYn0|  |||¡z |  ¡WntyžYn0zh|j rúz |  ¡WnDtj jyø}z(|jjd t|ƒ¡gddWYd}~n d}~00|jddWnFtj jyN}z(|jjd t|ƒ¡gddWYd}~n d}~00t|ddƒ} t| ƒr´i} |jr„|  dg¡ d ¡|jrž|  dg¡ d ¡| r$| d i| ¤Žnpg} |jrèd d i} |  |j ¡ ¡jfi| ¤Ž¡|jrd d i} |  |j ¡ ¡jfi| ¤Ž¡| r$| |_|S)z*Return a fully configured dnf Base object.z{0}rC©rDrFrENÚauto)Zload_system_repoÚadd_security_filtersÚtypesÚbugfixÚsecurityÚeqZadvisory_type__eq)r‡)rZBaseryZ setup_loggersrZ init_pluginsÚsetZdisable_pluginZ enable_pluginZpre_configure_pluginsr€Zconfigure_pluginsÚ update_cacheÚ exceptionsÚ RepoErrorrrPr(rZ fill_sackÚgetattrÚcallabler…Ú setdefaultror†ÚsackÚqueryÚupgradesÚfilterZ_update_security_filters) rrerxr~rrlrkrrRrƒÚfiltersÚkeyr!r!r"Ú_baseËsh        ý ý    zDnfModule._basecs”|dkr d}|dvr8‡fdd„tˆjj ¡|ƒƒDƒ}nH|dvrXdd„ˆjj ¡Dƒ}n(tj |¡  ˆjj¡}‡fdd„|Dƒ}ˆj j d |d d S) z'List package info based on the command.Zupdatesr‘)r6r‘r5csg|]}ˆ |¡‘qSr!©r;©Ú.0r9r#r!r"Ú sÿz(DnfModule.list_items..)r{Z repositoriescSsg|]}|jddœ‘qS)Zenabled)r8Ústate)Úid)r˜r3r!r!r"r™sÿcsg|]}ˆ |¡‘qSr!r–r—r#r!r"r™órIr\N) rŒrrrr{Z iter_enabledrÚsubjectÚSubjectÚget_best_queryrÚ exit_json)rZcommandrFZpackagesr!r#r"Ú list_itemss þ þzDnfModule.list_itemscCst|jj ¡ ¡}i}| |¡\}}|r.||d<| |¡}|rXt|dƒ|d<| |¡n||d<t|j fi|¤ŽƒS)Nr/r0r.) rrrr6r@rSÚintÚupdateÚboolr’)rÚpkgr6Z package_specr.r/Zpackage_detailsr!r!r"Ú _is_installeds  zDnfModule._is_installedc Csx| |¡}|sdS|jj ¡ ¡}|j|dd ¡}|rp|d}| |j|j |j |d|d|d¡}|dkSdSdS) NFr.)r.rr0r2r1rC) rSrrrr6r’ÚrunrVr0r2r1)rÚpkg_nameZ candidate_pkgr6Ú installed_pkgZevr_cmpr!r!r"Ú_is_newer_version_installed0s  þz%DnfModule._is_newer_version_installedFc CsÆ| |¡}| |¡}z|rh|jr–|rN|r6|j |¡qd|jj||jjjdqf|jj||jjjdq–n.|r€|r–|j |¡q–n|jj||jjjddddddœWStj j yò}z0dd  |¡d  |t |ƒf¡d gd œWYd }~Sd }~0tj jy>}z0dd   |¡d  |t |ƒf¡d gd œWYd }~Sd }~0tj jyÀ}zftd ƒt|ƒvr|ddddœWYd }~Sdd  |¡d  |t |ƒf¡d gd œWYd }~SWYd }~n d }~00d S)zMark the package for install.©rrFrIr)ÚfailedrDÚfailurerETr'ú rC)r¬rDr­rErFNz(Depsolve Error occurred for package {0}.úalready installed)r¬rDr­z'Unknown Error occurred for package {0}.)rªr¦Úallow_downgraderÚupgradeÚinstallrgrrrrŠÚ MarkingErrorr(rQrÚ DepsolveErrorÚErrorr)rÚpkg_specr±Zis_newer_version_installedZ is_installedrRr!r!r"Ú_mark_package_installFsP   ûûûzDnfModule._mark_package_installcCsN|j ¡|jj ¡ ¡}|j|d}| |j|d¡ ¡}|rJ|djSdS)N)Úfile)Zprovidesr) rrzrrr5r’Úunionr§r.)rÚfilepathr5Z files_filterr¶r!r!r"Ú _whatprovidesŒs   zDnfModule._whatprovidesc Csggggf\}}}}d}|jD]Ü}d|vrBt|j|ƒ}| |¡q| d¡rX| |¡q| d¡r~| |¡}|rú| |¡qq| d¡sd|vrð|s¢|j ¡d}|dd…  ¡}|j rä|j   |¡} | drØ| |¡qî| |¡qú| |¡q| |¡q||||fS) NFz://rBrdú@TrCr) ÚnamesrrroÚendswithÚ startswithr»rZ read_compsÚstriprÚ module_baseÚ _get_modules) rÚ pkg_specsZ grp_specsÚ module_specsÚ filenamesZalready_loaded_compsr.r¶Zgrp_env_mdl_candidateZmdlr!r!r"Ú_parse_spec_group_file—s4              z DnfModule._parse_spec_group_filec Cs–g}|D]ˆ}| |¡r†z,tt|ƒtƒr4|j |¡n |j |¡Wqty‚}z(|jj d  t |ƒ¡gddWYd}~qd}~00q|  |¡q|S)Nz4Error occurred attempting update_only operation: {0}rCr) r¦Ú isinstancerr rr±Zpackage_upgradeÚ ExceptionrrPr(rro)rÚpkgsÚ not_installedr¥rRr!r!r"Ú _update_onlyºs  ý zDnfModule._update_onlyc Cs^ttj d¡dƒdkr6tt|j t|ƒ¡ddƒ}nxg}z |D]}| |j  |¡¡q@WnRt y¬}z:t dƒt |ƒvr˜|j j d |t|ƒ¡gdd WYd}~n d}~00|jrÀ| |¡nš|D]”}zL| | |¡d ¡rü|jrú|jj||jjjd n|jj||jjjd WqÄtyV}z(|j j d  t|ƒ¡gdd WYd}~qÄd}~00qÄdS) Nr=réT)ÚreversezCan not load RPM filezAError occurred attempting remote rpm install of package: {0}. {1}rCrr4r«z3Error occurred attempting remote rpm operation: {0})r¢rÚ __version__rNrmÚsortedrZadd_remote_rpmsroZadd_remote_rpmÚIOErrorrrrPr(rÚ update_onlyrËrªr;r°Zpackage_installrgrrrÈ)rrÅrÉÚfilenamerRr¥r!r!r"Ú_install_remote_rpmsÎs6ý  ýzDnfModule._install_remote_rpmscCsT|jrP| ¡}|j |¡\}}|jj |j¡}|rP|jrL|j|vrFdSdSndSdS)NTF) rrÀrÁrÂrZ_moduleContainerZgetEnabledStreamr.Ústream)rZ module_specZ module_listZnsvZenabled_streamsr!r!r"Ú_is_module_installedîs zDnfModule._is_module_installedc! CsÌ ddgddœ}dggddœ}|js4|jr4g|_d|_|jdgkr |jd kr z|j ¡WnBtjjyš}z&d |d <|jj fi|¤ŽWYd}~n d}~00 n^|  ¡\}}}}d d „|Dƒ}dd „|Dƒ}g}g} dd„|DƒD]^} |jj   | ¡} | r|  | j¡qâ|jj  | ¡} | r*|   | j¡qâ|jj d | ¡gdqâ|jdvr†| |¡|D]} |d  d | ¡¡q\|r|jr|D]Ž}z@| |¡s°|d  d |¡¡|j |g¡|j |g¡WnFtjjy}z(|d  d |t|ƒf¡¡WYd}~n d}~00qŠ|D]à} zJ|j | tjj¡}|dkrV|d  d | ¡¡n|d  d | ¡¡WnŽtjjy¶}z,d | ¡|d <|jj fi|¤ŽWYd}~nNd}~0tjjyú}z(|d  d | t|ƒf¡¡WYd}~n d}~00q| D]¬} z|j | tjj¡WnŽtjjyh}z,d | ¡|d <|jj fi|¤ŽWYd}~nNd}~0tjjy¬}z(|d  d | t|ƒf¡¡WYd}~n d}~00q|rÚ|jsÚ|jj d |d¡gd|jr |  |¡}|D]}|d  d|¡qðnv|D]p}| !|¡}|drb|d rF|d |d 7<|d  | "||d¡¡n|d r|d  |d ¡qnx|jd kr¼| |¡|D]} |d  d | ¡¡q |rP|jrP|D]€}z2| |¡rô|d  d  |¡¡|j #|g¡WnFtjjyJ}z(|d  d |t|ƒf¡¡WYd}~n d}~00qÎ|D]Þ} zz$|j $| ¡|d  d! | ¡¡Wnftjj%yä|jsà|j | tjj¡}|dkrÌ|d  d | ¡¡n|d  d | ¡¡Yn0WnFtjjy.}z(|d  d | t|ƒf¡¡WYd}~n d}~00qT| D]Ä} z@z|j &| ¡Wn*tjj%yx|j | tjj¡Yn0Wn|tjjy´}zd | ¡|d <WYd}~nNd}~0tjjyø}z(|d  d | t|ƒf¡¡WYd}~n d}~00q8|jr0|  |¡}|D]}|d  d|¡qnˆ|D]‚}|j' |jj(_)|j!|d"d#}|dr˜|d r||d |d 7<|d  | "||d¡¡n|d r4|d  |d ¡q4nB|rÒ|jj d$gd|r‚|jr‚|D]œ}zN| |¡r |d  d% |¡¡|j *|g¡|j +|g¡|j ,|g¡WnFtjjy|}z(|d  d |t|ƒf¡¡WYd}~n d}~00qä|D]B} z|j -| ¡Wn*tjj%y²Ynt.yÄYn0q†| D]0} z|j /| ¡Wntjj%yúYn0qÎ|jj0 1¡ 2¡}|D]Ð}d|v r¦z|j *|¡Wnntjj3 y }zP| 4|t|ƒ¡\}}| r~|d  d& |t|ƒ¡¡n|d  |¡WYd}~n d}~00 qtj5 6|¡j7|jj0d' 2¡ 8¡}|D]}|j *t9|ƒ¡ qÊ qd"|_:|j rþ|j ¡zæ|jj;|j:d( sV|d r8d)|d <|jj fi|¤Žd*|d <|jjj?D]}|d  d. ||¡¡ qz|jj>j@D]}|d  d/ |¡¡ q¢|d râd)|d <|jj fi|¤Ž|jjA rd0|d <|jjj?¡WnDtjjJ y¢}z&|jj d1 tK|ƒ¡gdWYd}~n d}~00|jL sP|jj>j?D]˜}d}|j M|¡\}}|dk rÞ q¶nP|dk r*z|j N|¡Wn.tjj y&}zd"}WYd}~n d}~00nd"}| r¶d2 ||¡}|j  |¡ q¶|j= rl|jj.cSsg|] }| ¡‘qSr!rÚ)r˜Úfr!r!r"r™!rœcss|]}| ¡VqdS)NrÚ)r˜Úgr!r!r"Ú $rœz#DnfModule.ensure..zNo group {0} available.r\)r6ZpresentrFz Installed {0}zModule {0} installed.rØr®zGroup {0} already installed.zGroup {0} installed.z8Depsolve Error occurred attempting to install group: {0}z>Depsolve Error occurred attempting to install environment: {0}z@Packages providing %s not installed due to update_only specifiedr¬r­zModule {0} upgraded.zGroup {0} upgraded.T)r±z3Cannot remove paths -- please specify package name.zModule {0} removed.z {0} - {1})r)Z allow_erasingz0Failed to install some of the specified packagesz Nothing to dor×Z DownloadedZ Installedz{0}: {1}z Removed: {0}z@Check mode: No changes made, but would have if not in check modez Failed to download packages: {0}z-Failed to validate GPG signature for {0}: {1}zDepsolve Error occurred: {0}r¯zPackage already installed: {0}zUnknown Error occurred: {0})Tr½rwršrZ upgrade_allrrŠr´rrPrÆÚcompsZgroup_by_patternror›Zenvironment_by_patternr(rÓrrÕrÁr²r}Z MarkingErrorsrQrZ group_installÚconstZGROUP_PACKAGE_TYPESrµZenvironment_installrÑrËr·r,r±Z group_upgradeZ CompsErrorZenvironment_upgraderrgrsÚremover|ÚresetZ group_removerZenvironment_removerrr6r³r-rržrŸr§r7rÚresolver rtÚ transactionZ install_setZ remove_setZ check_moderurvÚutilZ ensure_dirr{ÚallZpkgdirZdownload_packagesZ DownloadErrorrrxZ_sig_check_pkgZ_get_key_for_packageZdo_transactionÚhistoryÚoldZ return_codeÚoutput)!rZresponseZfailure_responserRrÃZ group_specsrÄrÅrMZ environmentsZ group_specÚgroupZ environmentrÒrZgroup_pkg_count_installedrÊr*r¶Zinstall_resultr6Z is_failureZhandled_remove_errorr©r¥Zinstall_actionr9ZfailZgpgresZgpgerrrDÚtidrär!r!r"Úensureÿsêü ü ,þ   6 &6&6 þ        6  6"6    þ 6   $ ÿ      þ      &zDnfModule.ensurecCsV|jr.ttjƒtdƒkr.|jjdtjgd|jr\ttjƒtdƒkr\|jjdtjgd|jr¤|js¤|j s¤|  |j |j |j |j|j|j¡|_|jjddgdd |jd ur´d |_|j rê|  |j |j |j |j|j|j¡|_| |j ¡nh|jstj ¡s|jjd gd|  |j |j |j |j|j|j¡|_|jrJtjj |j¡|_| ¡d S) zThe main function.z2.0.1z9Autoremove requires dnf>=2.0.1. Current dnf version is %sr\z2.6.2z;download_dir requires dnf>=2.6.2. Current dnf version is %sz Cache updatedFrrÖNr6z/This command has to be run under the root user.)rwr rrÎrrPrur‰r½rmr•rerxr~rrlrkrr ršr¡rtråZ am_i_rootrrÁZ ModuleBaserìr#r!r!r"r§\sVþþ  þü   þþ  þz DnfModule.run)rdT)F)Ú__name__Ú __module__Ú __qualname__Ú__doc__rr$r,r-r;r@rSrVrryr€r•r¡r¦rªr·r»rÆrËrÓrÕrìr§Ú __classcell__r!r!rr"rˆs4  1+ ]= F # _rc Cs”tdddtdd<tdddtdd<tfit¤Ž}t|ƒ}z | ¡WnDtjjyŽ}z(|jd  t |ƒ¡dgdd WYd}~n d}~00dS) NFr¤)ÚdefaultÚtypeZ argument_specrrz#Failed to synchronize repodata: {0}rC)rDrErFr×) Údictrr rr§rrŠr‹rPr(r)rZmodule_implementationÚder!r!r"Úmainšsÿ  üröÚ__main__)$Z __future__rrrróZ __metaclass__Z DOCUMENTATIONZEXAMPLESr]rJr`Zansible.module_utils._textrrZansible.module_utils.urlsrZansible.module_utils.sixrr Z#ansible.module_utils.compat.versionr Zansible.module_utils.basicr Z"ansible.module_utils.common.localer Z#ansible.module_utils.common.respawnr rrZansible.module_utils.yumdnfrrrrrörír!r!r!r"Ú s:X    !