1 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
2 : Copyright (c) 2017 Mirantis Inc., Enea AB and others.
4 : All rights reserved. This program and the accompanying materials
5 : are made available under the terms of the Apache License, Version 2.0
6 : which accompanies this distribution, and is available at
7 : http://www.apache.org/licenses/LICENSE-2.0
8 ::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
9 From: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
10 Date: Mon, 22 Jan 2018 00:28:09 +0100
11 Subject: [PATCH] system.repo: Debian: Add keyserver proxy support
13 Introduce a new, optional set of parameters to configure the proxy
14 used for key fetching / keyserver access under:
15 linux:system:proxy:keyserver:http(s).
17 Previously, when fetching GPG keys for APT keyring, either using
18 public key download & import (as for default repos) or via keyserver,
19 we relied on simple `curl` calls or passed it down to Salt aptpkg
21 To be able to retrieve APT keys behind a proxy, one used to have to
22 configure the proxy for the Salt minion, which does not yet have
23 `no_proxy` support (either *all* or *no* traffic hits the proxy).
25 When the new http(s) proxy param is set:
26 - no longer pass key configuration to Salt aptpkg (until it properly
28 - handle all keys explicitly with `curl` and `apt-key`;
29 - set 'http(s)_proxy' env vars for `cmd.run`/`cmd.wait` calls;
31 If linux:system:proxy:keyserver is not defined, the behavior is
32 unchanged for backwards compatibility.
34 Signed-off-by: Alexandru Avadanii <Alexandru.Avadanii@enea.com>
36 README.rst | 16 ++++++++++++++++
37 linux/system/repo.sls | 40 ++++++++++++++++++++++++++++++++++++++++
38 2 files changed, 56 insertions(+)
40 diff --git a/linux/system/repo.sls b/linux/system/repo.sls
41 index 5d4d059..724db5a 100644
42 --- a/linux/system/repo.sls
43 +++ b/linux/system/repo.sls
44 @@ -96,13 +96,50 @@ linux_repo_{{ name }}_key:
45 - name: "curl -s {{ repo.key_url }} | apt-key add -"
47 - file: default_repo_list
48 +{%- if system.proxy.keyserver is defined %}
50 + - http_proxy: {{ system.proxy.get('keyserver', {}).get('http', '') }}
51 + - https_proxy: {{ system.proxy.get('keyserver', {}).get('https', '') }}
56 +{#- repo.default is false #}
59 {%- if repo.get('enabled', True) %}
61 +{%- if system.proxy.keyserver is defined %}
63 +{%- if repo.get('key') %}
65 +linux_repo_{{ name }}_key:
67 + - name: "echo '{{ repo.key }}' | apt-key add -"
69 +{%- elif repo.key_url|default(False) %}
71 +linux_repo_{{ name }}_key:
73 + - name: "curl -s {{ repo.key_url }} | apt-key add -"
75 + - http_proxy: {{ system.proxy.get('keyserver', {}).get('http', '') }}
76 + - https_proxy: {{ system.proxy.get('keyserver', {}).get('https', '') }}
78 +{%- elif repo.key_id is defined and repo.key_server is defined %}
80 +linux_repo_{{ name }}_key:
82 + - name: "apt-key adv --keyserver {{ repo.key_server }} --recv {{ repo.key_id }}"
84 + - http_proxy: {{ system.proxy.get('keyserver', {}).get('http', '') }}
85 + - https_proxy: {{ system.proxy.get('keyserver', {}).get('https', '') }}
89 +{#- system.proxy.keyserver #}
92 linux_repo_{{ name }}:
94 {%- if repo.ppa is defined %}
95 @@ -115,6 +152,7 @@ linux_repo_{{ name }}:
97 - file: /etc/apt/sources.list.d/{{ name }}.list
98 - clean_file: {{ repo.clean|default(True) }}
99 + {%- if system.proxy.keyserver is not defined %}
100 {%- if repo.key_id is defined %}
101 - keyid: {{ repo.key_id }}
103 @@ -124,6 +162,7 @@ linux_repo_{{ name }}:
104 {%- if repo.key_url is defined %}
105 - key_url: {{ repo.key_url }}
108 - consolidate: {{ repo.get('consolidate', False) }}
109 - clean_file: {{ repo.get('clean_file', False) }}
110 - refresh_db: {{ repo.get('refresh_db', True) }}
111 @@ -140,6 +179,7 @@ linux_repo_{{ name }}:
115 +{#- repo.enabled is false #}
118 linux_repo_{{ name }}_absent: