mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-08 22:30:04 -07:00
disable_excludes (#42510)
* implementing disable_excludes * add check for yum version * limit choices * add testcases for disable_exclude * fix formating * add documentation * syntax fix for test case * fix indentation * need to ignore errors when we want to do a test that fails * test disable_excludes with zip and not sos * add tests for yum < 3.4 not supported * fix formating * centos 6.1 does not support map * drop unsupported selectattr * cleanup testcases * fix test cases beloging to wrong test scenarion (propper when) * evaluate expression * minor test fixes * check output of msg
This commit is contained in:
parent
f2acc97b84
commit
66adabfd42
2 changed files with 201 additions and 57 deletions
|
@ -214,7 +214,7 @@
|
|||
- name: check sos with rpm
|
||||
shell: rpm -q sos
|
||||
|
||||
- name: check sos with rpm
|
||||
- name: check bc with rpm
|
||||
shell: rpm -q bc
|
||||
|
||||
- name: uninstall sos and bc
|
||||
|
@ -546,3 +546,113 @@
|
|||
file:
|
||||
name: "/tmp/non_existent_pkg.rpm"
|
||||
state: absent
|
||||
|
||||
- name: get yum version
|
||||
yum:
|
||||
list: yum
|
||||
register: yum_version
|
||||
|
||||
- name: set yum_version of installed version
|
||||
set_fact:
|
||||
yum_version: "{%- if item.yumstate == 'installed' -%}{{ item.version }}{%- else -%}{{ yum_version }}{%- endif -%}"
|
||||
with_items: "{{ yum_version.results }}"
|
||||
|
||||
- name: check whether yum supports disableexcludes (>= 3.4)
|
||||
set_fact:
|
||||
supports_disable_excludes: "{{ yum_version is version_compare('3.4.0', '>=') }}"
|
||||
|
||||
- name: uninstall zip
|
||||
yum: name=zip state=removed
|
||||
|
||||
- name: check zip with rpm
|
||||
shell: rpm -q zip
|
||||
ignore_errors: True
|
||||
register: rpm_zip_result
|
||||
|
||||
- name: verify zip is uninstalled
|
||||
assert:
|
||||
that:
|
||||
- "rpm_zip_result is failed"
|
||||
|
||||
- name: exclude zip
|
||||
lineinfile:
|
||||
dest: /etc/yum.conf
|
||||
regexp: (^exclude=)(.)*
|
||||
line: "exclude=zip*"
|
||||
state: present
|
||||
|
||||
# begin test case where disable_excludes is supported
|
||||
- name: Try install zip without disable_excludes
|
||||
yum: name=zip state=latest
|
||||
register: yum_zip_result
|
||||
ignore_errors: True
|
||||
when: supports_disable_excludes
|
||||
|
||||
- name: verify zip did not install because it is in exclude list
|
||||
assert:
|
||||
that:
|
||||
- "yum_zip_result is failed"
|
||||
when: supports_disable_excludes
|
||||
|
||||
- name: install zip with disable_excludes
|
||||
yum: name=zip state=latest disable_excludes=all
|
||||
register: yum_zip_result_using_excludes
|
||||
when: supports_disable_excludes
|
||||
|
||||
- name: verify zip did install using disable_excludes=all
|
||||
assert:
|
||||
that:
|
||||
- "yum_zip_result_using_excludes is success"
|
||||
- "yum_zip_result_using_excludes is changed"
|
||||
- "yum_zip_result_using_excludes is not failed"
|
||||
when: supports_disable_excludes
|
||||
|
||||
- name: remove exclude zip (cleanup yum.conf)
|
||||
lineinfile:
|
||||
dest: /etc/yum.conf
|
||||
regexp: (^exclude=zip*)
|
||||
line: "exclude="
|
||||
state: present
|
||||
when: supports_disable_excludes
|
||||
# end test case where disable_excludes is supported
|
||||
|
||||
# begin test case where disable_excludes is not supported
|
||||
- name: Try install zip with disable_excludes
|
||||
yum: name=zip state=latest disable_excludes=all
|
||||
register: yum_fail_zip_result_old_yum
|
||||
ignore_errors: True
|
||||
when: not supports_disable_excludes
|
||||
|
||||
- name: verify packages did not install because yum version is unsupported
|
||||
assert:
|
||||
that:
|
||||
- "yum_fail_zip_result_old_yum is failed"
|
||||
when: not supports_disable_excludes
|
||||
|
||||
- name: verify yum module outputs
|
||||
assert:
|
||||
that:
|
||||
- "'is available in yum version 3.4 and onwards.' in yum_fail_zip_result_old_yum.msg"
|
||||
when: not supports_disable_excludes
|
||||
|
||||
- name: remove exclude zip (cleanup yum.conf)
|
||||
lineinfile:
|
||||
dest: /etc/yum.conf
|
||||
regexp: (^exclude=zip*)
|
||||
line: "exclude="
|
||||
state: present
|
||||
when: not supports_disable_excludes
|
||||
|
||||
- name: install zip (bring test env in same state as when testing started)
|
||||
yum: name=zip state=latest
|
||||
register: yum_zip_result_old_yum
|
||||
when: not supports_disable_excludes
|
||||
|
||||
- name: verify zip installed
|
||||
assert:
|
||||
that:
|
||||
- "yum_zip_result_old_yum is success"
|
||||
- "yum_zip_result_old_yum is changed"
|
||||
- "yum_zip_result_old_yum is not failed"
|
||||
when: not supports_disable_excludes
|
||||
# end test case where disable_excludes is not supported
|
Loading…
Add table
Add a link
Reference in a new issue