mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
sorcery: update only specified grimoires (#7091)
* sorcery: update only specified grimoires * Update plugins/modules/sorcery.py Co-authored-by: Felix Fontein <felix@fontein.de> * Add a flag to omit listing new repositories before add/remove * No need to append an empty string --------- Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
fe3eec0122
commit
f7176df480
1 changed files with 11 additions and 2 deletions
|
@ -255,9 +255,11 @@ def codex_fresh(codex, module):
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
def codex_list(module):
|
def codex_list(module, skip_new=False):
|
||||||
""" List valid grimoire collection. """
|
""" List valid grimoire collection. """
|
||||||
|
|
||||||
|
params = module.params
|
||||||
|
|
||||||
codex = {}
|
codex = {}
|
||||||
|
|
||||||
cmd_scribe = "%s index" % SORCERY['scribe']
|
cmd_scribe = "%s index" % SORCERY['scribe']
|
||||||
|
@ -276,6 +278,10 @@ def codex_list(module):
|
||||||
if match:
|
if match:
|
||||||
codex[match.group('grim')] = match.group('ver')
|
codex[match.group('grim')] = match.group('ver')
|
||||||
|
|
||||||
|
# return only specified grimoires unless requested to skip new
|
||||||
|
if params['repository'] and not skip_new:
|
||||||
|
codex = dict((x, codex.get(x, NA)) for x in params['name'])
|
||||||
|
|
||||||
if not codex:
|
if not codex:
|
||||||
module.fail_json(msg="no grimoires to operate on; add at least one")
|
module.fail_json(msg="no grimoires to operate on; add at least one")
|
||||||
|
|
||||||
|
@ -337,6 +343,9 @@ def update_codex(module):
|
||||||
|
|
||||||
cmd_scribe = "%s update" % SORCERY['scribe']
|
cmd_scribe = "%s update" % SORCERY['scribe']
|
||||||
|
|
||||||
|
if params['repository']:
|
||||||
|
cmd_scribe += ' %s' % ' '.join(codex.keys())
|
||||||
|
|
||||||
rc, stdout, stderr = module.run_command(cmd_scribe)
|
rc, stdout, stderr = module.run_command(cmd_scribe)
|
||||||
|
|
||||||
if rc != 0:
|
if rc != 0:
|
||||||
|
@ -485,7 +494,7 @@ def manage_grimoires(module):
|
||||||
grimoires = params['name']
|
grimoires = params['name']
|
||||||
url = params['repository']
|
url = params['repository']
|
||||||
|
|
||||||
codex = codex_list(module)
|
codex = codex_list(module, True)
|
||||||
|
|
||||||
if url == '*':
|
if url == '*':
|
||||||
if params['state'] in ('present', 'latest', 'absent'):
|
if params['state'] in ('present', 'latest', 'absent'):
|
||||||
|
|
Loading…
Reference in a new issue