Skip to content
This repository has been archived by the owner on Nov 23, 2017. It is now read-only.

Commit

Permalink
use apt-cacher-ng instead of apt-cacher. apt-cacher-ng works better w…
Browse files Browse the repository at this point in the history
…ith mixed Debian & Ubuntu repos and supposedly scales better
  • Loading branch information
mattray committed Feb 6, 2012
1 parent cc0551d commit 49ef086
Show file tree
Hide file tree
Showing 6 changed files with 27 additions and 192 deletions.
27 changes: 15 additions & 12 deletions apt/README.md
@@ -1,11 +1,15 @@
Description
===========

This cookbook includes recipes to execute apt-get update to ensure the local APT package cache is up to date or manage apt-cacher and cacher clients. It also includes a LWRP for managing APT repositories in /etc/apt/sources.list.d.
This cookbook includes recipes to execute apt-get update to ensure the local APT package cache is up to date. There are recipes for managing the apt-cacher-ng caching proxy and proxy clients. It also includes a LWRP for managing APT repositories in /etc/apt/sources.list.d.

Changes
=======

## v1.3.0:

* COOK-593: switched from apt-cacher to apt-cacher-ng to better support multiple distributions.

## v1.2.2:

* COOK-804: apt-get update resource in apt cookbook changed names
Expand All @@ -28,14 +32,14 @@ This recipe should appear first in the run list of Debian or Ubuntu nodes to ens

This recipe also sets up a local cache directory for preseeding packages.

cacher
------
cacher-ng
---------

Installs the apt-cacher package and service so the system can provide APT caching. You can check the usage report at http://{hostname}:3142/report. The cacher recipe includes the `cacher-client` recipe, so it helps seed itself.
Installs the `apt-cacher-ng` package and service so the system can provide APT caching. You can check the usage report at http://{hostname}:3142/acng-report.html. The `cacher-ng` recipe includes the `cacher-client` recipe, so it helps seed itself.

cacher-client
-------------
Configures the node to use the apt-cacher server as a client.
Configures the node to use the `apt-cacher-ng` server as a client.

Resources/Providers
===================
Expand Down Expand Up @@ -64,7 +68,7 @@ This LWRP provides an easy way to manage additional APT repositories. Adding a n
uri "http://dev.zenoss.org/deb"
components ["main","stable"]
end

# add the Nginx PPA; grab key from keyserver
apt_repository "nginx-php" do
uri "http://ppa.launchpad.net/nginx/php5/ubuntu"
Expand All @@ -73,20 +77,20 @@ This LWRP provides an easy way to manage additional APT repositories. Adding a n
keyserver "keyserver.ubuntu.com"
key "C300EE8C"
end

# add the Cloudkick Repo
apt_repository "cloudkick" do
uri "http://packages.cloudkick.com/ubuntu"
distribution node['lsb']['codename']
components ["main"]
key "http://packages.cloudkick.com/cloudkick.packages.key"
end

# remove Zenoss repo
apt_repository "zenoss" do
action :remove
end

Usage
=====

Expand All @@ -98,7 +102,7 @@ Put `recipe[apt]` first in the run list. If you have other recipes that you want

The above will run during execution phase since it is a normal template resource, and should appear before other package resources that need the sources in the template.

Put `recipe[apt::cacher]` in the run_list for a server to provide APT caching and add `recipe[apt::cacher-client]` on the rest of the Debian-based nodes to take advantage of the caching server.
Put `recipe[apt::cacher-ng]` in the run_list for a server to provide APT caching and add `recipe[apt::cacher-client]` on the rest of the Debian-based nodes to take advantage of the caching server.

License and Author
==================
Expand All @@ -107,7 +111,7 @@ Author:: Joshua Timberman (<joshua@opscode.com>)
Author:: Matt Ray (<matt@opscode.com>)
Author:: Seth Chisamore (<schisamo@opscode.com>)

Copyright 2009-2011 Opscode, Inc.
Copyright 2009-2012 Opscode, Inc.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
Expand All @@ -120,4 +124,3 @@ distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

9 changes: 0 additions & 9 deletions apt/files/default/apt-cacher

This file was deleted.

144 changes: 0 additions & 144 deletions apt/files/default/apt-cacher.conf

This file was deleted.

6 changes: 3 additions & 3 deletions apt/metadata.rb
Expand Up @@ -3,10 +3,10 @@
license "Apache 2.0"
description "Configures apt and apt services and an LWRP for managing apt repositories"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "1.2.2"
version "1.3.0"
recipe "apt", "Runs apt-get update during compile phase and sets up preseed directories"
recipe "apt::cacher", "Set up an APT cache"
recipe "apt::cacher-client", "Client for the apt::cacher server"
recipe "apt::cacher-ng", "Set up an apt-cacher-ng caching proxy"
recipe "apt::cacher-client", "Client for the apt::cacher-ng caching proxy"

%w{ ubuntu debian }.each do |os|
supports os
Expand Down
8 changes: 4 additions & 4 deletions apt/recipes/cacher-client.rb
Expand Up @@ -2,7 +2,7 @@
# Cookbook Name:: apt
# Recipe:: cacher-client
#
# Copyright 2011, Opscode, Inc.
# Copyright 2011, 2012 Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -33,11 +33,11 @@
servers << cacher
end
else
servers += search(:node, 'recipes:apt\:\:cacher')
servers += search(:node, 'recipes:apt\:\:cacher-ng')
end

if servers.length > 0
Chef::Log.info("apt-cacher server found on #{servers[0]}.")
Chef::Log.info("apt-cacher-ng server found on #{servers[0]}.")
proxy = "Acquire::http::Proxy \"http://#{servers[0].ipaddress}:3142\";\n"
file "/etc/apt/apt.conf.d/01proxy" do
owner "root"
Expand All @@ -47,7 +47,7 @@
action :create
end
else
Chef::Log.info("No apt-cacher server found.")
Chef::Log.info("No apt-cacher-ng server found.")
file "/etc/apt/apt.conf.d/01proxy" do
action :delete
only_if {File.exists?("/etc/apt/apt.conf.d/01proxy")}
Expand Down
25 changes: 5 additions & 20 deletions apt/recipes/cacher.rb → apt/recipes/cacher-ng.rb
@@ -1,8 +1,8 @@
#
# Cookbook Name:: apt
# Recipe:: cacher
# Recipe:: cacher-ng
#
# Copyright 2008-2011, Opscode, Inc.
# Copyright 2008-2012, Opscode, Inc.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
Expand All @@ -16,30 +16,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
package "apt-cacher" do

package "apt-cacher-ng" do
action :install
end

service "apt-cacher" do
service "apt-cacher-ng" do
supports :restart => true, :status => false
action [ :enable, :start ]
end

cookbook_file "/etc/apt-cacher/apt-cacher.conf" do
source "apt-cacher.conf"
owner "root"
group "root"
mode 0644
notifies :restart, resources(:service => "apt-cacher")
end

cookbook_file "/etc/default/apt-cacher" do
source "apt-cacher"
owner "root"
group "root"
mode 0644
notifies :restart, resources(:service => "apt-cacher")
end

#this will help seed the proxy
include_recipe "apt::cacher-client"

0 comments on commit 49ef086

Please sign in to comment.