Browse Source

Add initial support for apt conf management

- Add template file
- Add pillar example
master
devster31 8 years ago
parent
commit
9850446c2c
4 changed files with 76 additions and 0 deletions
  1. +23
    -0
      apt/conf.sls
  2. +1
    -0
      apt/map.jinja
  3. +30
    -0
      apt/templates/conf.jinja
  4. +22
    -0
      pillar.example

+ 23
- 0
apt/conf.sls View File

@@ -0,0 +1,23 @@
{% from "apt/map.jinja" import apt as apt_map with context %}
{% set confd_dir = salt['pillar.get']('apt:confd_dir', apt_map.confd_dir) %}
{% set clean_conf_d = salt['pillar.get']('apt:clean_conf_d', apt_map.clean_conf_d) %}
{% set apt_conf = salt['pillar.get']('apt:conf', apt_map.conf) %}

{{ confd_dir }}:
file.directory:
- mode: '0755'
- user: root
- group: root
- clean: {{ clean_conf_d }}

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

+ 1
- 0
apt/map.jinja View File

@@ -14,6 +14,7 @@
'preferences': {},
'remove_preferences': false,
'clean_preferences_d': false,
'clean_conf_d': false,
'default_keyserver': 'pool.sks-keyservers.net',
'default_url': 'http://deb.debian.org/debian/',
'default_keyring_package': 'debian-archive-keyring',

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

@@ -0,0 +1,30 @@
{%- 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

@@ -8,6 +8,28 @@ apt:
remove_preferences: true
clean_preferences_d: true

conf:
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:
allowed_origins:
- origin1

Loading…
Cancel
Save