mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
42f28048a8
* Disable yum_versionlock integration test on Fedora 34
* Remove --assumeyes and add a comment regarding this
* Update update task name
(cherry picked from commit da7e4e1dc2
)
Co-authored-by: Amin Vakil <info@aminvakil.com>
63 lines
2.3 KiB
YAML
63 lines
2.3 KiB
YAML
---
|
|
####################################################################
|
|
# WARNING: These are designed specifically for Ansible tests #
|
|
# and should not be used as examples of how to write Ansible roles #
|
|
####################################################################
|
|
|
|
- block:
|
|
- name: Install necessary packages to test yum_versionlock
|
|
yum:
|
|
name: yum-plugin-versionlock
|
|
state: present
|
|
register: yum_versionlock_install
|
|
|
|
- name: Yum checkupdate
|
|
yum:
|
|
list: updates
|
|
register: yum_updates
|
|
|
|
- block:
|
|
- name: Lock all packages
|
|
community.general.yum_versionlock:
|
|
name: "{{ yum_updates.results | map(attribute='name') | list }}"
|
|
state: present
|
|
register: lock_all_packages
|
|
|
|
# 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
|
|
register: update_all_locked_packages
|
|
changed_when:
|
|
- '"No packages marked for update" not in update_all_locked_packages.stdout'
|
|
- '"Nothing to do" not in update_all_locked_packages.stdout'
|
|
|
|
- name: Unlock all packages
|
|
community.general.yum_versionlock:
|
|
name: "{{ yum_updates.results | map(attribute='name') | list }}"
|
|
state: absent
|
|
register: unlock_all_packages
|
|
|
|
- name: Update all packages
|
|
yum:
|
|
name: '*'
|
|
state: latest
|
|
check_mode: yes
|
|
register: update_all_packages
|
|
when: yum_updates.results | length != 0
|
|
|
|
- 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 }}"
|
|
when: yum_updates.results | length != 0
|
|
|
|
- name: Remove installed packages in case it was not installed
|
|
yum:
|
|
name: yum-plugin-versionlock
|
|
state: absent
|
|
when: yum_versionlock_install is changed
|
|
when: (ansible_distribution in ['CentOS', 'RedHat'] and ansible_distribution_major_version is version('7', '>=')) or
|
|
(ansible_distribution == 'Fedora' and ansible_distribution_major_version is version('33', '<='))
|