o nnh @s^ddlmZdZdZdZddlZeddeddlZddl Z ddl Z ddl Z ddl Z ddlZddlZddlZddlZddlZddlmZdd lmZdd lmZdd lmZmZmZdd lmZmZdd l m!Z!ddl"m#Z#dZ$dZ%dZ&dZ'dZ(dZ)dZ*e+dddZ,dZ-zddl.Z.ddl/Z.ddl0Z0dZ-Wn e1ydZ.Z0YnwGddde2Z3ddZ4dd Z5d!d"Z6d#d$Z7d%d&Z8d'd(Z9d)d*Z:d+d,Z;dddde8e$ddddddddf d-d.Zdde8e$ddfd4d5Z?ddde8e$fd6d7Z@d8d9ZAd:ddde8e$ddddf d;d<ZBd=d>ZCd?d@ZDdAdBZEdCdDZFeGdEkr-eFdSdS)G) annotationsa9& --- module: apt short_description: Manages apt-packages description: - Manages I(apt) packages (such as for Debian/Ubuntu). version_added: "0.0.2" options: name: description: - A list of package names, like V(foo), or package specifier with version, like V(foo=1.0) or V(foo>=1.0). Name wildcards (fnmatch) like V(apt*) and version wildcards like V(foo=1.0*) are also supported. aliases: [ package, pkg ] type: list elements: str state: description: - Indicates the desired package state. V(latest) ensures that the latest version is installed. V(build-dep) ensures the package build dependencies are installed. V(fixed) attempt to correct a system with broken dependencies in place. type: str default: present choices: [ absent, build-dep, latest, present, fixed ] update_cache: description: - Run the equivalent of C(apt-get update) before the operation. Can be run as part of the package installation or as a separate step. - Default is not to update the cache. aliases: [ update-cache ] type: bool update_cache_retries: description: - Amount of retries if the cache update fails. Also see O(update_cache_retry_max_delay). type: int default: 5 version_added: '2.10' update_cache_retry_max_delay: description: - Use an exponential backoff delay for each retry (see O(update_cache_retries)) up to this max delay in seconds. type: int default: 12 version_added: '2.10' cache_valid_time: description: - Update the apt cache if it is older than the O(cache_valid_time). This option is set in seconds. - As of Ansible 2.4, if explicitly set, this sets O(update_cache=yes). type: int default: 0 purge: description: - Will force purging of configuration files if O(state=absent) or O(autoremove=yes). type: bool default: 'no' default_release: description: - Corresponds to the C(-t) option for I(apt) and sets pin priorities aliases: [ default-release ] type: str install_recommends: description: - Corresponds to the C(--no-install-recommends) option for I(apt). V(true) installs recommended packages. V(false) does not install recommended packages. By default, Ansible will use the same defaults as the operating system. Suggested packages are never installed. aliases: [ install-recommends ] type: bool force: description: - 'Corresponds to the C(--force-yes) to I(apt-get) and implies O(allow_unauthenticated=yes) and O(allow_downgrade=yes)' - "This option will disable checking both the packages' signatures and the certificates of the web servers they are downloaded from." - 'This option *is not* the equivalent of passing the C(-f) flag to I(apt-get) on the command line' - '**This is a destructive operation with the potential to destroy your system, and it should almost never be used.** Please also see C(man apt-get) for more information.' type: bool default: 'no' clean: description: - Run the equivalent of C(apt-get clean) to clear out the local repository of retrieved package files. It removes everything but the lock file from /var/cache/apt/archives/ and /var/cache/apt/archives/partial/. - Can be run as part of the package installation (clean runs before install) or as a separate step. type: bool default: 'no' version_added: "2.13" allow_unauthenticated: description: - Ignore if packages cannot be authenticated. This is useful for bootstrapping environments that manage their own apt-key setup. - 'O(allow_unauthenticated) is only supported with O(state): V(install)/V(present)' aliases: [ allow-unauthenticated ] type: bool default: 'no' version_added: "2.1" allow_downgrade: description: - Corresponds to the C(--allow-downgrades) option for I(apt). - This option enables the named package and version to replace an already installed higher version of that package. - Note that setting O(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). - 'O(allow_downgrade) is only supported by C(apt) and will be ignored if C(aptitude) is detected or specified.' aliases: [ allow-downgrade, allow_downgrades, allow-downgrades ] type: bool default: 'no' version_added: "2.12" allow_change_held_packages: description: - Allows changing the version of a package which is on the apt hold list type: bool default: 'no' version_added: '2.13' upgrade: description: - If yes or safe, performs an aptitude safe-upgrade. - If full, performs an aptitude full-upgrade. - If dist, performs an apt-get dist-upgrade. - 'Note: This does not upgrade a specific package, use state=latest for that.' - 'Note: Since 2.4, apt-get is used as a fall-back if aptitude is not present.' version_added: "1.1" choices: [ dist, full, 'no', safe, 'yes' ] default: 'no' type: str dpkg_options: description: - Add dpkg options to apt command. Defaults to '-o "Dpkg::Options::=--force-confdef" -o "Dpkg::Options::=--force-confold"' - Options should be supplied as comma separated list default: force-confdef,force-confold type: str deb: description: - Path to a .deb package on the remote machine. - If :// in the path, ansible will attempt to download deb before installing. (Version added 2.1) - Requires the C(xz-utils) package to extract the control file of the deb package to install. type: path required: false version_added: "1.6" autoremove: description: - If V(true), remove unused dependency packages for all module states except V(build-dep). It can also be used as the only option. - Previous to version 2.4, autoclean was also an alias for autoremove, now it is its own separate command. See documentation for further information. type: bool default: 'no' version_added: "2.1" autoclean: description: - If V(true), cleans the local repository of retrieved package files that can no longer be downloaded. type: bool default: 'no' version_added: "2.4" policy_rc_d: description: - Force the exit code of /usr/sbin/policy-rc.d. - For example, if I(policy_rc_d=101) the installed package will not trigger a service start. - If /usr/sbin/policy-rc.d already exists, it is backed up and restored after the package installation. - If V(null), the /usr/sbin/policy-rc.d isn't created/changed. type: int default: null version_added: "2.8" only_upgrade: description: - Only upgrade a package if it is already installed. type: bool default: 'no' version_added: "2.1" fail_on_autoremove: description: - 'Corresponds to the C(--no-remove) option for C(apt).' - 'If V(true), it is ensured that no packages will be removed or the task will fail.' - 'O(fail_on_autoremove) is only supported with O(state) except V(absent).' - 'O(fail_on_autoremove) is only supported by C(apt) and will be ignored if C(aptitude) is detected or specified.' type: bool default: 'no' version_added: "2.11" force_apt_get: description: - Force usage of apt-get instead of aptitude type: bool default: 'no' version_added: "2.4" lock_timeout: description: - How many seconds will this action wait to acquire a lock on the apt db. - Sometimes there is a transitory lock and this will retry at least until timeout is hit. type: int default: 60 version_added: "2.12" requirements: - python-apt (python 2) - python3-apt (python 3) - aptitude (before 2.4) author: "Matthew Williams (@mgwilliams)" extends_documentation_fragment: action_common_attributes attributes: check_mode: support: full diff_mode: support: full platform: platforms: debian notes: - Three of the upgrade modes (V(full), V(safe) and its alias V(true)) required C(aptitude) up to 2.3, since 2.4 C(apt-get) is used as a fall-back. - In most cases, packages installed with apt will start newly installed services by default. Most distributions have mechanisms to avoid this. For example when installing Postgresql-9.5 in Debian 9, creating an executable shell script (/usr/sbin/policy-rc.d) that throws a return code of 101 will stop Postgresql 9.5 starting up after install. Remove the file or its execute permission afterward. - The apt-get commandline supports implicit regex matches here but we do not because it can let typos through easier (If you typo C(foo) as C(fo) apt-get would install packages that have "fo" in their name with a warning and a prompt for the user. Since we don't have warnings and prompts before installing, we disallow this.Use an explicit fnmatch pattern if you want wildcarding) - When used with a C(loop:) each package will be processed individually, it is much more efficient to pass the list directly to the O(name) option. - When O(default_release) is used, an implicit priority of 990 is used. This is the same behavior as C(apt-get -t). - When an exact version is specified, an implicit priority of 1001 is used. - If the interpreter can't import ``python-apt``/``python3-apt`` the module will check for it in system-owned interpreters as well. If the dependency can't be found, the module will attempt to install it. If the dependency is found or installed, the module will be respawned under the correct interpreter. a - name: Install apache httpd (state=present is optional) ansible.builtin.apt: name: apache2 state: present - name: Update repositories cache and install "foo" package ansible.builtin.apt: name: foo update_cache: yes - name: Remove "foo" package ansible.builtin.apt: name: foo state: absent - name: Install the package "foo" ansible.builtin.apt: name: foo - name: Install a list of packages ansible.builtin.apt: pkg: - foo - foo-tools - name: Install the version '1.00' of package "foo" ansible.builtin.apt: name: foo=1.00 - name: Update the repository cache and update package "nginx" to latest version using default release squeeze-backport ansible.builtin.apt: name: nginx state: latest default_release: squeeze-backports update_cache: yes - name: Install the version '1.18.0' of package "nginx" and allow potential downgrades ansible.builtin.apt: name: nginx=1.18.0 state: present allow_downgrade: yes - name: Install zfsutils-linux with ensuring conflicted packages (e.g. zfs-fuse) will not be removed. ansible.builtin.apt: name: zfsutils-linux state: latest fail_on_autoremove: yes - name: Install latest version of "openjdk-6-jdk" ignoring "install-recommends" ansible.builtin.apt: name: openjdk-6-jdk state: latest install_recommends: no - name: Update all packages to their latest version ansible.builtin.apt: name: "*" state: latest - name: Upgrade the OS (apt-get dist-upgrade) ansible.builtin.apt: upgrade: dist - name: Run the equivalent of "apt-get update" as a separate step ansible.builtin.apt: update_cache: yes - name: Only run "update_cache=yes" if the last one is more than 3600 seconds ago ansible.builtin.apt: update_cache: yes cache_valid_time: 3600 - name: Pass options to dpkg on run ansible.builtin.apt: upgrade: dist update_cache: yes dpkg_options: 'force-confold,force-confdef' - name: Install a .deb package ansible.builtin.apt: deb: /tmp/mypackage.deb - name: Install the build dependencies for package "foo" ansible.builtin.apt: pkg: foo state: build-dep - name: Install a .deb package from the internet ansible.builtin.apt: deb: https://example.com/python-ppq_0.1-1_all.deb - name: Remove useless packages from the cache ansible.builtin.apt: autoclean: yes - name: Remove dependencies that are no longer required ansible.builtin.apt: autoremove: yes - name: Remove dependencies that are no longer required and purge their configuration files ansible.builtin.apt: autoremove: yes purge: true - name: Run the equivalent of "apt-get clean" as a separate step ansible.builtin.apt: clean: yes aP cache_updated: description: if the cache was updated or not returned: success, in some cases type: bool sample: True cache_update_time: description: time of the last cache update (0 if unknown) returned: success, in some cases type: int sample: 1425828348000 stdout: description: output from apt returned: success, when needed type: str sample: |- Reading package lists... Building dependency tree... Reading state information... The following extra packages will be installed: apache2-bin ... stderr: description: error output from apt returned: success, when needed type: str sample: "AH00558: apache2: Could not reliably determine the server's fully qualified domain name, using 127.0.1.1. Set the 'ServerName' directive globally to ..." Nignorezapt API not stable yet) AnsibleModule)S_IRWXU_RXG_RXO)get_best_parsable_locale) has_respawnedprobe_interpreters_for_modulerespawn_module) to_nativeto_text) string_types) fetch_filezforce-confdef,force-confoldz 0 upgraded, 0 newly installedz' 0 packages upgraded, 0 newly installedz/var/lib/apt/listsz*/var/lib/apt/periodic/update-success-stampzInvalid operationz8Usage: apt-mark [options] {markauto|unmarkauto} packagesz&The following packages will be REMOVEDzDel ) autoremove autocleanFTc@s(eZdZdZddZddZddZdS) PolicyRcDa This class is a context manager for the /usr/sbin/policy-rc.d file. It allow the user to prevent dpkg to start the corresponding service when installing a package. https://people.debian.org/~hmh/invokerc.d-policyrc.d-specification.txt cCsB||_|jjddur dStjdrtjdd|_dSd|_dS)N policy_rc_d/usr/sbin/policy-rc.dansible)prefix)mparamsospathexiststempfilemkdtemp backup_dir)selfmoduler>/usr/local/lib/python3.10/dist-packages/ansible/modules/apt.py__init__s   zPolicyRcD.__init__cCs|jjddur dS|jr*z td|jWnty)|jjd|jdYnwz)tdd}|d|jjdWdn1sFwYt dt WdStyd|jjddYdSw) ud This method will be called when we enter the context, before we call `apt-get …` rNrz(Fail to move /usr/sbin/policy-rc.d to %smsgwz#!/bin/sh exit %d z/Failed to create or chmod /usr/sbin/policy-rc.d) rrrshutilmove Exception fail_jsonopenwriterchmodr)rrrrr __enter__s    zPolicyRcD.__enter__c Cs|jjddur dS|jr?=)r)resplitlen)pkgspecpartsrrr package_splits r>cCs.zt||WStyt||YSw)N)apt_pkgversion_compareAttributeErrorVersionCompare)version other_versionrrr package_version_compares  rEcCst|}|tjd|tjd|r!|d||d|dkr-|d||d||}||}|s:dS|dkrGt|j |sGdS|j S)NzDir::Etc::preferenceszDir::Etc::preferencespartsReleasei=Versioni) r?Policy read_pinfileconfig find_file read_pindir create_pinget_candidate_verfnmatchver_str)pkgname version_cmprCreleasecachepolicypkgpkgverrrr package_best_matchs  rYc Cs8z ||}|j|}Wn[tyf|dkraz?||} | rL||rHt| dkrH| d} t|| j||||dd\} } } }| rH| | | |fWYSWYdS|jd|dWnty`YYdSwYdSYnwz t|j dk}Wnt y{d }Yn tyd }Ynwz|j t j k}Wntyz|j}Wn ty|j}YnwYnwt|||||j}d }d } |rz|jj} Wn ty|j} Ynw|d krt| |}|r| |krt||r|} n0|d krt | |dk}|r| |krt ||dkr|} nd }|r| |kr|} n|} ||| |fS)aR :return: A tuple of (installed, installed_version, version_installable, has_files). *installed* indicates whether the package (regardless of version) is installed. *installed_version* indicates whether the installed package matches the provided version criteria. *version_installable* provides the latest matching version that can be installed. In the case of virtual packages where we can't determine an applicable match, True is returned. *has_files* indicates whether the package has files on the filesystem (even if not installed, meaning a purge is required). installr8rstate)FFTFz%No package matching '%s' is availabler")FFNFTFNrGz>=)_cacheKeyErrorget_providing_packagesis_virtual_packager;package_statusnamer(rAinstalled_filesUnicodeDecodeError current_stater?CURSTATE_INSTALLED is_installed isInstalledrY installedrCinstalledVersionrPr@)rrRrSrCdefault_releaserUr\rWll_pkgprovided_packagespackageriinstalled_versionversion_installable has_filespackage_is_installed version_bestversion_is_installedrrr ra s                " racCs,|d}d}|D]}d||f}q |S)N,z%s -o "Dpkg::Options::=--%s")r:strip)dpkg_options_compressed options_list dpkg_options dpkg_optionrrr expand_dpkg_optionsas r|c Csg}|rv|D]o}t|ts|jdt|dt|\}}}td|rpd|vr@z|} Wn)ty?dd|D} }Ynwz| } WntyVdd|D} } Ynwt | |} | sj|jdt |dq| | q| |q|S) Nz9Invalid type for package name, expected string but got %sr"z*?[]!:cSsg|] }d|jvr|jqS)r}rb.0rWrrr z1expand_pkgspec_from_fnmatches..cSsg|]}|jqSrr~rrrr rsz%No package(s) matching '%s' available) isinstancer r(r0r> frozenset intersection NameErrorrPfilterr extendappend) rr<rU new_pkgspecpkgspec_patternpkgname_patternrSrC_non_multiarchpkg_name_cache_all_pkg_namesmatchesrrr expand_pkgspec_from_fnmatchesjs0       rc Cst|}z|d}Wnty)z|d}Wn ty&d}YnwYnwz tddt|D}Wn tyDt|}Ynw|d7}|d7}dd|||iS) NzResolving dependencies...zReading state information...css$|] \}}td|r|VqdS)z[0-9]+ (packages )?upgradedN)r9match)riitemrrr s"zparse_diff..r8prepared ) r splitlinesindex ValueErrornext enumerate StopIterationr;r-)outputdiff diff_startdiff_endrrr parse_diffs&     rcCs|sdS|d}|dur|ddSd|d|f}||\}}}t|vs-t|vr>d|d|f}||\}}}|dkrQ|jd||f|||ddSdS) Nzapt-markzMCould not find apt-mark binary, not marking package(s) as manually installed.z %s manual %s z%s unmarkauto %sr'%s' failed: %sr#stdoutstderrrc) get_bin_pathwarnr- run_commandAPT_MARK_INVALID_OPAPT_MARK_INVALID_OP_DEB6r()rpackagesapt_mark_cmd_pathcmdrouterrrrr mark_installed_manuallys  rc% Csg}d}t|||}g}|D]|}|r|d|qt|\}}}||t||||||dd\}}}}|s:| r:q|sM|sMd}td|d}||fS|ry|sS| rW|sW|sy|dure|d ||fq|rq|d ||fq|d|q|r|r|d kr|d ||fqd |}|rU|rd }nd}|jrd }nd}| rd} nd} | rd} nd} | rd} nd} | rd} nd} |rdt|| | || ||f}n dt|| | || | ||f }|r|d|f7}|dur|d7}n|dur|d7}| r|d7}|r|d7}|r|d7}t|| |\} }!}"Wdn 1s wY|j r.t |!}#ni}#d}d}$|r;t |!v}$t|$|!|"|#d}| rTd}td||"f|!|"| d}nd}tdd}|sh|jsht ||||fS)Nrv'%s'rZr[Fz*no available installation candidate for %sr"Tz'%s=%s'rGr --force-yes --simulate --auto-remove --no-removez--only-upgradez --fix-brokenz$%s -y %s %s %s %s %s %s build-dep %sz%%s -y %s %s %s %s %s %s %s install %s -t '%s'z -o APT::Install-Recommends=noz -o APT::Install-Recommends=yesz --allow-unauthenticatedz --allow-downgradesz --allow-change-held-packageschangedrrrrrr)rrr>radictr- check_mode APT_GET_CMDrr_diffr APT_GET_ZEROr)%rr<rUupgraderkinstall_recommendsforcerz build_depfixedrfail_on_autoremove only_upgradeallow_unauthenticatedallow_downgradeallow_change_held_packagespkg_listr package_namesrnrbrSrCrirorprqstatusdata force_yes check_argrrrrrrrrr rZs         rZrHcCsV|dd}|d||f}||\}}}|dkr$|jd|||dt|dS)NdpkgTz --field %s %sr %s failedr#rrr)rrr(r rw)rdeb_filefieldcmd_dpkgrrrrrrr get_field_of_debEs rc ! Csd} g} g} |dD]} zotjj| td}t|| d}t|| d}ttdr>tt dkr>t|| d}d ||f}n|}zt|}|j j }t ||d krUWWq Wn t y_Ynw|su|smd |jvrn|rnn|j|jd | |jWnt y}z|jd t|d WYd}~nd}~ww|rt|| d}| dd|D| | q i}| rt|| ||||||t| d \}}|s|jd"i||dd} | rpddd| dD}|jr|d7}|r|d7}d|d| f}t|||\}}}Wdn 1swYd|vr'|d|}n|}d|vrB|d}d|vrA|dd|7<nt|}d|vrR|d|} n|} |d krd|jd|| |ddS|jd||| d dS|j| |dd!|dd!|dd!ddS)#NFru)rUPackagerHget_architecturesr8 Architecturez%s:%srz later versionr"zUnable to install package: %s RecommendscSsg|]}|qSrrw)rpkg_namerrr r|zinstall_deb..) rr<rUrrrrrrzrrcSsg|]}d|qS)z--%sr)rxrrr rrz --simulatez --force-allz dpkg %s -i %srrrz rTrrrrvr)r:aptdebfile DebPackageCacherhasattrr?r;rrirCrEr'check_failure_stringr(r missing_depsr rrZr|getr-rrrr exit_json)!rdebsrUrrrrrrrzrdeps_to_installpkgs_to_installrrWr pkg_versionpkg_archpkg_key installed_pkgroepkg_recommendsretvalssuccessoptionsrrrrrrrrrr install_debNs                .rc Cs^g}t|||}|D]%} t| \} } } t|| | | d|dd\} }}}|s(|r/|r/|d| q d|}|s?|jdddS|rDd}nd}|rKd }nd}|rRd }nd}|jrZd }nd}|rad }nd}d t|||||||f}t|| |\}}}Wdn1swY|j rt |}ni}|r|j d||f|||d|jd|||ddS)Nr/r[rrFrrrv--purgerrz--allow-change-held-packagesz$%s -q -y %s %s %s %s %s %s remove %sz'apt-get remove %s' failed: %srTr) rr>rarr-rrrrrrrr()rr<rUpurgerrzrrrrnrbrSrCriro upgradablerqrrrrrrrrrrr r/sZ     r/c Cs|tddgvrtd||rd}nd}|rd}nd}|jr"d}nd}dt|||||f}t|||\}} } Wdn1sEwY|jrRt| } ni} |rc|jd || f| | |d t || v} |j | | | | d dS) Nrrz>Expected "autoremove" or "autoclean" cleanup operation, got %srrvrrz%s -y %s %s %s %s %sz'apt-get %s' failed: %srr) rAssertionErrorrrrrrrr(CLEAN_OP_CHANGED_STRr) rrr operationrzrrrrrrrrrrr cleanups,    rcCs\|ddg\}}}|jrt|ni}|r|jd||d|r)|jd|||d|||fS)Napt-getcleanzapt-get clean failedr#rrzapt-get clean failed: %s)rrrr()rclean_rc clean_out clean_err clean_diffrrr aptcleans ryesc  Cs|rd}nd}|jr d} nd} d} d} |dks|dkr$|r$t} d|} n|dkr/|s/t} d} n|r8t} d|} nt} d } d } |rJ| tkrGd }nd }nd}|r]| tkrUd }n |dd}nd}|rcdnd}| rv| tkrnd} n |dd} nd} | dur|rt} n|jdd|j| dd}d|||||| | | f}|r|d|f7}t||j|| d\}}}Wdn1swY|jrt |}ni}|r|jd| | |f||d| tkrt |vs| tkrt |vr|j d|||d|j d||||ddS)Nrrvrdistfullzdist-upgrade %sz full-upgradezupgrade --with-new-pkgs %sz safe-upgradezR(^Do you want to ignore this warning and proceed anyway\?|^\*\*\*.*\[default=.*\])rz--assume-yes --allow-untrustedrzUAPTITUDE does not support '--no-remove', ignoring the 'fail_on_autoremove' parameter.z--allow-unauthenticatedz--allow-downgradeszYAPTITUDE does not support '--allow-downgrades', ignoring the 'allow_downgrade' parameter.zfUnable to find APTITUDE in path. Please make sure to have APTITUDE in path or use 'force_apt_get=True'r"T)requiredz%s -y %s %s %s %s %s %s %sr) prompt_regexz'%s %s' failed: %srF)rr#rrrr#rrr) rr APTITUDE_CMDrr(rrrrrr APTITUDE_ZEROr)rmoderrk use_apt_getrzrrrrrapt_cmdr upgrade_commandr apt_cmd_pathrrrrrrrr r"s           rcCs<d}tjtrttj}|Stjtrttj}|S)zReturn mtime of a valid apt cache file. Stat the apt cache file and if no cache file is found return 0 :returns: ``int`` r)rrrAPT_UPDATE_SUCCESS_STAMP_PATHstatst_mtimeAPT_LISTS_PATH) cache_timerrr get_cache_mtimes   rcCs,t}tj|}tt|}||fS)zReturn the mtime time stamp and the updated cache time. Always retrieve the mtime of the apt cache or set the `cache_mtime` variable to 0 :returns: ``tuple`` )rdatetime fromtimestampinttimemktime timetuple) cache_mtime mtimestampupdated_cache_timerrr get_updated_cache_times r$c Csd}zt}W|Styh}zSdt|vrNd}|dkr6|gd\}}}|d7}|dkr2n|dks|dkrI|jdt|||f|dt}n|jt|d WYd}~|SWYd}~|Sd}~ww) z8Attempt to get the cache object and update till it worksNz/var/lib/apt/lists/r)rupdate-qr8zAUpdating the cache to correct corrupt package lists failed: %s %s)r#rr")rr SystemErrorr lowerrr()rrUrretriesrsoserrr get_caches,   r-c0Csttd]idtddgdddtddgd d td d d dtd dd dtd dd dtddd dtddddgddtdddtddgd dtddgd d tddd d!tdgd"d#d$d%tdtd d&tddd d'tddd d(tddd d)td dd d*tddd d+tddd d,tddd d-tddd.gd/d0tddgd1d/d2tddd d3td d4d gd5ggd6gd7d8}t|}ttj|td9d:||||d;}||_|d}tr |jd?|tjd@dAdBg}t|dC}|rt||jr)|jdD|d@|j ddur:|dE|n|dF||jt dGgd7dHt dI|dJdK|g} |dur_| dLdMgn |d7urk| dLdNg|j| d7dHt|dC}|rt|n |jd?|tjd@|d,d7urt|\} } } |ds|d!d#kr|ds|jd7| | | | dO|d!d#krd|d!<|d+} | st sd7} d}d}|d-}|d0}|d2}|d&}|d(}|d'}t|d3} t|}z|drz |dtjdP<Wnt y|dtj!dP<Ynw|j"ddQt#\}}d}|ds,|drt$j$%}t$j&|ddR}|||ksdS}|j d }|j d}t'(ddTdU}t)|D]<}z |jse|*Wn<t+j,j-y} z t.| }WYd} ~ nd} ~ wwdV||}!|!|kr||}!t/|!qZ|jdW|r|ndXd@|j"ddQt#\}}"|js||"krd7}|"}|ds|d!s|ds|j|||dY|d }#|d!rt0||d!|#|d| ||||| |dr!|ddkr|jdZd@d[|dvrt1||d|d<t2||d||||||#||d%d\ |dp'd]}$d^d_|$D}%d`|$v}&|ddak}'|'rW|&rW|%rH|jdbd@t0|dc|#|d| ||||| |%rp|%D]}(|(3dddekrn|jdf|(d@q\|%s|rt4||d|#d'|dg|rt4||d|#d&|dg|ddhvrd})d}*d}+|ddakrd7})|ddikrd7}*|ddjkrd7}+t5||%||)|d||#||*|+|||d*|||dk\},}-||-dl<||-dm<|,r|jd]i|-n|jd]i|-n|ddnkrt6||%||d|#|||doWnGt+j,j7y/}.zt|krWYd}.~.q|jdp|.d@WYd}.~.n!d}.~.wt+j,j-yK}/z|jdq|/d@WYd}/~/nd}/~/ww|jdrd@q)sNr\strpresent)absent build-deprlatestr/)r0defaultchoices update_cacheboolz update-cache)r0aliasesupdate_cache_retriesr)r0r3update_cache_retry_max_delay cache_valid_timerrFrnlistrWrb)r0elementsr7debr)r0rkzdefault-releaserzinstall-recommendsrr)r r nosaferr@)r0r4r3rzrrrrr force_apt_getrrzallow-unauthenticated)r0r3r7r)zallow-downgradeallow_downgradeszallow-downgradesr lock_timeout<)r?rnr)rr?rnr5rT) argument_specmutually_exclusiverequired_one_ofsupports_check_modenoninteractivecritical)DEBIAN_FRONTENDDEBIAN_PRIORITYLANGLC_ALL LC_MESSAGESLC_CTYPEaptituderz python3-aptz+{0} must be installed and visible from {1}.r"z/usr/bin/python3z/usr/bin/pythonrzX%s must be installed to use check mode. If run normally this module can auto-install it.z=Auto-installing missing dependency without updating cache: %sz9Updating cache and auto-installing missing dependency: %sr&)check_rcrZz-yr'z-ozAPT::Install-Recommends=nozAPT::Install-Recommends=yesr zAPT::Default-Release)progress)secondsrvig@@r%zFailed to update apt cache: %szunknown reason)r cache_updatedcache_update_timezdeb only supports state=presentz://)rrrrrrrzrcSsg|] }|dkr|qS)*r)rrnrrr rrzmain..rXr2zKunable to install additional packages when upgrading all installed packagesrrGr8zinvalid package spec: %s)rrrz)r2r/r1rr1r) rrkrrrzrrrrrrrrrVrWr0)rrzrrz.Failed to lock apt for exclusive operation: %sz%Could not fetch updated apt files: %szNUnexpected code path taken, we really should have exited before, this is a bug)8rr DPKG_OPTIONSr locale_module setlocalerOrun_command_environ_updaterrrrr|HAS_PYTHON_APTrr(formatsys executablerr rrrrrrrrr-r?rKrAConfigr)r$rnow timedeltarandomrandintranger&rrUFetchFailedExceptionr sleeprr rcountrrZr/LockFailedException)0rlocale APT_ENV_VARSprrz apt_pkg_name interpreters interpreter apt_pkg_cmdaptclean_stdoutaptclean_stderr aptclean_diffr updated_cacher#rrrrrrdeadlinerUr"rbtdeltarr8r: randomizeretryrdelaypost_cache_update_timerunfiltered_packagesr all_installedr2rn state_upgradestate_builddep state_fixedrrlockFailedExceptionfetchFailedExceptionrrr mains*                   #         "                        r__main__)rH)H __future__r DOCUMENTATIONEXAMPLESRETURNwarningsfilterwarnings FutureWarningrrPrkrZrrdr9r%r_rransible.module_utils.basicr ansible.module_utils.common.filer"ansible.module_utils.common.localer#ansible.module_utils.common.respawnrrr +ansible.module_utils.common.text.convertersr r ansible.module_utils.sixr ansible.module_utils.urlsr rYrrrrrrrrr]r apt.debfiler? ImportErrorobjectrr>rErYrar|rrrrZrrr/rrrrr$r-rr4rrrr s Rn       MW /    d ? &   e   R