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/yum_versionlock/tasks/main.yml

88 lines
3.2 KiB
YAML
Raw Normal View History

yum_versionlock: new module (#1405) * new module: yum_versionlock * Removed redundant logic * Added check_mode support * Updated examples * Updated documentation Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> Co-authored-by: Erik-jan Riemers <riemers@binkey.nl> * Update plugins/modules/packaging/os/yum_versionlock.py Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Fix version_added * Add module symlink * Fix symlink * Improve documentation formatting by Anderssoon007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Improve documentation formatting by Anderssoon007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Improve documentation * Add notes section * check_mode is supported * Initial integration test * Change pkg to name * Do the tests only when there is something to update * Ignore CentOS 6 * Fix * Do not update obsolete packages * yum -q versionlock list does not show anything in CentOS 8 * Various suggestions by Andersson007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Apply suggestions from felixfontein review Co-authored-by: Felix Fontein <felix@fontein.de> * returned always * Apply felixfontein suggestion Co-authored-by: Felix Fontein <felix@fontein.de> * Fix RETUNRED values returned * Change default from present to locked * Remove locked, unlocked states * change locked/unlocked to present/absent in integration tests Co-authored-by: Felix Fontein <felix@fontein.de> * Fix module short_description formatting * Add myself as co-author Co-authored-by: Erik-jan Riemers <riemers@binkey.nl> Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> Co-authored-by: Felix Fontein <felix@fontein.de>
2020-12-03 20:00:49 +01:00
---
####################################################################
# WARNING: These are designed specifically for Ansible tests #
# and should not be used as examples of how to write Ansible roles #
####################################################################
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later
- name: Update procps-ng temporary until issue (#2539) is fixed
yum:
name: procps-ng
state: latest
when: ansible_distribution == 'Fedora' and ansible_distribution_major_version == '34'
yum_versionlock: new module (#1405) * new module: yum_versionlock * Removed redundant logic * Added check_mode support * Updated examples * Updated documentation Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> Co-authored-by: Erik-jan Riemers <riemers@binkey.nl> * Update plugins/modules/packaging/os/yum_versionlock.py Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Fix version_added * Add module symlink * Fix symlink * Improve documentation formatting by Anderssoon007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Improve documentation formatting by Anderssoon007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Improve documentation * Add notes section * check_mode is supported * Initial integration test * Change pkg to name * Do the tests only when there is something to update * Ignore CentOS 6 * Fix * Do not update obsolete packages * yum -q versionlock list does not show anything in CentOS 8 * Various suggestions by Andersson007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Apply suggestions from felixfontein review Co-authored-by: Felix Fontein <felix@fontein.de> * returned always * Apply felixfontein suggestion Co-authored-by: Felix Fontein <felix@fontein.de> * Fix RETUNRED values returned * Change default from present to locked * Remove locked, unlocked states * change locked/unlocked to present/absent in integration tests Co-authored-by: Felix Fontein <felix@fontein.de> * Fix module short_description formatting * Add myself as co-author Co-authored-by: Erik-jan Riemers <riemers@binkey.nl> Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> Co-authored-by: Felix Fontein <felix@fontein.de>
2020-12-03 20:00:49 +01:00
- 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
- 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
yum_versionlock: new module (#1405) * new module: yum_versionlock * Removed redundant logic * Added check_mode support * Updated examples * Updated documentation Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> Co-authored-by: Erik-jan Riemers <riemers@binkey.nl> * Update plugins/modules/packaging/os/yum_versionlock.py Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Fix version_added * Add module symlink * Fix symlink * Improve documentation formatting by Anderssoon007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Improve documentation formatting by Anderssoon007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Improve documentation * Add notes section * check_mode is supported * Initial integration test * Change pkg to name * Do the tests only when there is something to update * Ignore CentOS 6 * Fix * Do not update obsolete packages * yum -q versionlock list does not show anything in CentOS 8 * Various suggestions by Andersson007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Apply suggestions from felixfontein review Co-authored-by: Felix Fontein <felix@fontein.de> * returned always * Apply felixfontein suggestion Co-authored-by: Felix Fontein <felix@fontein.de> * Fix RETUNRED values returned * Change default from present to locked * Remove locked, unlocked states * change locked/unlocked to present/absent in integration tests Co-authored-by: Felix Fontein <felix@fontein.de> * Fix module short_description formatting * Add myself as co-author Co-authored-by: Erik-jan Riemers <riemers@binkey.nl> Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> Co-authored-by: Felix Fontein <felix@fontein.de>
2020-12-03 20:00:49 +01:00
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: true
yum_versionlock: new module (#1405) * new module: yum_versionlock * Removed redundant logic * Added check_mode support * Updated examples * Updated documentation Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> Co-authored-by: Erik-jan Riemers <riemers@binkey.nl> * Update plugins/modules/packaging/os/yum_versionlock.py Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Fix version_added * Add module symlink * Fix symlink * Improve documentation formatting by Anderssoon007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Improve documentation formatting by Anderssoon007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Improve documentation * Add notes section * check_mode is supported * Initial integration test * Change pkg to name * Do the tests only when there is something to update * Ignore CentOS 6 * Fix * Do not update obsolete packages * yum -q versionlock list does not show anything in CentOS 8 * Various suggestions by Andersson007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Apply suggestions from felixfontein review Co-authored-by: Felix Fontein <felix@fontein.de> * returned always * Apply felixfontein suggestion Co-authored-by: Felix Fontein <felix@fontein.de> * Fix RETUNRED values returned * Change default from present to locked * Remove locked, unlocked states * change locked/unlocked to present/absent in integration tests Co-authored-by: Felix Fontein <felix@fontein.de> * Fix module short_description formatting * Add myself as co-author Co-authored-by: Erik-jan Riemers <riemers@binkey.nl> Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> Co-authored-by: Felix Fontein <felix@fontein.de>
2020-12-03 20:00:49 +01:00
register: update_all_packages
when: yum_updates.results | length != 0
- name: Assert everything is fine
assert:
that:
- 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
yum_versionlock: new module (#1405) * new module: yum_versionlock * Removed redundant logic * Added check_mode support * Updated examples * Updated documentation Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> Co-authored-by: Erik-jan Riemers <riemers@binkey.nl> * Update plugins/modules/packaging/os/yum_versionlock.py Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Fix version_added * Add module symlink * Fix symlink * Improve documentation formatting by Anderssoon007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Improve documentation formatting by Anderssoon007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Improve documentation * Add notes section * check_mode is supported * Initial integration test * Change pkg to name * Do the tests only when there is something to update * Ignore CentOS 6 * Fix * Do not update obsolete packages * yum -q versionlock list does not show anything in CentOS 8 * Various suggestions by Andersson007 Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> * Apply suggestions from felixfontein review Co-authored-by: Felix Fontein <felix@fontein.de> * returned always * Apply felixfontein suggestion Co-authored-by: Felix Fontein <felix@fontein.de> * Fix RETUNRED values returned * Change default from present to locked * Remove locked, unlocked states * change locked/unlocked to present/absent in integration tests Co-authored-by: Felix Fontein <felix@fontein.de> * Fix module short_description formatting * Add myself as co-author Co-authored-by: Erik-jan Riemers <riemers@binkey.nl> Co-authored-by: Abhijeet Kasurde <akasurde@redhat.com> Co-authored-by: Andrew Klychkov <aaklychkov@mail.ru> Co-authored-by: Felix Fontein <felix@fontein.de>
2020-12-03 20:00:49 +01:00
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')