zypper_repository: fix idempotency on adding repo with releasever and basearch variables (#2722)

* zypper_repository: Check idempotency on adding repo with releasever

* Name required when adding non-repo files.

* Initial try to fix releasever

* Replace re.sub with .replace

* name releaseverrepo releaseverrepo

* Change  to ansible_distribution_version for removing repo

* improve asserts format

* add changelog

* Fix changelog formatting

Co-authored-by: Felix Fontein <felix@fontein.de>

* improve command used for retrieving releasever variable

Co-authored-by: Felix Fontein <felix@fontein.de>

* add basearch replace

* Add basearch to changelog fragment

* Check for releasever and basearch only when they are there

Co-authored-by: Felix Fontein <felix@fontein.de>
This commit is contained in:
Amin Vakil 2021-06-08 10:53:32 +04:30 committed by GitHub
commit 94a53adff1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 75 additions and 2 deletions

View file

@ -125,3 +125,61 @@
priority: 100
auto_import_keys: true
state: "present"
- name: add a repo by releasever
community.general.zypper_repository:
name: releaseverrepo
repo: http://download.opensuse.org/repositories/devel:/languages:/ruby/openSUSE_Leap_$releasever/
state: present
register: add_repo
- name: add a repo by releasever again
community.general.zypper_repository:
name: releaseverrepo
repo: http://download.opensuse.org/repositories/devel:/languages:/ruby/openSUSE_Leap_$releasever/
state: present
register: add_repo_again
- assert:
that:
- add_repo is changed
- add_repo_again is not changed
- name: remove added repo
community.general.zypper_repository:
repo: http://download.opensuse.org/repositories/devel:/languages:/ruby/openSUSE_Leap_{{ ansible_distribution_version }}/
state: absent
register: remove_repo
- assert:
that:
- remove_repo is changed
- name: add a repo by basearch
community.general.zypper_repository:
name: basearchrepo
repo: https://packagecloud.io/netdata/netdata/opensuse/13.2/$basearch
state: present
register: add_repo
- name: add a repo by basearch again
community.general.zypper_repository:
name: basearchrepo
repo: https://packagecloud.io/netdata/netdata/opensuse/13.2/$basearch
state: present
register: add_repo_again
- assert:
that:
- add_repo is changed
- add_repo_again is not changed
- name: remove added repo
community.general.zypper_repository:
repo: https://packagecloud.io/netdata/netdata/opensuse/13.2/x86_64
state: absent
register: remove_repo
- assert:
that:
- remove_repo is changed