Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/dnf_versionlock/tasks/lock_updates.yml

raw
1 ---
2 # Copyright (c) Ansible Project
3 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 - name: Check packages with updates
7 dnf:
8 list: updates
9 register: updates
10
11 - name: Set local facts
12 set_fact:
13 _packages: "{{ (updates.results | map(attribute='name') | list)[:5] }}"
14
15 - debug:
16 msg:
17 - "The packages to be locked and unlocked are: {{ _packages}}"
18
19 - block:
20 - name: Clear locklist
21 community.general.dnf_versionlock:
22 state: clean
23 register: clear_locklist
24
25 - assert:
26 that:
27 - clear_locklist.locklist_post | length == 0
28
29 - name: Lock packages with updates
30 dnf_versionlock:
31 name: "{{ _packages }}"
32 state: present
33 register: lock_packages
34
35 - assert:
36 that:
37 - lock_packages is changed
38 - (lock_packages.locklist_post | length) <= (_packages | length)
39
40 - name: Update packages with updates while locked
41 command: >-
42 dnf update -y
43 --setopt=obsoletes=0 {{ _packages | join(' ') }}
44 register: update_locked_packages
45 changed_when: '"Nothing to do" not in update_locked_packages.stdout'
46
47 - assert:
48 that:
49 - update_locked_packages is not changed
50
51 - name: Unlock packages with updates
52 dnf_versionlock:
53 name: "{{ _packages }}"
54 state: absent
55 register: unlock_packages
56
57 - assert:
58 that:
59 - unlock_packages is changed
60 - unlock_packages.locklist_post | length == 0
61
62 - name: Update packages
63 dnf:
64 name: "{{ _packages }}"
65 state: latest
66 check_mode: true
67 register: update_packages
68
69 - assert:
70 that:
71 - update_packages is changed
72
73 when: updates.results | length > 0
74 ...