Browse Source

Merge pull request #38 from ze42/apt_conf

apt.conf.d
master
Niels Abspoel 6 years ago
parent
commit
2893b0dc39
No account linked to committer's email address
4 changed files with 92 additions and 1 deletions
  1. +36
    -0
      apt/apt_conf.sls
  2. +4
    -1
      apt/map.jinja
  3. +30
    -0
      apt/templates/apt_conf.jinja
  4. +22
    -0
      pillar.example

+ 36
- 0
apt/apt_conf.sls View File

{% from "apt/map.jinja" import apt as apt_map with context %}
{% set remove_apt_conf = salt['pillar.get']('apt:remove_apt_conf', apt_map.remove_apt_conf) %}
{% set confd_dir = salt['pillar.get']('apt:confd_dir', apt_map.confd_dir) %}
{% set clean_apt_conf_d = salt['pillar.get']('apt:clean_apt_conf_d', apt_map.clean_apt_conf_d) %}
{% set apt_conf_d = salt['pillar.get']('apt:apt_conf_d', apt_map.apt_conf_d) %}

/etc/apt/apt.conf:
file.managed:
- mode: '0644'
- user: root
- group: root
{% if remove_apt_conf %}
- contents: ''
- contents_newline: False
{% else %}
- replace: False
{% endif %}

{{ confd_dir }}:
file.directory:
- mode: 755
- user: root
- group: root
- clean: {{ clean_apt_conf_d }}

{% for file, contents in apt_conf_d|dictsort %}
{{ confd_dir }}/{{ file }}:
file.managed:
- source: salt://apt/templates/apt_conf.jinja
- template: jinja
- user: root
- group: root
- mode: 644
- context:
data: {{ contents }}
{% endfor %}

+ 4
- 1
apt/map.jinja View File

'preferences': {}, 'preferences': {},
'remove_preferences': false, 'remove_preferences': false,
'clean_preferences_d': false, 'clean_preferences_d': false,
'remove_apt_conf': false,
'clean_apt_conf_d': false,
'apt_conf_d': {},
'default_keyserver': 'pool.sks-keyservers.net', 'default_keyserver': 'pool.sks-keyservers.net',
'default_url': 'http://deb.debian.org/debian/', 'default_url': 'http://deb.debian.org/debian/',
'default_keyring_package': 'debian-archive-keyring', 'default_keyring_package': 'debian-archive-keyring',
'arch': arch, 'arch': arch,
'comps': ['main'], 'comps': ['main'],
}, },
},
},
}, },
}, merge=salt['pillar.get']('apt:lookup'), default='Debian') %} }, merge=salt['pillar.get']('apt:lookup'), default='Debian') %}

+ 30
- 0
apt/templates/apt_conf.jinja View File

{%- macro print(mname, mvalue) %}
{%- if mvalue is string %}
{{ mname }} "{{ mvalue }}";
{%- elif mvalue is sequence %}
{{ mname }} {
{%- for item in mvalue %}
"{{ item }}";
{%- endfor %}
};
{%- endif %}
{%- endmacro -%}
// This file is managed by salt
{%- for opt, opt_data in data|dictsort -%}
{%- if opt_data is string %}
{{ opt }} "{{ opt_data }}";
{%- elif opt_data is mapping %}
{{ opt }}
{
{%- for name, value in opt_data|dictsort %}
{{- print(name, value) }}
{%- endfor %}
};
{%- elif opt_data is sequence %}
{{ opt }} {
{%- for item in opt_data %}
"{{ item }}";
{%- endfor %}
};
{%- endif %}
{%- endfor -%}

+ 22
- 0
pillar.example View File

remove_preferences: true remove_preferences: true
clean_preferences_d: true clean_preferences_d: true


apt_conf_d:
30release:
'APT::Default-Release': stable
'40dpkg-options':
'Dpkg::Options':
- '--force-confdef'
- '--force-confold'
60proxy:
'Acquire::ftp':
Proxy: "ftp://127.0.0.1/"
'Proxy::http.us.debian.org': DIRECT
ProxyLogin:
- "USER $(PROXY_USER)"
- "PASS $(PROXY_PASS)"
- "USER $(SITE_USER)@$(SITE):$(SITE_PORT)"
- "PASS $(SITE_PASS)"
DSelect:
Clean: auto
Options: -f
UpdateOptions: ""
PromptAfterUpdate: "no"

unattended: unattended:
allowed_origins: allowed_origins:
- origin1 - origin1

Loading…
Cancel
Save