mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-24 13:50:22 -07:00
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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue