Adding code to set default values

if the values are not provided from the task-input nor read from an existing file
This commit is contained in:
Tobias Zeuch 2024-11-08 12:43:00 +01:00
parent 2004d37073
commit ba8eca9488

View file

@ -357,17 +357,17 @@ def main():
'priority': module.params['priority'],
}
# rewrite bools in the language that zypper lr -x provides for easier comparison
if 'enabled' in module.params
if 'enabled' in module.params:
if module.params['enabled']:
repodata['enabled'] = '1'
else:
repodata['enabled'] = '0'
if 'disable_gpg_check' in module.params
if 'disable_gpg_check' in module.params:
if module.params['disable_gpg_check']:
repodata['gpgcheck'] = '0'
else:
repodata['gpgcheck'] = '1'
if 'autorefresh' in module.params
if 'autorefresh' in module.params:
if module.params['autorefresh']:
repodata['autorefresh'] = '1'
else:
@ -438,18 +438,26 @@ def main():
# Map additional values, if available
if 'name' in repofile_items:
if 'name' not in repodata
if 'name' not in repodata:
repodata['name'] = repofile_items['name']
if 'enabled' in repofile_items:
if 'enabled' not in repodata
if 'enabled' not in repodata:
repodata['enabled'] = repofile_items['enabled']
if 'autorefresh' in repofile_items:
if 'autorefresh' not in repodata
if 'autorefresh' not in repodata:
repodata['autorefresh'] = repofile_items['autorefresh']
if 'gpgcheck' in repofile_items:
if 'gpgcheck' not in repodata
if 'gpgcheck' not in repodata:
repodata['gpgcheck'] = repofile_items['gpgcheck']
# finally, fill empty attributes with defaults
if 'enabled' not in repodata:
repodata['enabled'] = '0'
if 'autorefresh' not in repodata:
repodata['autorefresh'] = '0'
if 'gpgcheck' not in repodata:
repodata['gpgcheck'] = '0'
exists, mod, old_repos = repo_exists(module, repodata, overwrite_multiple)
if alias: