Add alternative syntax for upgrading all installed packages via apt (#25007)
syntax: 'apt: name=* state=latest' feature #24189
This commit is contained in:
parent
5c43bd3bae
commit
b820d024fc
2 changed files with 25 additions and 1 deletions
|
@ -170,6 +170,11 @@ EXAMPLES = '''
|
|||
state: latest
|
||||
install_recommends: no
|
||||
|
||||
- name: Upgrade all packages to the latest version
|
||||
apt:
|
||||
name: "*"
|
||||
state: latest
|
||||
|
||||
- name: Update all packages to the latest version
|
||||
apt:
|
||||
upgrade: dist
|
||||
|
@ -919,8 +924,15 @@ def main():
|
|||
allow_unauthenticated=allow_unauthenticated,
|
||||
force=force_yes, dpkg_options=p['dpkg_options'])
|
||||
|
||||
packages = p['package']
|
||||
packages = [package for package in p['package'] if package != '*']
|
||||
all_installed = '*' in p['package']
|
||||
latest = p['state'] == 'latest'
|
||||
|
||||
if latest and all_installed:
|
||||
if packages:
|
||||
module.fail_json(msg='unable to install additional packages when ugrading all installed packages')
|
||||
upgrade(module, 'yes', force_yes, p['default_release'], dpkg_options)
|
||||
|
||||
if packages:
|
||||
for package in packages:
|
||||
if package.count('=') > 1:
|
||||
|
|
|
@ -148,3 +148,15 @@
|
|||
assert:
|
||||
that:
|
||||
- "dpkg_force.changed"
|
||||
|
||||
# NEGATIVE: upgrade all packages while providing additional packages to install
|
||||
- name: provide additional packages to install while upgrading all installed packages
|
||||
apt: pkg=*,test state=latest
|
||||
ignore_errors: True
|
||||
register: apt_result
|
||||
|
||||
- name: verify failure of upgrade packages and install
|
||||
assert:
|
||||
that:
|
||||
- "not apt_result.changed"
|
||||
- "apt_result.failed"
|
||||
|
|
Loading…
Reference in a new issue