1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2024-09-14 20:13:21 +02:00
community.general/tests/integration/targets/dnf_versionlock/tasks/lock_updates.yml
patchback[bot] fbf11668f4
CI: Remove 'warn:' that's removed in ansible-core 2.14 (#4434) (#4437)
* Remove 'warn:' that's removed in ansible-core 2.14.

* Install virtualenv when needed.

(cherry picked from commit 24ca69aa05)

Co-authored-by: Felix Fontein <felix@fontein.de>
2022-04-01 23:11:39 +02:00

70 lines
1.6 KiB
YAML
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

---
- name: Check packages with updates
dnf:
list: updates
register: updates
- name: Set local facts
set_fact:
_packages: "{{ (updates.results | map(attribute='name') | list)[:5] }}"
- debug:
msg:
- "The packages to be locked and unlocked are: {{ _packages}}"
- block:
- name: Clear locklist
community.general.dnf_versionlock:
state: clean
register: clear_locklist
- assert:
that:
- clear_locklist.locklist_post | length == 0
- name: Lock packages with updates
dnf_versionlock:
name: "{{ _packages }}"
state: present
register: lock_packages
- assert:
that:
- lock_packages is changed
- (lock_packages.locklist_post | length) <= (_packages | length)
- name: Update packages with updates while locked
command: >-
dnf update -y
--setopt=obsoletes=0 {{ _packages | join(' ') }}
register: update_locked_packages
changed_when: '"Nothing to do" not in update_locked_packages.stdout'
- assert:
that:
- update_locked_packages is not changed
- name: Unlock packages with updates
dnf_versionlock:
name: "{{ _packages }}"
state: absent
register: unlock_packages
- assert:
that:
- unlock_packages is changed
- unlock_packages.locklist_post | length == 0
- name: Update packages
dnf:
name: "{{ _packages }}"
state: latest
check_mode: yes
register: update_packages
- assert:
that:
- update_packages is changed
when: updates.results | length > 0
...