mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-08 14:20:04 -07:00
yum_versionlock: fix idempotency when using wildcard (asterisk) (#2787)
* Check idempotency on yum_versionlock * Lock packages wildcard * fix formatting Co-authored-by: Felix Fontein <felix@fontein.de> * Fix formatting in asserts * little closer but not still there * Import fnmatch * Change check_mode logic * Add check_mode for add * Add changelog Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
parent
c7cf6f2eb7
commit
0a9cf38118
3 changed files with 32 additions and 14 deletions
|
@ -29,6 +29,18 @@
|
|||
state: present
|
||||
register: lock_all_packages
|
||||
|
||||
- name: Lock all packages again
|
||||
community.general.yum_versionlock:
|
||||
name: "{{ yum_updates.results | map(attribute='name') | list }}"
|
||||
state: present
|
||||
register: lock_all_packages_again
|
||||
|
||||
- name: Lock packages wildcard
|
||||
community.general.yum_versionlock:
|
||||
name: "nss*"
|
||||
state: present
|
||||
register: lock_nss_wildcard
|
||||
|
||||
# This should fail when it needs user interaction and missing -y is on purpose.
|
||||
- name: Update all packages (not really)
|
||||
command: yum update --setopt=obsoletes=0
|
||||
|
@ -54,10 +66,12 @@
|
|||
- name: Assert everything is fine
|
||||
assert:
|
||||
that:
|
||||
- "{{ lock_all_packages.changed }}"
|
||||
- "{{ not update_all_locked_packages.changed }}"
|
||||
- "{{ unlock_all_packages.changed }}"
|
||||
- "{{ update_all_packages.changed }}"
|
||||
- lock_all_packages is changed
|
||||
- lock_all_packages_again is not changed
|
||||
- lock_nss_wildcard is not changed
|
||||
- update_all_locked_packages is not changed
|
||||
- unlock_all_packages is changed
|
||||
- update_all_packages is changed
|
||||
when: yum_updates.results | length != 0
|
||||
|
||||
- name: Remove installed packages in case it was not installed
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue