4

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.

Mojo
  • 955
  • 2
  • 9
  • 24
  • What if you set an explicit version of the package using `version` attribute? Could you please also post `chef-client` execution log somewhere? – Alex Aug 08 '12 at 16:32
  • When I tried that before, I got a "version not found" error. I'll try it again and post the pertinent portion of the chef-client debug log. – Mojo Aug 08 '12 at 17:33
  • You should try to execute `apt-get update` on the node manually I guess. `apt` cookbook does not always do that in right times, I often have problems with it. – Alex Aug 08 '12 at 17:37
  • Please also provide the ruby, chef, apt cookbook versions for further debugging. – Mike Fiedler Aug 08 '12 at 17:48
  • ruby: 1.9.3-p125, chef: 0.10.8. apt: 1.2.0 – Mojo Aug 08 '12 at 20:29
  • 1
    Doing an `apt-get update` manually on the machine was revealing. The varnish repo doesn't have a "main" component, but does have the component "varnish-3.0". You can see that's what I used in the recipe above, but an earlier run using "main" had already been recorded in the sources.list.d file. ... Now "apt-get udpate" runs without errors. But that doesn't solve the problem ... – Mojo Aug 08 '12 at 20:36
  • 1
    This is the section of the Chef log related to installing the varnish repository and varnish 3.0 package: https://gist.github.com/3298601 – Mojo Aug 08 '12 at 20:44
  • 1
    Here's what I've discovered so far, not using chef, but doing manual apt-gets: If the repo line is appended to /etc/apt/sources.list then apt-get update includes the varnish repo and updates to 3.0.2-lucid. However with only a varnish-3.0-source.list file in /etc/apt/sources.list.d apt-get does not see any newer versions than 2.1. – Mojo Aug 08 '12 at 21:16
  • 2
    Looks like cookbooks/apt version 1.4.0 (latest from git) solved this problem. I'll post an answer tomorrow (when I can). – Mojo Aug 08 '12 at 21:30
  • apt cookbook version 1.4.4 is the latest version available on community.opscode.com, it was released Jul 12, 2012 – jtimberman Aug 09 '12 at 18:10

2 Answers2

2

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:

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 "varnish-cache.org.gpg-key.txt"
  deb_src true
  action :add
end

package "varnish" do
  source "http://repo.varnish-cache.org/ubuntu/"
  version "3.0.2-1~1lucid1"
  options "--force-yes"
  action :install
end

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.

Mojo
  • 955
  • 2
  • 9
  • 24
0

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.)

gWaldo
  • 11,957
  • 8
  • 42
  • 69