Restore repos after zypper_repository test runs.

This also allows the test to run on newer containers by not
manipulating any of the pre-configured repositories.

(cherry picked from commit cac51e6da8)
pull/44940/head
Matt Clay 6 years ago
parent 7342085586
commit f8e742acee

@ -17,5 +17,5 @@
# You should have received a copy of the GNU General Public License
# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
- include: 'zypper_repository.yml'
- include: 'test.yml'
when: ansible_os_family == 'Suse'

@ -0,0 +1,33 @@
- name: collect repo configuration before test
shell: "grep . /etc/zypp/repos.d/*"
register: before
- name: ensure zypper ref works
command: zypper -n ref
- block:
- include: 'zypper_repository.yml'
always:
- name: remove repositories added during test
zypper_repository:
name: "{{item}}"
state: absent
with_items:
- chrome1
- chrome2
- test
- testrefresh
- testprio
- Apache_Modules
- name: collect repo configuration after test
shell: "grep . /etc/zypp/repos.d/*"
register: after
- name: verify repo configuration has been restored
assert:
that:
- before.stdout == after.stdout
- name: ensure zypper ref still works
command: zypper -n ref

@ -1,8 +1,3 @@
---
- name: ensure zypper ref works
command: zypper -n ref
- name: Delete test repo
zypper_repository:
name: test
@ -16,8 +11,6 @@
repo: http://dl.google.com/linux/chrome/rpm/stable/x86_64
register: zypper_result
- debug: var=zypper_result
- name: verify repo addition
assert:
that:
@ -47,17 +40,12 @@
that:
- "zypper_result.changed"
- name: Remove repo by name (also to not mess up later tasks)
zypper_repository:
name: test
state: absent
- name: use refresh option
zypper_repository:
name: testrefresh
refresh: no
state: present
repo: http://download.opensuse.org/distribution/leap/{{ ansible_distribution_version }}/repo/oss/
repo: http://download.videolan.org/pub/vlc/SuSE/Leap_{{ ansible_distribution_version }}/
- name: check refreshoption
command: zypper -x lr testrefresh
@ -72,7 +60,7 @@
name: testprio
priority: 55
state: present
repo: http://download.opensuse.org/distribution/leap/{{ ansible_distribution_version }}/repo/oss/
repo: http://download.videolan.org/pub/vlc/SuSE/Leap_{{ ansible_distribution_version }}/
- name: check refreshoption
command: zypper -x lr testprio
@ -86,18 +74,18 @@
zypper_repository:
name: "{{item}}"
state: present
repo: http://download.opensuse.org/distribution/leap/{{ ansible_distribution_version }}/repo/oss/
repo: http://dl.google.com/linux/chrome/rpm/stable/x86_64
with_items:
- oss1
- oss2
- chrome1
- chrome2
- name: check repo is updated by url
command: zypper lr oss1
command: zypper lr chrome1
register: zypper_result1
ignore_errors: yes
- name: check repo is updated by url
command: zypper lr oss2
command: zypper lr chrome2
register: zypper_result2
- assert:
@ -105,16 +93,7 @@
- "zypper_result1.rc == 6"
- "'not found' in zypper_result1.stderr"
- "zypper_result2.rc == 0"
- "'http://download.opensuse.org/distribution/leap/{{ ansible_distribution_version }}/repo/oss/' in zypper_result2.stdout"
- name: reset oss repo (to not break zypper later)
zypper_repository:
name: OSS
state: present
repo: http://download.opensuse.org/distribution/leap/{{ ansible_distribution_version }}/repo/oss/
priority: 99
refresh: yes
- "'http://dl.google.com/linux/chrome/rpm/stable/x86_64' in zypper_result2.stdout"
- name: add two repos with same name
zypper_repository:
@ -139,9 +118,6 @@
repo: http://download.opensuse.org/repositories/devel:/languages:/ruby/openSUSE_Leap_{{ ansible_distribution_version }}/
state: absent
- name: ensure zypper ref still works
command: zypper -n ref
- name: "Test adding a repo with custom GPG key"
zypper_repository:
name: "Apache_Modules"
@ -149,6 +125,3 @@
priority: 100
auto_import_keys: true
state: "present"
- name: ensure zypper ref still works
command: zypper -n ref

Loading…
Cancel
Save