mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
apt_repository: added option update_cache.
The default behavior is to update_cache if changed. If you add more then one repo, you may not want to update cache for every repo separately. So you can now disable update_cache with this new option e.g. update_cache=no Updating cache can also be handled using the apt module.
This commit is contained in:
parent
a991b62a51
commit
9fccf96d61
1 changed files with 11 additions and 2 deletions
|
@ -42,6 +42,12 @@ options:
|
||||||
default: "present"
|
default: "present"
|
||||||
description:
|
description:
|
||||||
- A source string state.
|
- A source string state.
|
||||||
|
update_cache:
|
||||||
|
description:
|
||||||
|
- Run the equivalent of C(apt-get update) if has changed.
|
||||||
|
required: false
|
||||||
|
default: "yes"
|
||||||
|
choices: [ "yes", "no" ]
|
||||||
author: Alexander Saltanov
|
author: Alexander Saltanov
|
||||||
version_added: "0.7"
|
version_added: "0.7"
|
||||||
requirements: [ python-apt, python-pycurl ]
|
requirements: [ python-apt, python-pycurl ]
|
||||||
|
@ -329,6 +335,7 @@ def main():
|
||||||
argument_spec=dict(
|
argument_spec=dict(
|
||||||
repo=dict(required=True),
|
repo=dict(required=True),
|
||||||
state=dict(choices=['present', 'absent'], default='present'),
|
state=dict(choices=['present', 'absent'], default='present'),
|
||||||
|
update_cache = dict(aliases=['update-cache'], type='bool'),
|
||||||
),
|
),
|
||||||
supports_check_mode=True,
|
supports_check_mode=True,
|
||||||
)
|
)
|
||||||
|
@ -341,6 +348,7 @@ def main():
|
||||||
|
|
||||||
repo = module.params['repo']
|
repo = module.params['repo']
|
||||||
state = module.params['state']
|
state = module.params['state']
|
||||||
|
update_cache = module.params['update_cache']
|
||||||
sourceslist = None
|
sourceslist = None
|
||||||
|
|
||||||
if isinstance(distro, aptsources.distro.DebianDistribution):
|
if isinstance(distro, aptsources.distro.DebianDistribution):
|
||||||
|
@ -366,8 +374,9 @@ def main():
|
||||||
if not module.check_mode and changed:
|
if not module.check_mode and changed:
|
||||||
try:
|
try:
|
||||||
sourceslist.save(module)
|
sourceslist.save(module)
|
||||||
cache = apt.Cache()
|
if update_cache:
|
||||||
cache.update()
|
cache = apt.Cache()
|
||||||
|
cache.update()
|
||||||
except OSError as err:
|
except OSError as err:
|
||||||
module.fail_json(msg=unicode(err))
|
module.fail_json(msg=unicode(err))
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue