Skip to content

Commit

Permalink
fix(pkgrepo/suse/install): avoid managing repo if it already exists
Browse files Browse the repository at this point in the history
Use ugly `zypper lr --uri` hack to get around failure if the `base_url`
already exists under a different name:

```
      ID: salt-pkgrepo-install-saltstack-suse
Function: pkgrepo.managed
    Name: systemsmanagement_saltstack_products
  Result: False
 Comment: Failed to configure repo 'systemsmanagement_saltstack_products':
          Repository 'systemsmanagement_saltstack_products' already exists as 'systemsmanagement_saltstack'.
 Started: 09:28:39.154054
Duration: 2760.727 ms
```

Upstream code:

* https://github.com/saltstack/salt/blob/45cc49daed1618dbe89e1f012128c8dcab00b356/salt/modules/zypperpkg.py#L1262-L1265
  • Loading branch information
myii committed Jan 29, 2021
1 parent 6aeaa5a commit d5320a3
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions salt/pkgrepo/suse/install.sls
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
# vim: ft=sls
{% from "salt/map.jinja" import salt_settings with context %}
{#- Resorting to this ugly hack since the state doesn't handle if the `baseurl` is
already configured under another name, such as used by the `salt-bootstrap` #}
{%- if not salt["cmd.run"]("zypper lr --uri | grep " ~ salt_settings.pkgrepo) %}
salt-pkgrepo-install-saltstack-suse:
pkgrepo.managed:
- name: systemsmanagement_saltstack_products
Expand All @@ -11,3 +14,4 @@ salt-pkgrepo-install-saltstack-suse:
- gpgcheck: 1
- gpgkey: {{ salt_settings.key_url }}
- gpgautoimport: true
{%- endif %}

0 comments on commit d5320a3

Please sign in to comment.