Puppet module for apt-cacher-ng
Puppet Ruby
Pull request Compare This branch is 25 commits ahead, 2 commits behind tryphon:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



A Puppet module for apt-cacher-ng, with a Vagrantfile for quick deployment on Vagrant.

Original author: Alban Peignier

Maintainer of this fork: Garth Kidd

Other contributors:

Installation in Production

  • Clone the module into your /etc/puppet/modules directory:

    cd /etc/puppet/modules
    git clone git://github.com/garthk/puppet-apt-cacher-ng apt-cacher-ng
  • Edit the definition for your server to include apt-cacher-ng, perhaps specifying version:

      class { 'apt-cacher-ng':
        # version => '0.4.6-1ubuntu1',

    The server will be available at the default port (3142).

    The server will not use itself as a cache by default.

  • Edit the definition for your clients to include apt-cacher-ng::client:

    class { 'apt-cacher-ng::client':
      server  => "",
  • To specify more than one server:

    class { 'apt-cacher-ng::client':
      servers => ["", ""],
  • To disable fallback to direct access if the proxy is not available:

    class { 'apt-cacher-ng::client':
      autodetect => false,
      server     => "",

    Per askubuntu:54099, you'll need to do this on older Ubuntu and Debian releases. Lucid and Squeeze support Acquire::http::ProxyAutoDetect; Karmic and Lenny don't.

Providing an apt cache for your Vagrant virtual machines

To install apt-cacher-ng on a fresh box in Vagrant:

vagrant up aptcache

The Vagrantfile specifies a box named aptcache providing its service from You should be able to browse to it from your host OS to manage it.

Using the apt cache

To configure your own Vagrant box to access the aptcache box:

  • Configure your VM for host-only networking, by adding the following line to your Vagrantfile:

      config.vm.network :hostonly, ""

    (Change the final octet (2) to make sure it's unique on your machine. Don't use 1: it'll probably be used by your host OS for its vboxnet0 adapter.)

  • Inside your box, create /etc/apt/apt.conf.d/71proxy with the line:

    Acquire::http { Proxy ""; };

    If you're using Puppet Provisioning, put this in your manifest_file, e.g. my_manifest.pp:

    file { "/etc/apt/apt.conf.d/71proxy": 
      owner   => root,
      group   => root,
      mode    => '0644',
      content => 'Acquire::http { Proxy ""; };',

    You could also install the Puppet module and use apt-cacher-ng::client as above.


To perform a smoke test:

make smoke

To smoke test both the module and the Vagrantfile's manifest_file:

make test

To test the module properly, install Vagrant and:

make vm