Help:Using debs in labs

From Wikitech
Jump to navigation Jump to search


Template:Deprecated

Please use Aptly for new projects!

How to use .deb packages in labs

Warning Warning: This process only works on precise

When the package already exists

When you wish to install a package from the main Ubuntu repository, just ask puppet to install it and it will get the current version. For example, to install memcached:

 package { “memcached”:
   ensure => present;
 }

That’s all!

When installing a non-standard package

There are a number of reasons you might need to pull in a package that is not in the mainline Ubuntu repository:

  • you need a newer version than exists in the Ubuntu repo
  • you need a package that exists on a different repository
  • you are creating your own package

In all of these cases, we want to make the package available to your project within labs before pushing the package into the production repository (thereby making it available to production servers as well as labs).

NOTE: The repository created by this class does not have priority over the other repositories. If there are newer versions of the package available in other repos, it may not choose your version. Most of the time this isn't a problem because we're working with newer versions of packages. If the version you expect isn't getting installed, run apt-cache policy <pkg-name> to ask apt to show you how it's interpreting the priority rules. For more info on how to force specific package versions, look up 'Apt Pinning'.

Overview

The basic steps in this process are:

  • include the puppet class to use the repository
  • run puppet
  • copy your package into the project’s shared storage
  • write puppet rules for the packages like you normally would
  • run puppet twice

include the puppet class to use the repository

In the labsconsole section controlling what puppet classes are applied to your hosts, in the 'building' group, include the ‘labs_debrepo’ class. This class will:

  • include /data/project/repo in /etc/apt/sources.list.d/
  • makes /data/project/repo/ and turns it into a debian repository (it'll be empty, but that's ok.)

run puppet

Run puppet on an instance to trigger the repo creation class

copy your package into the project’s shared storage

$ cp *.deb /data/project/repo/

Note that since all hosts in your project share the storage in /data/project/, you only need to do this step on one instance in your project. After that, all instances in your project that have the labs_debrepo puppet class enabled will have access to the packages.

write puppet rules for the packages like you normally would

Follow the first section of this doc: When the package already exists. If you're just installing a newer version of an existing package, this step has already been done.

run puppet twice

Now that the packages are in the repo directory, running puppet will update the repository listing to be aware of the packages you placed in the directory. The second puppet run will have access to those packages (and puppet statements like ensure => latest will upgrade the package).