Skip to content

Commit 2893b0d

Browse files
authored
Merge pull request #38 from ze42/apt_conf
apt.conf.d
2 parents 35cf2e0 + de05ac6 commit 2893b0d

File tree

4 files changed

+92
-1
lines changed

4 files changed

+92
-1
lines changed

apt/apt_conf.sls

+36
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
{% from "apt/map.jinja" import apt as apt_map with context %}
2+
{% set remove_apt_conf = salt['pillar.get']('apt:remove_apt_conf', apt_map.remove_apt_conf) %}
3+
{% set confd_dir = salt['pillar.get']('apt:confd_dir', apt_map.confd_dir) %}
4+
{% set clean_apt_conf_d = salt['pillar.get']('apt:clean_apt_conf_d', apt_map.clean_apt_conf_d) %}
5+
{% set apt_conf_d = salt['pillar.get']('apt:apt_conf_d', apt_map.apt_conf_d) %}
6+
7+
/etc/apt/apt.conf:
8+
file.managed:
9+
- mode: '0644'
10+
- user: root
11+
- group: root
12+
{% if remove_apt_conf %}
13+
- contents: ''
14+
- contents_newline: False
15+
{% else %}
16+
- replace: False
17+
{% endif %}
18+
19+
{{ confd_dir }}:
20+
file.directory:
21+
- mode: 755
22+
- user: root
23+
- group: root
24+
- clean: {{ clean_apt_conf_d }}
25+
26+
{% for file, contents in apt_conf_d|dictsort %}
27+
{{ confd_dir }}/{{ file }}:
28+
file.managed:
29+
- source: salt://apt/templates/apt_conf.jinja
30+
- template: jinja
31+
- user: root
32+
- group: root
33+
- mode: 644
34+
- context:
35+
data: {{ contents }}
36+
{% endfor %}

apt/map.jinja

+4-1
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
'preferences': {},
1515
'remove_preferences': false,
1616
'clean_preferences_d': false,
17+
'remove_apt_conf': false,
18+
'clean_apt_conf_d': false,
19+
'apt_conf_d': {},
1720
'default_keyserver': 'pool.sks-keyservers.net',
1821
'default_url': 'http://deb.debian.org/debian/',
1922
'default_keyring_package': 'debian-archive-keyring',
@@ -30,6 +33,6 @@
3033
'arch': arch,
3134
'comps': ['main'],
3235
},
33-
},
36+
},
3437
},
3538
}, merge=salt['pillar.get']('apt:lookup'), default='Debian') %}

apt/templates/apt_conf.jinja

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{%- macro print(mname, mvalue) %}
2+
{%- if mvalue is string %}
3+
{{ mname }} "{{ mvalue }}";
4+
{%- elif mvalue is sequence %}
5+
{{ mname }} {
6+
{%- for item in mvalue %}
7+
"{{ item }}";
8+
{%- endfor %}
9+
};
10+
{%- endif %}
11+
{%- endmacro -%}
12+
// This file is managed by salt
13+
{%- for opt, opt_data in data|dictsort -%}
14+
{%- if opt_data is string %}
15+
{{ opt }} "{{ opt_data }}";
16+
{%- elif opt_data is mapping %}
17+
{{ opt }}
18+
{
19+
{%- for name, value in opt_data|dictsort %}
20+
{{- print(name, value) }}
21+
{%- endfor %}
22+
};
23+
{%- elif opt_data is sequence %}
24+
{{ opt }} {
25+
{%- for item in opt_data %}
26+
"{{ item }}";
27+
{%- endfor %}
28+
};
29+
{%- endif %}
30+
{%- endfor -%}

pillar.example

+22
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,28 @@ apt:
88
remove_preferences: true
99
clean_preferences_d: true
1010

11+
apt_conf_d:
12+
30release:
13+
'APT::Default-Release': stable
14+
'40dpkg-options':
15+
'Dpkg::Options':
16+
- '--force-confdef'
17+
- '--force-confold'
18+
60proxy:
19+
'Acquire::ftp':
20+
Proxy: "ftp://127.0.0.1/"
21+
'Proxy::http.us.debian.org': DIRECT
22+
ProxyLogin:
23+
- "USER $(PROXY_USER)"
24+
- "PASS $(PROXY_PASS)"
25+
- "USER $(SITE_USER)@$(SITE):$(SITE_PORT)"
26+
- "PASS $(SITE_PASS)"
27+
DSelect:
28+
Clean: auto
29+
Options: -f
30+
UpdateOptions: ""
31+
PromptAfterUpdate: "no"
32+
1133
unattended:
1234
allowed_origins:
1335
- origin1

0 commit comments

Comments
 (0)