Adoptable Cookbooks List

Looking for a cookbook to adopt? You can now see a list of cookbooks available for adoption!
List of Adoptable Cookbooks

Supermarket Belongs to the Community

Supermarket belongs to the community. While Chef has the responsibility to keep it running and be stewards of its functionality, what it does and how it works is driven by the community. The chef/supermarket repository will continue to be where development of the Supermarket application takes place. Come be part of shaping the direction of Supermarket by opening issues and pull requests or by joining us on the Chef Mailing List.

Select Badges

Select Supported Platforms


apt-repo (3) Versions 0.1.1

Add repositories to APT sources

cookbook 'apt-repo', '= 0.1.1'
cookbook 'apt-repo', '= 0.1.1', :supermarket
knife supermarket install apt-repo
knife supermarket download apt-repo
Quality -%


Set up APT repositories for Debian.


chef-apt-repo lets you manage apt repositories with Chef.

Simple example

To add an apt source for a PPA named "foobar/quux" just do this:

ppa "foobar/quux"

To add a repo for a package named "foobar" when using chef-apt-repo, you might do something like this in your chef recipes:

apt_repo "foobar" do
  key_package "foobar-debian-keyring"
  url ""

This would add a file called foobar.list containing a deb line with the specified URL to your /etc/apt/sources.list.d and install the package foobar-debian-keyring (which is assumed to contain the GPG keys used to sign the packages in this repo).

Obtaining GPG keys from a keyserver

Of course you shouldn't just install random keyrings so it might be a better idea to actually get the key you want from a keyserver before installing the key package:

apt_repo "foobar" do
  key_package "foobar-debian-keyring"
  url ""
  key_id "8BADF00D"
  keyserver "" # defaults to

You could also omit the key_package completely, but if there is a key package it's usually a good idea to install it, since your apt keyring is always up-to-date that way.

Downloading GPG keys via HTTP

In case you prefer to get your keys via HTTP instead of a keyserver, you can do so by specifying a key_url in addition to the key_id:

apt_repo "foobar" do
  key_id "8BADF00D"
  key_url ""
  url ""

(You still need the key id because it is used in order to determine whether the key is already installed.)

Specifying distribution and components

The commands above don't specify a distribution or a list of components, so distribution defaults to the current distribution's LSB codename (for example "lucid" or "squeeze"), while components defaults to the "main" component.

If you want to specify a different distribution or components or enable source packages, you can do so by adding the corresponding definitions:

apt_repo "foobar" do
  key_id "8BADF00D"
  key_package "foobar-debian-keyring"
  url ""
  distribution "foobar-stable"
  components ["free", "non-free"]
  source_packages true

This would roughly correspond to something like this:

cat > /etc/apt/sources.list.d/foobar.list <<EOF
deb foobar-stable free non-free
deb-src foobar-stable free non-free
apt-key adv --keyserver --recv-keys 8BADF00D
aptitude update
aptitude install foobar-debian-keyring

Real world examples

If you are interested in seeing some simple recipes that use chef-apt-repo you might want to have a peek into the recipes directory.

Why chef-apt-repo?

chef-apt-repo predates similar functionality in Opscode's apt cookbook.

While I have no plans to deprecate this cookbook just yet, I have been working with the Opscode team to add some missing features to their cookbook.

If you are starting a new project, I would suggest that you use the Opscode cookbook instead of this one.

Copyright (c) 2010-2011 Sebastian Boehm. See LICENSE for details.

No quality metric results found