Debian Codegraph @

ansible_collections/community/general/tests/integration/targets/yum_versionlock/tasks/main.yml

raw
1 ---
2 ####################################################################
3 # WARNING: These are designed specifically for Ansible tests #
4 # and should not be used as examples of how to write Ansible roles #
5 ####################################################################
6
7 # Copyright (c) Ansible Project
8 # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
9 # SPDX-License-Identifier: GPL-3.0-or-later
10
11 - name: Update procps-ng temporary until issue (#2539) is fixed
12 yum:
13 name: procps-ng
14 state: latest
15 when: ansible_facts.distribution == 'Fedora' and ansible_facts.distribution_major_version == '34'
16
17 - block:
18 - name: Install necessary packages to test yum_versionlock
19 yum:
20 name: yum-plugin-versionlock
21 state: present
22 register: yum_versionlock_install
23
24 - name: Yum checkupdate
25 yum:
26 list: updates
27 register: yum_updates
28
29 - block:
30 - name: Lock all packages
31 community.general.yum_versionlock:
32 name: "{{ yum_updates.results | map(attribute='name') | list }}"
33 state: present
34 register: lock_all_packages
35
36 - name: Lock all packages again
37 community.general.yum_versionlock:
38 name: "{{ yum_updates.results | map(attribute='name') | list }}"
39 state: present
40 register: lock_all_packages_again
41
42 - name: Lock packages wildcard
43 community.general.yum_versionlock:
44 name: "nss*"
45 state: present
46 register: lock_nss_wildcard
47
48 # This should fail when it needs user interaction and missing -y is on purpose.
49 - name: Update all packages (not really)
50 command: yum update --setopt=obsoletes=0
51 register: update_all_locked_packages
52 changed_when:
53 - '"No packages marked for update" not in update_all_locked_packages.stdout'
54 - '"Nothing to do" not in update_all_locked_packages.stdout'
55
56 - name: Unlock all packages
57 community.general.yum_versionlock:
58 name: "{{ yum_updates.results | map(attribute='name') | list }}"
59 state: absent
60 register: unlock_all_packages
61
62 - name: Update all packages
63 yum:
64 name: '*'
65 state: latest
66 check_mode: true
67 register: update_all_packages
68 when: yum_updates.results | length != 0
69
70 - name: Assert everything is fine
71 assert:
72 that:
73 - lock_all_packages is changed
74 - lock_all_packages_again is not changed
75 - lock_nss_wildcard is not changed
76 - update_all_locked_packages is not changed
77 - unlock_all_packages is changed
78 - update_all_packages is changed
79 when: yum_updates.results | length != 0
80
81 - name: Remove installed packages in case it was not installed
82 yum:
83 name: yum-plugin-versionlock
84 state: absent
85 when: yum_versionlock_install is changed
86 when: ansible_facts.distribution in ['CentOS', 'RedHat', 'Fedora']