Skip to content

Commit 3a829f2

Browse files
committed
Fix, system.repo don't use curl if not needed
- fixed pkgrepo.manage to use/prefer key_url for salt >= 2017.7 - updated syntax for key verificatoin - fix, avoid curl for salt:// schema (as in #156) Change-Id: I1b50c287a4030a9cefa1b819017d59cc5fb1c197
1 parent 4a23e4d commit 3a829f2

File tree

1 file changed

+14
-5
lines changed

1 file changed

+14
-5
lines changed

linux/system/repo.sls

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -83,21 +83,27 @@ linux_repo_{{ name }}_key:
8383
cmd.run:
8484
- name: |
8585
echo "{{ repo.key | indent(12) }}" | apt-key add -
86-
- unless: |
87-
apt-key finger --with-colons | grep -qF $(echo "{{ repo.key| indent(12) }}" | gpg --with-fingerprint --with-colons | grep -E '^fpr')
8886
- require_in:
8987
{%- if repo.get('default', False) %}
9088
- file: default_repo_list
9189
{% else %}
9290
- pkgrepo: linux_repo_{{ name }}
9391
{% endif %}
9492
95-
{%- elif repo.key_url|default(False) %}
93+
{# key_url fetch by curl when salt <2017.7, higher version of salt has fixed bug for using a proxy_host/port specified at minion.conf #}
94+
{#
95+
NOTE: curl/cmd.run usage to fetch gpg key has limited functionality behind proxy. Environments with salt >= 2017.7 should use
96+
key_url specified at pkgrepo.manage state (which uses properly configured http_host at minion.conf). Older versions of
97+
salt require to have proxy set at ENV and curl way to fetch gpg key here can have a sense for backward compatibility.
98+
99+
Be aware that as of salt 2018.3 no_proxy option is not implemented at all.
100+
#}
101+
{%- elif repo.key_url|default(False) and grains['saltversioninfo'] < [2017, 7] and not repo.key_url.startswith('salt://') %}
102+
96103
97104
linux_repo_{{ name }}_key:
98105
cmd.run:
99-
- name: "curl -sL {{ repo.key_url }} | apt-key add -"
100-
- unless: "apt-key finger --with-colons | grep -qF $(curl -sL {{ repo.key_url }} | gpg --with-fingerprint --with-colons | grep -E '^fpr')"
106+
- name: "curl -sL '{{ repo.key_url }}' | apt-key add -"
101107
- require_in:
102108
{%- if repo.get('default', False) %}
103109
- file: default_repo_list
@@ -132,6 +138,9 @@ linux_repo_{{ name }}:
132138
{%- if repo.key_server is defined %}
133139
- keyserver: {{ repo.key_server }}
134140
{%- endif %}
141+
{%- if repo.key_url is defined and (grains['saltversioninfo'] >= [2017, 7] or repo.key_url.startswith('salt://')) %}
142+
- key_url: {{ repo.key_url }}
143+
{%- endif %}
135144
- consolidate: {{ repo.get('consolidate', False) }}
136145
- clean_file: {{ repo.get('clean_file', False) }}
137146
- refresh_db: {{ repo.get('refresh_db', True) }}

0 commit comments

Comments
 (0)