mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-28 07:31:23 -07:00
Add zypper skip post errors feature (#9973)
* Add zypper skip post errors feature * Add feature to handle zypper return code 107 with skip_post_errors (default: false). * Add integration test to verify the skip_post_errors flag. * Add changelog fragment Issue: #9972 Issue-Ref: https://github.com/ansible-collections/community.general/issues/9972 Co-authored-by: Felix Fontein <felix@fontein.de> * Update plugins/modules/zypper.py * Update changelogs/fragments/9972-zypper-skip-post-errors.yml Co-authored-by: Felix Fontein <felix@fontein.de> * Update tests/integration/targets/zypper/tasks/zypper.yml Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --------- Co-authored-by: Felix Fontein <felix@fontein.de> Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com>
This commit is contained in:
parent
1243846c3a
commit
80252b29f8
5 changed files with 127 additions and 3 deletions
15
tests/integration/targets/zypper/files/post_error.spec
Normal file
15
tests/integration/targets/zypper/files/post_error.spec
Normal file
|
@ -0,0 +1,15 @@
|
|||
Summary: Post error RPM
|
||||
Name: post_error
|
||||
Version: 1
|
||||
Release: 0
|
||||
License: GPLv3
|
||||
Group: Applications/System
|
||||
BuildArch: noarch
|
||||
|
||||
%description
|
||||
Post error RPM
|
||||
|
||||
%files
|
||||
|
||||
%post
|
||||
exit 1
|
|
@ -0,0 +1,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)
|
||||
SPDX-License-Identifier: GPL-3.0-or-later
|
||||
SPDX-FileCopyrightText: Ansible Project
|
|
@ -255,6 +255,91 @@
|
|||
that:
|
||||
- "stat_result.stat.exists == true"
|
||||
|
||||
# Build and install an empty rpm with error in post script
|
||||
- name: uninstall post_error
|
||||
zypper:
|
||||
name: post_error
|
||||
state: removed
|
||||
|
||||
- name: install rpmbuild
|
||||
zypper:
|
||||
name: rpmbuild
|
||||
state: present
|
||||
|
||||
- name: clean zypper RPM cache
|
||||
file:
|
||||
name: /var/cache/zypper/RPMS
|
||||
state: absent
|
||||
|
||||
- name: create directory
|
||||
file:
|
||||
path: "{{ remote_tmp_dir | expanduser }}/zypper2"
|
||||
state: directory
|
||||
|
||||
- name: copy spec file
|
||||
copy:
|
||||
src: post_error.spec
|
||||
dest: "{{ remote_tmp_dir | expanduser }}/zypper2/post_error.spec"
|
||||
|
||||
- name: build rpm
|
||||
command: |
|
||||
rpmbuild -bb \
|
||||
--define "_topdir {{remote_tmp_dir | expanduser }}/zypper2/rpm-build"
|
||||
--define "_builddir %{_topdir}" \
|
||||
--define "_rpmdir %{_topdir}" \
|
||||
--define "_srcrpmdir %{_topdir}" \
|
||||
--define "_specdir {{remote_tmp_dir | expanduser}}/zypper2" \
|
||||
--define "_sourcedir %{_topdir}" \
|
||||
{{ remote_tmp_dir }}/zypper2/post_error.spec
|
||||
register: rpm_build_result
|
||||
|
||||
- name: install post_error rpm with skip_post_errors
|
||||
zypper:
|
||||
name: "{{ remote_tmp_dir | expanduser }}/zypper2/rpm-build/noarch/post_error-1-0.noarch.rpm"
|
||||
disable_gpg_check: true
|
||||
skip_post_errors: true
|
||||
register: zypper_result
|
||||
|
||||
- name: check post_error rpm
|
||||
shell: rpm -q post_error
|
||||
failed_when: false
|
||||
register: rpm_result
|
||||
|
||||
- name: verify installation of post_error
|
||||
assert:
|
||||
that:
|
||||
- "zypper_result.rc == 0"
|
||||
- "zypper_result.changed"
|
||||
- "rpm_result.rc == 0"
|
||||
|
||||
- name: uninstall post_error
|
||||
zypper:
|
||||
name: post_error
|
||||
state: removed
|
||||
|
||||
- name: install post_error rpm without skip_post_errors
|
||||
zypper:
|
||||
name: "{{ remote_tmp_dir | expanduser }}/zypper2/rpm-build/noarch/post_error-1-0.noarch.rpm"
|
||||
disable_gpg_check: true
|
||||
register: zypper_result
|
||||
ignore_errors: true
|
||||
|
||||
- name: check post_error rpm
|
||||
shell: rpm -q post_error
|
||||
failed_when: false
|
||||
register: rpm_result
|
||||
|
||||
- name: verify installation of post_error
|
||||
assert:
|
||||
that:
|
||||
- "zypper_result.rc == 107"
|
||||
- "not zypper_result.changed"
|
||||
- "rpm_result.rc == 0"
|
||||
|
||||
- name: uninstall post_error
|
||||
zypper:
|
||||
name: post_error
|
||||
state: removed
|
||||
|
||||
# test simultaneous remove and install using +- prefixes
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue