From 3de3ac23bb67171b5737e51516c09700589c4b8f Mon Sep 17 00:00:00 2001 From: root Date: Thu, 4 Sep 2014 13:18:34 +0900 Subject: [PATCH] Add support pillar attr for apt-cacher --- apt-cacher/files/apt-cacher.conf | 10 +++++++--- apt-cacher/map.jinja | 7 +++++++ pillar.example | 4 ++++ 3 files changed, 18 insertions(+), 3 deletions(-) create mode 100644 apt-cacher/map.jinja diff --git a/apt-cacher/files/apt-cacher.conf b/apt-cacher/files/apt-cacher.conf index 0381db1..574e093 100644 --- a/apt-cacher/files/apt-cacher.conf +++ b/apt-cacher/files/apt-cacher.conf @@ -1,5 +1,6 @@ +# vim:sts=2 ts=2 sw=2 et ai +{% from "apt-cacher/map.jinja" import apt_cacher with context %} # This file is managed by Salt, do not edit by hand!! -{% set apt_cacher = pillar.get('apt-cacher', {}) -%} ################################################################################# # This is the config file for apt-cacher. On most Debian systems you can safely # # leave the defaults alone. # @@ -42,8 +43,8 @@ admin_email = {{ apt_cacher.get('admin_email', 'root@localhost') }} # sufficient permissions within the cache and log directories. Comment the # settings to run apt-cacher as the invoking user. # -group = www-data -user = www-data +group = {{ apt_cacher.get('group', 'www-data') }} +user = {{ apt_cacher.get('user', 'www-data') }} # optional setting, binds the listening daemon to specified IP(s). # @@ -112,6 +113,9 @@ user = www-data # Specify an interface name, an IP address or a host name. # If unset, the default route is used. # +{%- if apt_cacher.get('interface', 'False') != 'False' %} +interface = {{ apt_cacher.get('interface', 'False') }} +{%- endif %} #interface = eth0 # Rate limiting sets the maximum bandwidth in bytes per second to use for diff --git a/apt-cacher/map.jinja b/apt-cacher/map.jinja new file mode 100644 index 0000000..2c179f5 --- /dev/null +++ b/apt-cacher/map.jinja @@ -0,0 +1,7 @@ +{% set apt_cacher = salt['grains.filter_by']({ + 'Debian': { + 'group': 'www-data', + 'user': 'www-data', + 'interface': 'False' + }, +}, merge=salt['pillar.get']('apt_cacher')) %} diff --git a/pillar.example b/pillar.example index 51e55b6..597b68d 100644 --- a/pillar.example +++ b/pillar.example @@ -1,6 +1,10 @@ apt_cacher: host: cacher.mycompany.com admin_email: admin@mycompany.com + group: www-data + user: www-data + #ip for upstream connection + interface: 10.10.0.1 apt_cacher_ng: # Setting up server_address is the minimal configuration requirement.