diff --git a/states/apt/10proxy.j2 b/states/apt/10proxy.j2 deleted file mode 100644 index 00f6880..0000000 --- a/states/apt/10proxy.j2 +++ /dev/null @@ -1,3 +0,0 @@ -{%- if salt['pillar.get']('apt-proxy:name') != "None" %} -Acquire::http { proxy "http://{{salt['pillar.get']('apt-proxy:name')}}:{{ salt['pillar.get']('apt-proxy:port')}}" } -{%- endif %} \ No newline at end of file diff --git a/states/apt/defaults.yaml b/states/apt/defaults.yaml new file mode 100644 index 0000000..c645290 --- /dev/null +++ b/states/apt/defaults.yaml @@ -0,0 +1,13 @@ +--- +apt: + config: {} + +# apt: +# config: +# 10proxy: +# content: +# - Acquire::http::Proxy "http://proxy:8000"; +# - Acquire::https::Proxy "DIRECT"; +# 99unauth: +# content: +# - APT::Get::AllowUnauthenticated "true"; diff --git a/states/apt/init.sls b/states/apt/init.sls index 311dbf3..8303f8c 100644 --- a/states/apt/init.sls +++ b/states/apt/init.sls @@ -1,28 +1,11 @@ --- -apt-unauth: - file.append: - - name: /etc/apt/apt.conf.d/99-unauth - - text: 'APT::Get::AllowUnauthenticated "true";' - -apt-aptitude-install: - pkg.latest: - - pkgs: - - aptitude - - apt-transport-https -# -# apt-upgrade: -# pkg.uptodate: -# - refresh: true -# -#apt-cacher-ng-proxy: -# file.managed: -# - name: /etc/apt/apt.conf.d/10proxy -# - source: salt://apt/10proxy.j2 -# - user: root -# - group: root -# - mode: 0644 -# - template: jinja -# -# apt-cacher-ng-proxy-delete: -# file.absent: -# - name: /etc/apt/apt.conf.d/10proxy \ No newline at end of file +{%- from "apt/map.jinja" import apt with context %} +{% for k, v in apt.config.items() -%} +apt-proxy-{{ k }}: + file.managed: + - name: /etc/apt/apt.conf.d/{{ k }} + - user: root + - group: root + - mode: 0644 + - contents: {{ v.content }} +{% endfor -%} \ No newline at end of file diff --git a/states/apt/map.jinja b/states/apt/map.jinja new file mode 100644 index 0000000..e98f8ad --- /dev/null +++ b/states/apt/map.jinja @@ -0,0 +1,5 @@ +{%- import_yaml "apt/defaults.yaml" as default_settings %} + +{%- set defaults = salt['grains.filter_by'](default_settings, default='apt') %} + +{%- set apt = salt['pillar.get']('apt', default=defaults, merge=True) %}