ansible-collections / community.general

Ansible Community General Collection
https://galaxy.ansible.com/ui/repo/published/community/general/
GNU General Public License v3.0
811 stars 1.49k forks source link

zypper_repository: Add option to add multiple repo urls #4701

Open kristofkessler opened 2 years ago

kristofkessler commented 2 years ago

Summary

I want to add more than one baseurl to a repository configuration to have a fallback repository-url in case the first one fails.

This SUSE Knowledgebase entry describes what I want to accomplish: https://www.suse.com/support/kb/doc/?id=000019926

I tried:

- { name: 'openSUSE-Leap-15.3-Devel-Tools-Building' , repo: 'https://rsync.opensuse.org/repositories/devel:/tools/15.3 https://download.opensuse.org/repositories/devel:/tools/15.3' }

which results in:

baseurl=https://rsync.opensuse.org/repositories/devel:/tools/15.3%20https://download.opensuse.org/repositories/devel:/tools/15.3

The blank space between the urls is url encoded, which makes sense as only one url is expected in repo and could be necessary in other url cases. So at the moment I can only do this via workarounds and replace %20 with a blank by looping through the repo configuration files.

Issue Type

Feature Idea

Component Name

community.general.zypper_repository

Additional Information

Would it be possible to add a feature in which repo can either hold a string or an array of strings. If it has an array of strings, then for each of the strings a line with "baseurl = repo_url" is written into the repo configuration file?

It could work like this:

defining a zypper repository with repo containing an array of strings:

- block:
  - name: Setup zypper repos (OpenSUSE 15.3 development)
    zypper_repository:
      name: "{{ item.name }}"
      repo: "{{ item.repo }}"
      priority: 90
      runrefresh: no
      disable_gpg_check: yes
    loop:
      - { name: 'openSUSE-Leap-15.3-Devel-Tools-Building' , repo: ['https://rsync.opensuse.org/repositories/devel:/tools/15.3 ', 'https://download.opensuse.org/repositories/devel:/tools/15.3'] }

resulting /etc/zypp/repos.d/openSUSE-Leap-15.3-Devel-Tools-Building.repo

[openSUSE-Leap-15.3-Devel-Tools-Building]
enabled=1
autorefresh=1
baseurl=https://rsync.opensuse.org/repositories/devel:/tools/15.3
baseurl=https://download.opensuse.org/repositories/devel:/tools/15.3
priority=90
gpgcheck=0

Code of Conduct

ansibullbot commented 2 years ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help

ansibullbot commented 2 years ago

cc @AnderEnder @alxgu @andytom @commel @dcermak @evrardjp @lrupp @sealor @toabctl click here for bot help

ansibullbot commented 1 year ago

Files identified in the description:

If these files are incorrect, please update the component name section of the description or use the !component bot command.

click here for bot help