Here's my problem. I want Varnish 3.0, but Lucid only has the 2.1 package available.
So using Chef, I need to make an install recipe that adds the varnish-cache.org repository to the apt sources and installs the varnish-3.0 package.
(I have the option of building it from source (right?), but if I do, I won't get the /etc/init.d scripts (right?)).
So I'm writing an apt_install.rb recipe which presumably adds the repository:
apt_repository "varnish-3.0" do
uri "http://repo.varnish-cache.org/ubuntu/"
repo_name "varnish-3.0"
distribution "lucid"
components ["varnish-3.0"]
key "http://repo.varnish-cache.org/debian/GPG-key.txt"
deb_src true
action :add
end
And indeed this adds a varnish-3.0-source.list in /etc/apt/sources.list.d which says:
# Created by the Chef apt_repository LWRP
deb http://repo.varnish-cache.org/ubuntu/ lucid main
Then I have
package "varnish" do
source "http://repo.varnish-cache.org/ubuntu/"
action :install
end
which proceeds to install version 2.1 on my server, not 3.0.
If I specify a "version" in the package block, I get "version not found".
What am I missing here? It must be something simple.
My biggest problem was an old version of the apt cookbook. Even so, the Varnish distribution names are a little unusual. Here's my config:
The repository key is included as a cookbook file.
When running this recipe on top of an existing Varnish 2.3 installation, the first chef-client run fails when trying to deal with apt's upgraded config file dialogs. In my instance the second chef-client runs cleaning and correctly.
I think that the method that the OP answered is the right way.
However, if that is not acceptable for one reason or another, the other thing that you could have done is to create your own .deb package from the source code.
Personally, rather than using every package managers different flavors of Crazy, I use Jordan Sissel's FPM. FPM makes it pretty trivially easy to make different flavors of package, and the documentation walks you through concrete examples, such as Use Case - Package something that uses 'make install'.
(Personal Note: This was an excellent use for Vagrant.)