Skip to content

Commit 7b56e1e

Browse files
Joshua TimbermanJoshua Timberman
authored andcommitted
Add apt proxy and cacher recipes
1 parent e3bb46c commit 7b56e1e

5 files changed

Lines changed: 279 additions & 0 deletions

File tree

‎apt/files/default/apt-cacher‎

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# apt-cacher startup configuration file
2+
3+
# IMPORTANT: check the apt-cacher.conf file before using apt-cacher as daemon.
4+
5+
# set to 1 to start the daemon at boot time
6+
AUTOSTART=1
7+
8+
# extra settings to override the ones in apt-cacher.conf
9+
# EXTRAOPT=" daemon_port=3142 limit=30 "

‎apt/files/default/apt-cacher.conf‎

Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
# This file has been modified by ./apt-proxy-to-apt-cacher
2+
# Some lines may have been appended at the bottom of this file
3+
# This file has been modified by /usr/share/apt-cacher/apt-proxy-to-apt-cacher
4+
# Some lines may have been appended at the bottom of this file
5+
#################################################################
6+
# This is the config file for apt-cacher. On most Debian systems
7+
# you can safely leave the defaults alone.
8+
#################################################################
9+
10+
# cache_dir is used to set the location of the local cache. This can
11+
# become quite large, so make sure it is somewhere with plenty of space.
12+
cache_dir=/var/cache/apt-cacher
13+
14+
# The email address of the administrator is displayed in the info page
15+
# and traffic reports.
16+
admin_email=root@localhost
17+
18+
# For the daemon startup settings please edit the file /etc/default/apt-cacher.
19+
20+
# Daemon port setting, only useful in stand-alone mode. You need to run the
21+
# daemon as root to use privileged ports (<1024).
22+
daemon_port = 8888
23+
24+
# optional settings, user and group to run the daemon as. Make sure they have
25+
# sufficient permissions on the cache and log directories. Comment the settings
26+
# to run apt-cacher as the native user.
27+
group=www-data
28+
user=www-data
29+
30+
# optional setting, binds the listening daemon to one specified IP. Use IP
31+
# ranges for more advanced configuration, see below.
32+
# daemon_addr=localhost
33+
34+
# If your apt-cacher machine is directly exposed to the Internet and you are
35+
# worried about unauthorised machines fetching packages through it, you can
36+
# specify a list of IPv4 addresses which are allowed to use it and another
37+
# list of IPv4 addresses which aren't.
38+
# Localhost (127.0.0.1) is always allowed. Other addresses must be matched
39+
# by allowed_hosts and not by denied_hosts to be permitted to use the cache.
40+
# Setting allowed_hosts to "*" means "allow all".
41+
# Otherwise the format is a comma-separated list containing addresses,
42+
# optionally with masks (like 10.0.0.0/22), or ranges of addresses (two
43+
# addresses separated by a hyphen, no masks, like '192.168.0.3-192.168.0.56').
44+
allowed_hosts=*
45+
denied_hosts=
46+
47+
# And similiarly for IPv6 with allowed_hosts_6 and denied_hosts_6.
48+
# Note that IPv4-mapped IPv6 addresses (::ffff:w.x.y.z) are truncated to
49+
# w.x.y.z and are handled as IPv4.
50+
allowed_hosts_6=fec0::/16
51+
denied_hosts_6=
52+
53+
# This thing can be done by Apache but is much simplier here - limit access to
54+
# Debian mirrors based on server names in the URLs
55+
#allowed_locations=ftp.uni-kl.de,ftp.nerim.net,debian.tu-bs.de
56+
57+
# Apt-cacher can generate usage reports every 24 hours if you set this
58+
# directive to 1. You can view the reports in a web browser by pointing
59+
# to your cache machine with '/apt-cacher/report' on the end, like this:
60+
# http://yourcache.example.com/apt-cacher/report
61+
# Generating reports is very fast even with many thousands of logfile
62+
# lines, so you can safely turn this on without creating much
63+
# additional system load.
64+
generate_reports=1
65+
66+
# Apt-cacher can clean up its cache directory every 24 hours if you set
67+
# this directive to 1. Cleaning the cache can take some time to run
68+
# (generally in the order of a few minutes) and removes all package
69+
# files that are not mentioned in any existing 'Packages' lists. This
70+
# has the effect of deleting packages that have been superseded by an
71+
# updated 'Packages' list.
72+
clean_cache=1
73+
74+
# The directory to use for apt-cacher access and error logs.
75+
# The access log records every request in the format:
76+
# date-time|client ip address|HIT/MISS/EXPIRED|object size|object name
77+
# The error log is slightly more free-form, and is also used for debug
78+
# messages if debug mode is turned on.
79+
# Note that the old 'logfile' and 'errorfile' directives are
80+
# deprecated: if you set them explicitly they will be honoured, but it's
81+
# better to just get rid of them from old config files.
82+
logdir=/var/log/apt-cacher
83+
84+
# apt-cacher can use different methods to decide whether package lists need to
85+
# be updated,
86+
# A) looking at the age of the cached files
87+
# B) getting HTTP header from server and comparing that with cached data. This
88+
# method is more reliable and avoids desynchronisation of data and index files
89+
# but needs to transfer few bytes from the server every time somebody requests
90+
# the files ("apt-get update")
91+
# Set the following value to the maximum age (in hours) for method A or to 0
92+
# for method B
93+
expire_hours=0
94+
95+
# Apt-cacher can pass all its requests to an external http proxy like
96+
# Squid, which could be very useful if you are using an ISP that blocks
97+
# port 80 and requires all web traffic to go through its proxy. The
98+
# format is 'hostname:port', eg: 'proxy.example.com:8080'.
99+
http_proxy=proxy.example.com:8080
100+
101+
# Use of an external proxy can be turned on or off with this flag.
102+
# Value should be either 0 (off) or 1 (on).
103+
use_proxy=0
104+
105+
# External http proxy sometimes need authentication to get full access. The
106+
# format is 'username:password'.
107+
http_proxy_auth=proxyuser:proxypass
108+
109+
# Use of external proxy authentication can be turned on or off with this flag.
110+
# Value should be either 0 (off) or 1 (on).
111+
use_proxy_auth=0
112+
113+
# Rate limiting sets the maximum bandwidth in bytes per second to use
114+
# for fetching packages. Syntax is fully defined in 'man wget'.
115+
# Use 'k' or 'm' to use kilobits or megabits / second: eg, 'limit=25k'.
116+
# Use 0 or a negative value for no rate limiting.
117+
limit=0
118+
119+
# Debug mode makes apt-cacher spew a lot of extra debug junk to the
120+
# error log (whose location is defined with the 'logdir' directive).
121+
# Leave this off unless you need it, or your error log will get very
122+
# big. Acceptable values are 0 or 1.
123+
debug=0
124+
125+
# Adapt the line in the usage info web page to match your server configuration
126+
# example_sources_line=deb&nbsp;http://<b>my.cacher.server:3142/</b>ftp.au.debian.org/debian&nbsp;unstable&nbsp;main&nbsp;contrib&nbsp;non-free
127+
128+
# Print a 410 (Gone) HTTP message with the specified text when accessed via
129+
# CGI. Useful to tell users to adapt their sources.list files when the
130+
# apt-cacher server is beeing relocated (via apt-get's error messages while
131+
# running "update")
132+
#cgi_advise_to_use = Please use http://cacheserver:3142/ as apt-cacher access URL
133+
#cgi_advise_to_use = Server relocated. To change sources.list, run perl -pe "s,/apt-cacher\??,:3142," -i /etc/apt/sources.list
134+
135+
# Server mapping - this allows to hide real server names behind virtual paths
136+
# that appear in the access URL. This method is known from apt-proxy. This is
137+
# also the only method to use FTP access to the target hosts. The syntax is simple, the part of the beginning to replace, followed by a list of mirror urls, all space separated. Multiple profile are separated by semicolons
138+
# path_map = debian ftp.uni-kl.de/pub/linux/debian ftp2.de.debian.org/debian ; ubuntu archive.ubuntu.com/ubuntu ; security security.debian.org/debian-security ftp2.de.debian.org/debian-security
139+
# Note that you need to specify all target servers in the allowed_locations
140+
# options if you make use of it. Also note that the paths should not overlap
141+
# each other. FTP access method not supported yet, maybe in the future.
142+
143+
# extra setting from apt-proxy configuration
144+
path_map = ubuntu us.archive.ubuntu.com/ubuntu ; ubuntu-security security.ubuntu.com/ubuntu ; debian debian.osuosl.org/debian/ ; security security.debian.org/debian-security
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
[DEFAULT]
2+
;; All times are in seconds, but you can add a suffix
3+
;; for minutes(m), hours(h) or days(d)
4+
5+
;; commented out address so apt-proxy will listen on all IPs
6+
;; address = 127.0.0.1
7+
port = 8888
8+
cache_dir = /var/cache/apt-proxy
9+
10+
;; Control files (Packages/Sources/Contents) refresh rate
11+
min_refresh_delay = 1s
12+
complete_clientless_downloads = 1
13+
14+
;; Debugging settings.
15+
debug = all:4 db:0
16+
17+
time = 30
18+
passive_ftp = on
19+
20+
;;--------------------------------------------------------------
21+
;; Cache housekeeping
22+
23+
cleanup_freq = 1d
24+
max_age = 120d
25+
max_versions = 3
26+
27+
;;---------------------------------------------------------------
28+
;; Backend servers
29+
;;
30+
;; Place each server in its own [section]
31+
32+
[ubuntu]
33+
; Ubuntu archive
34+
backends =
35+
http://us.archive.ubuntu.com/ubuntu
36+
37+
[ubuntu-security]
38+
; Ubuntu security updates
39+
backends = http://security.ubuntu.com/ubuntu
40+
41+
[debian]
42+
;; Backend servers, in order of preference
43+
backends =
44+
http://debian.osuosl.org/debian/
45+
46+
[security]
47+
;; Debian security archive
48+
backends =
49+
http://security.debian.org/debian-security
50+
http://ftp2.de.debian.org/debian-security

‎apt/recipes/cacher.rb‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#
2+
# Cookbook Name:: apt
3+
# Recipe:: cacher
4+
#
5+
# Copyright 2008, OpsCode, Inc.
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
package "apt-cacher" do
20+
action :install
21+
end
22+
23+
service "apt-cacher" do
24+
supports :restart => true
25+
action :enable
26+
end
27+
28+
remote_file "/etc/apt-cacher/apt-cacher.conf" do
29+
source "apt-cacher.conf"
30+
owner "root"
31+
group "root"
32+
mode 0644
33+
notifies :restart, resources(:service => "apt-cacher")
34+
end
35+
36+
remote_file "/etc/default/apt-cacher" do
37+
source "apt-cacher"
38+
owner "root"
39+
group "root"
40+
mode 0644
41+
notifies :restart, resources(:service => "apt-cacher")
42+
end

‎apt/recipes/proxy.rb‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
#
2+
# Cookbook Name:: apt
3+
# Recipe:: proxy
4+
#
5+
# Copyright 2008, OpsCode, Inc.
6+
#
7+
# Licensed under the Apache License, Version 2.0 (the "License");
8+
# you may not use this file except in compliance with the License.
9+
# You may obtain a copy of the License at
10+
#
11+
# http://www.apache.org/licenses/LICENSE-2.0
12+
#
13+
# Unless required by applicable law or agreed to in writing, software
14+
# distributed under the License is distributed on an "AS IS" BASIS,
15+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
# See the License for the specific language governing permissions and
17+
# limitations under the License.
18+
#
19+
package "apt-proxy" do
20+
action :install
21+
end
22+
23+
service "apt-proxy" do
24+
supports :restart => true
25+
action :enable
26+
end
27+
28+
remote_file "/etc/apt-proxy/apt-proxy-v2.conf" do
29+
source "apt-proxy-v2.conf"
30+
owner "root"
31+
group "root"
32+
mode 0644
33+
notifies :restart, resources(:service => "apt-proxy")
34+
end

0 commit comments

Comments
 (0)