# How to write the cookbook for third party ubuntu ppa?

**URL:** <https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042>\
**Category:** Chef Infra (archive)\
**Created:** [August 20, 2012, 7:09pm UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042 "2012-08-20T19:09:47Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![millisami\_r](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/millisami_r/32/418_2.png) [@millisami\_r](https://discourse.chef.io/u/millisami_r)\
**Post date:** [August 20, 2012, 7:09pm UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042/1 "2012-08-20T19:09:47Z")

</div>

Ohai!

I’m trying to write this ppa to install ruby 1.9.3.p-294 from the brightbox ppa at:

ppa:brightbox/ruby-ng

with both way, LWRP and template/execute resource one, neither works.  
When I run from the terminal on my ec2 server, it gets installed graciously.  
But why the chef-recipe way blows up every time.

# LWRP way

include\_recipe "apt"  
apt\_repository “brightbox-ruby-ng” do  
uri 'ppa:brightbox/ruby-ng’  
distribution node[‘lsb’][‘codename’]  
components [“main”]  
keyserver "[keyserver.ubuntu.com](http://keyserver.ubuntu.com)"  
key "C300EE8C"  
end  
package “ruby” do  
action :install  
end

# Template/Execute resource way

template “/etc/apt/sources.list.d/brightbox-ruby-ng-source.list” do  
source "brightbox-ruby-ng-source.list.erb"  
notifies :run, resources(:execute =\> “apt-get update”), :immediately  
end

package “ruby” do  
action :install  
end

package “rubygems” do  
action :install  
end

# And this is the content of the template file:

deb ppa:brightbox/ruby-ng precise main

Either way shows the same error:

[https://gist.github.com/3406875](https://gist.github.com/3406875)

* * *

@millisami  
~ Sachin Sagar Rai  
Ruby on Rails Developer  
[http://tfm.com.np](http://tfm.com.np)  
[http://nepalonrails.tumblr.com](http://nepalonrails.tumblr.com)  
Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

---

<div class="post-metadata">

**Author:** ![Kevin\_Nuckolls](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kevin_nuckolls/32/327_2.png) [@Kevin\_Nuckolls](https://discourse.chef.io/u/Kevin_Nuckolls)\
**Post date:** [August 20, 2012, 7:32pm UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042/2 "2012-08-20T19:32:36Z")

</div>

The URL you're looking for is the full one to the actual ppa that gets  
dropped in sources.conf.

I looked it up here for your case. Click on the technical details part.

> **[Brightbox Ruby NG : “Brightbox” team](https://launchpad.net/~brightbox/+archive/ubuntu/ruby-ng)**
>
> Ubuntu packages for Ruby 2.7, 2.6, 2.5, 2.4, 2.3, 2.2, 2.1, 2.0 1.9.3 and 1.8.
> 
> See https://www.brightbox.com/docs/ruby/ubuntu/ for more details.
> 
> Discussion list...

[http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu](http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu)

Hope that helps.  
-Kevin

On Mon, Aug 20, 2012 at 2:09 PM, Sachin Sagar Rai [millisami@gmail.com](mailto:millisami@gmail.com)wrote:

> Ohai!
> 
> I'm trying to write this ppa to install ruby 1.9.3.p-294 from the  
> brightbox ppa at:
> 
> ppa:brightbox/ruby-ng
> 
> with both way, LWRP and template/execute resource one, neither works.  
> When I run from the terminal on my ec2 server, it gets installed  
> graciously.  
> But why the chef-recipe way blows up every time.
> 
> # LWRP way
> 
> include\_recipe "apt"  
> apt\_repository "brightbox-ruby-ng" do  
> uri 'ppa:brightbox/ruby-ng'  
> distribution node['lsb']['codename']  
> components ["main"]  
> keyserver "[keyserver.ubuntu.com](http://keyserver.ubuntu.com)"  
> key "C300EE8C"  
> end  
> package "ruby" do  
> action :install  
> end
> 
> # Template/Execute resource way
> 
> template "/etc/apt/sources.list.d/brightbox-ruby-ng-source.list" do  
> source "brightbox-ruby-ng-source.list.erb"  
> notifies :run, resources(:execute =\> "apt-get update"), :immediately  
> end
> 
> package "ruby" do  
> action :install  
> end
> 
> package "rubygems" do  
> action :install  
> end
> 
> # And this is the content of the template file:
> 
> deb ppa:brightbox/ruby-ng precise main
> 
> Either way shows the same error:
> 
> [chef-client-log · GitHub](https://gist.github.com/3406875)
> 
> * * *
> 
> @millisami  
> ~ Sachin Sagar Rai  
> Ruby on Rails Developer  
> [http://tfm.com.np](http://tfm.com.np)  
> [http://nepalonrails.tumblr.com](http://nepalonrails.tumblr.com)  
> Sent with Sparrow [http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig)

---

<div class="post-metadata">

**Author:** ![millisami\_r](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/millisami_r/32/418_2.png) [@millisami\_r](https://discourse.chef.io/u/millisami_r)\
**Post date:** [August 21, 2012, 3:14pm UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042/3 "2012-08-21T15:14:33Z")

</div>

I've changed the uri as you suggested, but still it blows up:  
Following is the recipe:

include\_recipe "apt"

apt\_repository "brightbox-ruby-ng" do  
uri '[Index of /brightbox/ruby-ng/ubuntu](http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu)'  
distribution node['lsb']['codename']  
components ["main"]  
keyserver "[keyserver.ubuntu.com](http://keyserver.ubuntu.com)"  
key "C300EE8C"  
end

package "ruby" do  
action :install  
end

package "rubygems" do  
action :install  
end

I've even tried with:  
package "ruby1.9.3"

And this is the debug output:

[ec2-107-20-189-224.compute-1.amazonaws.com](http://ec2-107-20-189-224.compute-1.amazonaws.com) [Tue, 21 Aug 2012 14:33:42 +0000] ERROR: /opt/chef/embedded/lib/ruby/gems/1.9.1/gems/chef-10.12.0/bin/chef-client:26:in `<top (required)>' ec2-107-20-189-224.compute-1.amazonaws.com [Tue, 21 Aug 2012 14:33:42 +0000] ERROR: /usr/bin/chef-client:19:in `load'  
[ec2-107-20-189-224.compute-1.amazonaws.com](http://ec2-107-20-189-224.compute-1.amazonaws.com) [Tue, 21 Aug 2012 14:33:42 +0000] ERROR: /usr/bin/chef-client:19:in `'  
[ec2-107-20-189-224.compute-1.amazonaws.com](http://ec2-107-20-189-224.compute-1.amazonaws.com) [Tue, 21 Aug 2012 14:33:42 +0000] ERROR: Exception handlers complete  
[ec2-107-20-189-224.compute-1.amazonaws.com](http://ec2-107-20-189-224.compute-1.amazonaws.com) [Tue, 21 Aug 2012 14:33:42 +0000] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out  
[ec2-107-20-189-224.compute-1.amazonaws.com](http://ec2-107-20-189-224.compute-1.amazonaws.com) [Tue, 21 Aug 2012 14:33:42 +0000] FATAL: Chef::Exceptions::Exec: package[ruby] (base::install\_ruby line 22) had an error: Chef::Exceptions::Exec: apt-get -q -y install ruby=4.8-0bbox1 returned 100, expected 0

* * *

@millisami  
~ Sachin Sagar Rai  
Ruby on Rails Developer  
[http://tfm.com.np](http://tfm.com.np)  
[http://nepalonrails.tumblr.com](http://nepalonrails.tumblr.com)  
Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

On Tuesday, August 21, 2012 at 1:17 AM, Kevin Nuckolls wrote:

> The URL you're looking for is the full one to the actual ppa that gets dropped in sources.conf.
> 
> I looked it up here for your case. Click on the technical details part.  
> [Brightbox Ruby NG : “Brightbox” team](https://launchpad.net/~brightbox/+archive/ruby-ng)
> 
> [Index of /brightbox/ruby-ng/ubuntu](http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu)
> 
> Hope that helps.  
> -Kevin
> 
> On Mon, Aug 20, 2012 at 2:09 PM, Sachin Sagar Rai \<[millisami@gmail.com](mailto:millisami@gmail.com) ([mailto:millisami@gmail.com](mailto:millisami@gmail.com))\> wrote:
> 
> > Ohai!
> > 
> > I'm trying to write this ppa to install ruby 1.9.3.p-294 from the brightbox ppa at:
> > 
> > ppa:brightbox/ruby-ng
> > 
> > with both way, LWRP and template/execute resource one, neither works.  
> > When I run from the terminal on my ec2 server, it gets installed graciously.  
> > But why the chef-recipe way blows up every time.
> > 
> > # LWRP way
> > 
> > include\_recipe "apt"  
> > apt\_repository "brightbox-ruby-ng" do  
> > uri 'ppa:brightbox/ruby-ng'  
> > distribution node['lsb']['codename']  
> > components ["main"]  
> > keyserver "[keyserver.ubuntu.com](http://keyserver.ubuntu.com) ([http://keyserver.ubuntu.com](http://keyserver.ubuntu.com))"  
> > key "C300EE8C"  
> > end  
> > package "ruby" do  
> > action :install  
> > end
> > 
> > # Template/Execute resource way
> > 
> > template "/etc/apt/sources.list.d/brightbox-ruby-ng-source.list" do  
> > source "brightbox-ruby-ng-source.list.erb"  
> > notifies :run, resources(:execute =\> "apt-get update"), :immediately  
> > end
> > 
> > package "ruby" do  
> > action :install  
> > end
> > 
> > package "rubygems" do  
> > action :install  
> > end
> > 
> > # And this is the content of the template file:
> > 
> > deb ppa:brightbox/ruby-ng precise main
> > 
> > Either way shows the same error:
> > 
> > [chef-client-log · GitHub](https://gist.github.com/3406875)
> > 
> > * * *
> > 
> > @millisami  
> > ~ Sachin Sagar Rai  
> > Ruby on Rails Developer  
> > [http://tfm.com.np](http://tfm.com.np)  
> > [http://nepalonrails.tumblr.com](http://nepalonrails.tumblr.com)  
> > Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

---

<div class="post-metadata">

**Author:** ![Bryan\_McLellan](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/bryan_mclellan/32/81_2.png) [@Bryan\_McLellan](https://discourse.chef.io/u/Bryan_McLellan)\
**Post date:** [August 21, 2012, 3:36pm UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042/4 "2012-08-21T15:36:53Z")

</div>

On Tue, Aug 21, 2012 at 11:14 AM, Sachin Sagar Rai [millisami@gmail.com](mailto:millisami@gmail.com) wrote:

> FATAL: Chef::Exceptions::Exec: package[ruby] (base::install\_ruby line 22)  
> had an error: Chef::Exceptions::Exec: apt-get -q -y install ruby=4.8-0bbox1  
> returned 100, expected 0

It looks like apt is failing for some reason.

What happens if you run "apt-get -q -y install ruby=4.8-0bbox1"?

Bryan

---

<div class="post-metadata">

**Author:** ![Kevin\_Nuckolls](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kevin_nuckolls/32/327_2.png) [@Kevin\_Nuckolls](https://discourse.chef.io/u/Kevin_Nuckolls)\
**Post date:** [August 21, 2012, 9:50pm UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042/5 "2012-08-21T21:50:00Z")

</div>

I've encountered this problem as well and I'm nearly certain that a  
background process is running apt-get update by default when you start up  
the Ubuntu image. My solution was to tell cloud-init not to run apt-get  
update by default. These 100 errors no longer come up.

Read this. [CloudInit - Community Help Wiki](https://help.ubuntu.com/community/CloudInit)

Set apt\_upgrade: false in your user data script.

Hope that helps.

Bryan I bet that command you asked him to run will run because it's a race  
condition. By the time you log in to the Ubuntu box and run it, the  
background cloud-init is done and other systems can run apt just fine.

-Kevin

On Tuesday, August 21, 2012, Bryan McLellan wrote:

> On Tue, Aug 21, 2012 at 11:14 AM, Sachin Sagar Rai \<[millisami@gmail.com](mailto:millisami@gmail.com)\<javascript:;\>\>  
> wrote:
> 
> > FATAL: Chef::Exceptions::Exec: package[ruby] (base::install\_ruby line 22)  
> > had an error: Chef::Exceptions::Exec: apt-get -q -y install  
> > ruby=4.8-0bbox1  
> > returned 100, expected 0
> 
> It looks like apt is failing for some reason.
> 
> What happens if you run "apt-get -q -y install ruby=4.8-0bbox1"?
> 
> Bryan

---

<div class="post-metadata">

**Author:** ![millisami\_r](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/millisami_r/32/418_2.png) [@millisami\_r](https://discourse.chef.io/u/millisami_r)\
**Post date:** [August 22, 2012, 8:05am UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042/6 "2012-08-22T08:05:53Z")

</div>

@kevin, In which user script do i've to put that

> apt\_upgrade: false attribute? Is it some cookbook or role?

Via Millisami'z iPhone

On Aug 22, 2012, at 3:35 AM, Kevin Nuckolls [kevin.nuckolls@gmail.com](mailto:kevin.nuckolls@gmail.com) wrote:

> I've encountered this problem as well and I'm nearly certain that a background process is running apt-get update by default when you start up the Ubuntu image. My solution was to tell cloud-init not to run apt-get update by default. These 100 errors no longer come up.
> 
> Read this. [CloudInit - Community Help Wiki](https://help.ubuntu.com/community/CloudInit)
> 
> Set apt\_upgrade: false in your user data script.
> 
> Hope that helps.
> 
> Bryan I bet that command you asked him to run will run because it's a race condition. By the time you log in to the Ubuntu box and run it, the background cloud-init is done and other systems can run apt just fine.
> 
> -Kevin
> 
> On Tuesday, August 21, 2012, Bryan McLellan wrote:  
> On Tue, Aug 21, 2012 at 11:14 AM, Sachin Sagar Rai [millisami@gmail.com](mailto:millisami@gmail.com) wrote:
> 
> > FATAL: Chef::Exceptions::Exec: package[ruby] (base::install\_ruby line 22)  
> > had an error: Chef::Exceptions::Exec: apt-get -q -y install ruby=4.8-0bbox1  
> > returned 100, expected 0
> 
> It looks like apt is failing for some reason.
> 
> What happens if you run "apt-get -q -y install ruby=4.8-0bbox1"?
> 
> Bryan

---

<div class="post-metadata">

**Author:** ![Kevin\_Nuckolls](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/kevin_nuckolls/32/327_2.png) [@Kevin\_Nuckolls](https://discourse.chef.io/u/Kevin_Nuckolls)\
**Post date:** [August 22, 2012, 2:01pm UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042/7 "2012-08-22T14:01:26Z")

</div>

On EC2 or Eucalyptus you have the ability to upload what they call  
"user-data" that the ubuntu images know how to pull down and use as a bit  
of configuration information. When using the knife-ec2 plugin I pass in an  
executable bash script with the --user-data parameter.

If you're not using one of those clouds, something similar may be available  
for what you're using. You can also just go into your base system image and  
turn off cloud-init completely. It defaults to being on, and defaults to  
running apt-get update which in some cases will conflict with the initial  
chef bootstrap.

Hope that helps!  
-Kevin

On Wed, Aug 22, 2012 at 3:05 AM, Millisi [millisami@gmail.com](mailto:millisami@gmail.com) wrote:

> @kevin, In which user script do i've to put that
> 
> apt\_upgrade: false attribute? Is it some cookbook or role?
> 
> Via Millisami'z iPhone
> 
> On Aug 22, 2012, at 3:35 AM, Kevin Nuckolls [kevin.nuckolls@gmail.com](mailto:kevin.nuckolls@gmail.com)  
> wrote:
> 
> I've encountered this problem as well and I'm nearly certain that a  
> background process is running apt-get update by default when you start up  
> the Ubuntu image. My solution was to tell cloud-init not to run apt-get  
> update by default. These 100 errors no longer come up.
> 
> Read this. [CloudInit - Community Help Wiki](https://help.ubuntu.com/community/CloudInit)
> 
> Set apt\_upgrade: false in your user data script.
> 
> Hope that helps.
> 
> Bryan I bet that command you asked him to run will run because it's a race  
> condition. By the time you log in to the Ubuntu box and run it, the  
> background cloud-init is done and other systems can run apt just fine.
> 
> -Kevin
> 
> On Tuesday, August 21, 2012, Bryan McLellan wrote:
> 
> > On Tue, Aug 21, 2012 at 11:14 AM, Sachin Sagar Rai [millisami@gmail.com](mailto:millisami@gmail.com)  
> > wrote:
> > 
> > > FATAL: Chef::Exceptions::Exec: package[ruby] (base::install\_ruby line
> > 
> > 1. 
> > 
> > > had an error: Chef::Exceptions::Exec: apt-get -q -y install  
> > > ruby=4.8-0bbox1  
> > > returned 100, expected 0
> > 
> > It looks like apt is failing for some reason.
> > 
> > What happens if you run "apt-get -q -y install ruby=4.8-0bbox1"?
> > 
> > Bryan

---

<div class="post-metadata">

**Author:** ![Brian\_Akins](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/brian_akins/32/298_2.png) [@Brian\_Akins](https://discourse.chef.io/u/Brian_Akins)\
**Post date:** [August 24, 2012, 1:06am UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042/8 "2012-08-24T01:06:50Z")

</div>

On Wed, Aug 22, 2012 at 10:01 AM, Kevin Nuckolls  
[kevin.nuckolls@gmail.com](mailto:kevin.nuckolls@gmail.com) wrote:

> When using the knife-ec2 plugin I pass in an  
> executable bash script with the --user-data parameter.

We wrote a hacky knife plugin that passes in the bootstrap script via  
user\_data. No need for ssh for bootstrap.

---

<div class="post-metadata">

**Author:** ![millisami\_r](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/millisami_r/32/418_2.png) [@millisami\_r](https://discourse.chef.io/u/millisami_r)\
**Post date:** [August 24, 2012, 10:20am UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042/9 "2012-08-24T10:20:08Z")

</div>

Kevin, can u share it? N how to use?

Via Millisami'z iPhone

On Aug 24, 2012, at 6:51 AM, Brian Akins [brian@akins.org](mailto:brian@akins.org) wrote:

> On Wed, Aug 22, 2012 at 10:01 AM, Kevin Nuckolls  
> [kevin.nuckolls@gmail.com](mailto:kevin.nuckolls@gmail.com) wrote:
> 
> > When using the knife-ec2 plugin I pass in an  
> > executable bash script with the --user-data parameter.
> 
> We wrote a hacky knife plugin that passes in the bootstrap script via  
> user\_data. No need for ssh for bootstrap.

---

<div class="post-metadata">

**Author:** ![millisami\_r](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/millisami_r/32/418_2.png) [@millisami\_r](https://discourse.chef.io/u/millisami_r)\
**Post date:** [August 24, 2012, 3:21pm UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042/10 "2012-08-24T15:21:27Z")

</div>

@Kevin, can you gist your shell script and its usage?

* * *

@millisami  
~ Sachin Sagar Rai  
Ruby on Rails Developer  
[http://tfm.com.np](http://tfm.com.np)  
[http://nepalonrails.tumblr.com](http://nepalonrails.tumblr.com)  
Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

On Friday, August 24, 2012 at 4:05 PM, Millisi wrote:

> Kevin, can u share it? N how to use?
> 
> Via Millisami'z iPhone
> 
> On Aug 24, 2012, at 6:51 AM, Brian Akins \<[brian@akins.org](mailto:brian@akins.org) ([mailto:brian@akins.org](mailto:brian@akins.org))\> wrote:
> 
> > On Wed, Aug 22, 2012 at 10:01 AM, Kevin Nuckolls  
> > \<[kevin.nuckolls@gmail.com](mailto:kevin.nuckolls@gmail.com) ([mailto:kevin.nuckolls@gmail.com](mailto:kevin.nuckolls@gmail.com))\> wrote:
> > 
> > > When using the knife-ec2 plugin I pass in an  
> > > executable bash script with the --user-data parameter.
> > 
> > We wrote a hacky knife plugin that passes in the bootstrap script via  
> > user\_data. No need for ssh for bootstrap.

---

<div class="post-metadata">

**Author:** ![ringods](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ringods/32/154_2.png) [@ringods](https://discourse.chef.io/u/ringods)\
**Post date:** [August 28, 2012, 8:47am UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042/11 "2012-08-28T08:47:09Z")

</div>

Sachin,

On 21 August 2012 17:14, Sachin Sagar Rai [millisami@gmail.com](mailto:millisami@gmail.com) wrote:

> I've changed the uri as you suggested, but still it blows up:  
> Following is the recipe:
> 
> include\_recipe "apt"
> 
> apt\_repository "brightbox-ruby-ng" do  
> uri '[Index of /brightbox/ruby-ng/ubuntu](http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu)'  
> distribution node['lsb']['codename']  
> components ["main"]  
> keyserver "[keyserver.ubuntu.com](http://keyserver.ubuntu.com)"  
> key "C300EE8C"  
> end

What would you do if you add a new repository to your sources list  
manually? Right, you would run "apt-get update".

So just after your Chef snippet of apt\_repository, add this:

execute "apt-get update" do  
action :run  
end

Works for me.

Ringo

---

<div class="post-metadata">

**Author:** ![millisami\_r](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/millisami_r/32/418_2.png) [@millisami\_r](https://discourse.chef.io/u/millisami_r)\
**Post date:** [August 28, 2012, 4:31pm UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042/12 "2012-08-28T16:31:57Z")

</div>

Hi Ringo,  
Due to many trials, couldn't get that working. So, just went the old school way with `execute ...` resource.

But I'd like to do it the LWRP way. Can you also post your `apt_repository ....` block code as well!

I'd appreciate that.

* * *

@millisami  
~ Sachin Sagar Rai  
Ruby on Rails Developer  
[http://tfm.com.np](http://tfm.com.np)  
[http://nepalonrails.tumblr.com](http://nepalonrails.tumblr.com)  
Sent with Sparrow ([http://www.sparrowmailapp.com/?sig](http://www.sparrowmailapp.com/?sig))

On Tuesday, August 28, 2012 at 2:32 PM, Ringo De Smet wrote:

> Sachin,
> 
> On 21 August 2012 17:14, Sachin Sagar Rai \<[millisami@gmail.com](mailto:millisami@gmail.com) ([mailto:millisami@gmail.com](mailto:millisami@gmail.com))\> wrote:
> 
> > I've changed the uri as you suggested, but still it blows up:  
> > Following is the recipe:
> > 
> > include\_recipe "apt"
> > 
> > apt\_repository "brightbox-ruby-ng" do  
> > uri '[Index of /brightbox/ruby-ng/ubuntu](http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu)'  
> > distribution node['lsb']['codename']  
> > components ["main"]  
> > keyserver "[keyserver.ubuntu.com](http://keyserver.ubuntu.com) ([http://keyserver.ubuntu.com](http://keyserver.ubuntu.com))"  
> > key "C300EE8C"  
> > end
> 
> What would you do if you add a new repository to your sources list manually? Right, you would run "apt-get update".
> 
> So just after your Chef snippet of apt\_repository, add this:
> 
> execute "apt-get update" do  
> action :run  
> end
> 
> Works for me.
> 
> Ringo

---

<div class="post-metadata">

**Author:** ![ringods](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.chef.io/ringods/32/154_2.png) [@ringods](https://discourse.chef.io/u/ringods)\
**Post date:** [August 29, 2012, 6:23am UTC](https://discourse.chef.io/t/how-to-write-the-cookbook-for-third-party-ubuntu-ppa/3042/13 "2012-08-29T06:23:26Z")

</div>

Sachin,

On 28 August 2012 18:31, Sachin Sagar Rai [millisami@gmail.com](mailto:millisami@gmail.com) wrote:

> Hi Ringo,  
> Due to many trials, couldn't get that working. So, just went the old  
> school way with `execute ...` resource.
> 
> But I'd like to do it the LWRP way. Can you also post your `apt_repository ....` block code as well!
> 
> I'd appreciate that.

My apt\_repository block looks similar to yours, only pointing to the  
Mercurial PPA:

--- BEGIN ---

# add the Mercurial PPA; grab key from keyserverapt\_repository

"mercurial-ppa" do uri  
"[Index of /mercurial-ppa/releases/ubuntu](http://ppa.launchpad.net/mercurial-ppa/releases/ubuntu)" distribution  
node['lsb']['codename'] components ["main"] keyserver  
"[keyserver.ubuntu.com](http://keyserver.ubuntu.com)" key "323293EE" action :addendexecute "apt-get  
update" do action :runend

--- END ---

I do have to note though that this piece of code works for me with an older  
version of the apt cookbook. I haven't really tested with the latest  
version including that apt update timestamp functionality.

Hope this helps.

Ringo
