mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-22 21:00:22 -07:00
yum: do not hide yum's errors (#27696)
This commit is contained in:
parent
7974ad34f1
commit
1c4e491eac
2 changed files with 110 additions and 30 deletions
|
@ -1,21 +1,4 @@
|
|||
# UNINSTALL 'yum-utils'
|
||||
# The `yum` module has the smarts to auto-install `yum-utils`. To test, we
|
||||
# will first uninstall `yum-utils`.
|
||||
- name: check yum-utils with rpm
|
||||
shell: rpm -q yum-utils
|
||||
register: rpm_result
|
||||
ignore_errors: true
|
||||
|
||||
# Don't uninstall yum-utils with the `yum` module, it would be bad. The `yum`
|
||||
# module does some `repoquery` magic after removing a package. It fails when you
|
||||
# remove `yum-utils.
|
||||
- name: uninstall yum-utils with shell
|
||||
shell: yum -y remove yum-utils
|
||||
when: rpm_result|success
|
||||
|
||||
# UNINSTALL
|
||||
# With 'yum-utils' uninstalled, the first call to 'yum' should install
|
||||
# yum-utils.
|
||||
- name: uninstall sos
|
||||
yum: name=sos state=removed
|
||||
register: yum_result
|
||||
|
@ -232,3 +215,103 @@
|
|||
installroot: '/'
|
||||
state: removed
|
||||
register: yum_result
|
||||
|
||||
- name: install group
|
||||
yum:
|
||||
name: "@Development Tools"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: verify installation of the group
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.rc == 0"
|
||||
- "yum_result.changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: install the group again
|
||||
yum:
|
||||
name: "@Development Tools"
|
||||
state: present
|
||||
register: yum_result
|
||||
|
||||
- name: verify nothing changed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.rc == 0"
|
||||
- "not yum_result.changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: try to install non existing group
|
||||
yum:
|
||||
name: "@non-existing-group"
|
||||
state: present
|
||||
register: yum_result
|
||||
ignore_errors: True
|
||||
|
||||
- name: verify installation of the non existing group failed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result.rc == 1"
|
||||
- "not yum_result.changed"
|
||||
- "yum_result|failed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
- "'rc' in yum_result"
|
||||
- "'results' in yum_result"
|
||||
|
||||
- name: try to install non existing file
|
||||
yum:
|
||||
name: /tmp/non-existing-1.0.0.fc26.noarch.rpm
|
||||
state: present
|
||||
register: yum_result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: verify installation failed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result|failed"
|
||||
- "not yum_result.changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
|
||||
- name: try to install from non existing url
|
||||
yum:
|
||||
name: http://non-existing.com/non-existing-1.0.0.fc26.noarch.rpm
|
||||
state: present
|
||||
register: yum_result
|
||||
ignore_errors: yes
|
||||
|
||||
- name: verify installation failed
|
||||
assert:
|
||||
that:
|
||||
- "yum_result|failed"
|
||||
- "not yum_result.changed"
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'changed' in yum_result"
|
||||
- "'msg' in yum_result"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue