mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-04-10 04:30:32 -07:00
Merge 0e436967ff
into 70b5e362f9
This commit is contained in:
commit
2ddebaa805
3 changed files with 54 additions and 13 deletions
|
@ -0,0 +1,2 @@
|
|||
bugfixes:
|
||||
- zypper-module - only read attributes ``enabled``, ``disable_gpg_check`` and ``autorefresh`` from local repo files, if the parameters were not already provided by the task parameters (https://github.com/ansible-collections/community.general/pull/9108).
|
|
@ -354,19 +354,6 @@ def main():
|
|||
'name': module.params['description'],
|
||||
'priority': module.params['priority'],
|
||||
}
|
||||
# rewrite bools in the language that zypper lr -x provides for easier comparison
|
||||
if module.params['enabled']:
|
||||
repodata['enabled'] = '1'
|
||||
else:
|
||||
repodata['enabled'] = '0'
|
||||
if module.params['disable_gpg_check']:
|
||||
repodata['gpgcheck'] = '0'
|
||||
else:
|
||||
repodata['gpgcheck'] = '1'
|
||||
if module.params['autorefresh']:
|
||||
repodata['autorefresh'] = '1'
|
||||
else:
|
||||
repodata['autorefresh'] = '0'
|
||||
|
||||
def exit_unchanged():
|
||||
module.exit_json(changed=False, repodata=repodata, state=state)
|
||||
|
@ -391,6 +378,14 @@ def main():
|
|||
if not alias and state == "present":
|
||||
module.fail_json(msg='Name required when adding non-repo files.')
|
||||
|
||||
# fill boolean 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'
|
||||
|
||||
# Download / Open and parse .repo file to ensure idempotency
|
||||
if repo and repo.endswith('.repo'):
|
||||
if repo.startswith(('http://', 'https://')):
|
||||
|
@ -441,6 +436,12 @@ def main():
|
|||
if 'gpgcheck' in repofile_items:
|
||||
repodata['gpgcheck'] = repofile_items['gpgcheck']
|
||||
|
||||
# override boolean parameters in repodata with provided entries in module.params
|
||||
# in the language that zypper lr -x provides for easier comparison
|
||||
repodata['enabled'] = '1' if module.params['enabled'] else '0'
|
||||
repodata['gpgcheck'] = '0' if module.params['disable_gpg_check'] else '1'
|
||||
repodata['autorefresh'] = '1' if module.params['autorefresh'] else '0'
|
||||
|
||||
exists, mod, old_repos = repo_exists(module, repodata, overwrite_multiple)
|
||||
|
||||
if alias:
|
||||
|
|
|
@ -246,6 +246,44 @@
|
|||
that:
|
||||
- added_again_by_repo_file is not changed
|
||||
|
||||
- name: change the repository config by name with flag - disable
|
||||
community.general.zypper_repository:
|
||||
name: systemsmanagement_Uyuni_Stable
|
||||
state: present
|
||||
enabled: false
|
||||
register: modified_repo_file_result
|
||||
|
||||
- name: modified_repo_file_result is changed
|
||||
assert:
|
||||
that:
|
||||
- modified_repo_file_result is changed
|
||||
|
||||
- name: get repository details again from zypper after disabling the repository
|
||||
command: zypper --xmlout lr systemsmanagement_Uyuni_Stable
|
||||
register: get_repository_details_from_zypper
|
||||
|
||||
- name: verify modifying via .repo file was successful - the module is now disabled
|
||||
assert:
|
||||
that:
|
||||
- "'enabled=\"0\"' in get_repository_details_from_zypper.stdout"
|
||||
|
||||
- name: change flag autorefresh in the same zypper-module
|
||||
community.general.zypper_repository:
|
||||
name: systemsmanagement_Uyuni_Stable
|
||||
state: present
|
||||
autorefresh: false
|
||||
register: modified_repo_file_result
|
||||
|
||||
- name: get repository details again from zypper after disabling the repository
|
||||
command: zypper --xmlout lr systemsmanagement_Uyuni_Stable
|
||||
register: get_repository_details_from_zypper
|
||||
|
||||
- name: verify modifying via .repo file was successful - the autorefesh is disabled, but the enabled-flag was not modified (it is still disabled)
|
||||
assert:
|
||||
that:
|
||||
- "'enabled=\"0\"' in get_repository_details_from_zypper.stdout"
|
||||
- "'autorefresh=\"0\"' in get_repository_details_from_zypper.stdout"
|
||||
|
||||
- name: remove repository via url to .repo file
|
||||
community.general.zypper_repository:
|
||||
repo: http://download.opensuse.org/repositories/systemsmanagement:/Uyuni:/Stable/openSUSE_Leap_{{ ansible_distribution_version }}/systemsmanagement:Uyuni:Stable.repo
|
||||
|
|
Loading…
Add table
Reference in a new issue