mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Merge pull request #2391 from bcoca/apt_lock_exception
now catches lock exceptions from apt and returns friendly message
This commit is contained in:
commit
94eefac456
1 changed files with 34 additions and 30 deletions
|
@ -226,6 +226,7 @@ def main():
|
||||||
p = module.params
|
p = module.params
|
||||||
install_recommends = p['install_recommends']
|
install_recommends = p['install_recommends']
|
||||||
|
|
||||||
|
try:
|
||||||
cache = apt.Cache()
|
cache = apt.Cache()
|
||||||
if p['default_release']:
|
if p['default_release']:
|
||||||
apt_pkg.config['APT::Default-Release'] = p['default_release']
|
apt_pkg.config['APT::Default-Release'] = p['default_release']
|
||||||
|
@ -262,6 +263,9 @@ def main():
|
||||||
elif p['state'] in [ 'removed', 'absent' ]:
|
elif p['state'] in [ 'removed', 'absent' ]:
|
||||||
remove(module, packages, cache, p['purge'])
|
remove(module, packages, cache, p['purge'])
|
||||||
|
|
||||||
|
except apt.cache.LockFailedException:
|
||||||
|
module.fail_json(msg="Failed to lock apt for exclusive operation")
|
||||||
|
|
||||||
# this is magic, see lib/ansible/module_common.py
|
# this is magic, see lib/ansible/module_common.py
|
||||||
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
|
#<<INCLUDE_ANSIBLE_MODULE_COMMON>>
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue