mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
Zypper: Fix update_cache in checkmode (#20143)
Fixes #20139 Refresh does not support dry-run, so don't run it in check mode. Also add a test for this case.
This commit is contained in:
parent
e4bfc2b84c
commit
4976429e42
2 changed files with 26 additions and 2 deletions
|
@ -95,7 +95,7 @@ options:
|
||||||
update_cache:
|
update_cache:
|
||||||
version_added: "2.2"
|
version_added: "2.2"
|
||||||
description:
|
description:
|
||||||
- Run the equivalent of C(zypper refresh) before the operation.
|
- Run the equivalent of C(zypper refresh) before the operation. Disabled in check mode.
|
||||||
required: false
|
required: false
|
||||||
default: "no"
|
default: "no"
|
||||||
choices: [ "yes", "no" ]
|
choices: [ "yes", "no" ]
|
||||||
|
@ -449,7 +449,7 @@ def main():
|
||||||
name = filter(None, name)
|
name = filter(None, name)
|
||||||
|
|
||||||
# Refresh repositories
|
# Refresh repositories
|
||||||
if update_cache:
|
if update_cache and not module.check_mode:
|
||||||
retvals = repo_refresh(module)
|
retvals = repo_refresh(module)
|
||||||
|
|
||||||
if retvals['rc'] != 0:
|
if retvals['rc'] != 0:
|
||||||
|
|
|
@ -334,3 +334,27 @@
|
||||||
- zypperin1|changed
|
- zypperin1|changed
|
||||||
- not zypperin2|changed
|
- not zypperin2|changed
|
||||||
when: ansible_distribution == 'openSUSE Leap' and ansible_distribution_version == '42.1'
|
when: ansible_distribution == 'openSUSE Leap' and ansible_distribution_version == '42.1'
|
||||||
|
|
||||||
|
|
||||||
|
# check for https://github.com/ansible/ansible/issues/20139
|
||||||
|
- name: run updatecache
|
||||||
|
zypper:
|
||||||
|
name: hello
|
||||||
|
state: present
|
||||||
|
update_cache: True
|
||||||
|
register: zypper_result_update_cache
|
||||||
|
|
||||||
|
- name: run updatecache in check mode
|
||||||
|
zypper:
|
||||||
|
name: hello
|
||||||
|
state: present
|
||||||
|
update_cache: True
|
||||||
|
check_mode: True
|
||||||
|
register: zypper_result_update_cache_check
|
||||||
|
|
||||||
|
|
||||||
|
- assert:
|
||||||
|
that:
|
||||||
|
- zypper_result_update_cache|success
|
||||||
|
- zypper_result_update_cache_check|success
|
||||||
|
- not zypper_result_update_cache_check|changed
|
||||||
|
|
Loading…
Add table
Reference in a new issue