How to write the cookbook for third party ubuntu ppa?


#1

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"
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


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


#2

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.
https://launchpad.net/~brightbox/+archive/ruby-ng

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.comwrote:

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"
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


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


#3

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 'http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu
distribution node[‘lsb’][‘codename’]
components [“main”]
keyserver "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 [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:inload’
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 [Tue, 21 Aug 2012 14:33:42 +0000] ERROR: Exception handlers complete
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 [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://nepalonrails.tumblr.com
Sent with Sparrow (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.
https://launchpad.net/~brightbox/+archive/ruby-ng

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:

https://gist.github.com/3406875


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


#4

On Tue, Aug 21, 2012 at 11:14 AM, Sachin Sagar Rai 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


#5

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


#6

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


#7

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 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
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. 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
wrote:

FATAL: Chef::Exceptions::Exec: package[ruby] (base::install_ruby line

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


#8

On Wed, Aug 22, 2012 at 10:01 AM, Kevin Nuckolls
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.


#9

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 wrote:

On Wed, Aug 22, 2012 at 10:01 AM, Kevin Nuckolls
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.


#10

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


@millisami
~ Sachin Sagar Rai
Ruby on Rails Developer
http://tfm.com.np
http://nepalonrails.tumblr.com
Sent with Sparrow (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)> 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.


#11

Sachin,

On 21 August 2012 17:14, Sachin Sagar Rai 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 'http://ppa.launchpad.net/brightbox/ruby-ng/ubuntu
distribution node[‘lsb’][‘codename’]
components [“main”]
keyserver "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


#12

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://nepalonrails.tumblr.com
Sent with Sparrow (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)> 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 '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


#13

Sachin,

On 28 August 2012 18:31, Sachin Sagar Rai 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
"http://ppa.launchpad.net/mercurial-ppa/releases/ubuntu" distribution
node[‘lsb’][‘codename’] components [“main”] keyserver
"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