Using apt cookbook to add PPA


#1

All -

I am trying to re-write a recipe to use the apt_repository resource to add a PPA on Ubuntu so that I can install a newer version of Subversion.

Originally I had this code in my recipe:

Get the add-apt-repository command

execute “install add-apt-repository” do
command "sudo apt-get install python-software-properties -y"
end

Add ppa to make version 1.7+ of Subversion available

execute “add-apt-repository” do
command "sudo add-apt-repository ppa:dominik-stadler/subversion-1.7"
end

apt-get update to bring in the ppa contents

execute “apt-get update” do
command "sudo apt-get update"
end

apt-get install subversion

package “subversion” do
action :install
end

Brute-force, but effective.

Now I’d like to switch to using apt_repository, like so:

Use apt_repository cookbook to add PPA for Subversion 1.7

apt_repository “#{node[‘subversion’][‘subversion_ppa’]}” do
uri node[‘subversion’][‘subversion_ppa’]
distribution node[‘subversion’][‘ubuntu_version’]
components [“main”]
# keyserver “keyserver.ubuntu.com
# key "29E526FC"
action :add
end

apt-get install subversion

package “subversion” do
action :install
end

Where these attributes:

default[‘subversion’][‘subversion_ppa’] = "http://ppa.launchpad.net/dominik-stadler/subversion-1.7/ubuntu"
default[‘subversion’][‘ubuntu_version’] = “precise”

When I run vagrant up I get the following error:

Chef:: Exceptions:: EnclosingDirectoryDoesNotExist

Parent directory /etc/apt/sources.list.d/http://ppa.launchpad.net/dominik-stadler/subversion-1.7 does not exist

I’ve tried specifying the PPA address like this: ppa:dominik-stadler/subversion-1.7, with a similar unsuccessful result.

I hate to revert to the brute-force code I had before. What am I missing with apt_repository? /etc/apt/sources.list is on the VM, so I’m at a loss as to what “enclosing directory” is missing.

Thanks,
Mark


#2

On Thursday, June 27, 2013 at 17:44, Mark H. Nichols wrote:

Instead of this line:

apt_repository “#{node[‘subversion’][‘subversion_ppa’]}” do

Give your resource a filesystem-friendly name, like

apt_repository “subversion-ppa” do

The provider uses the “name” attribute for the filename of the PPA .list file, so in this case it will create /etc/apt/sources.list.d/subversion-ppa.list.

  • cassiano

#3

Cassiano -
On Jun 27, 2013, at 4:37 PM, Cassiano Leal cassianoleal@gmail.com wrote:

On Thursday, June 27, 2013 at 17:44, Mark H. Nichols wrote:

Instead of this line:

apt_repository “#{node[‘subversion’][‘subversion_ppa’]}” do
Give your resource a filesystem-friendly name, like

apt_repository “subversion-ppa” do

The provider uses the “name” attribute for the filename of the PPA .list file, so in this case it will create /etc/apt/sources.list.d/subversion-ppa.list.

Thank you, that did the trick.

– Mark