Yum install from URL

Hi,

How can I run the following command using a recipe?

yum install -y
http://www.rabbitmq.com/releases/rabbitmq-server/v3.0.1/rabbitmq-server-3.0.1-1.noarch.rpm

Thanks,
Jordi

Hi Jordi!

try this:

package "rabbit" do
source "http://www.rabbitmq.com/releases/rabbitmq-server/v3.0.1/rabbitmq-server-3.0.1-1.noarch.rpm"
action :install
provider Chef::Provider::package::Rpm
end

-s

On Sun, Jan 6, 2013 at 4:47 PM, Jordi Llonch llonchj@gmail.com wrote:

Hi,

How can I run the following command using a recipe?

yum install -y
http://www.rabbitmq.com/releases/rabbitmq-server/v3.0.1/rabbitmq-server-3.0.1-1.noarch.rpm

Thanks,
Jordi

I would urge caution in the use of this. Depending on 3rd party /
non-yum repo sources will cause cookbooks to completely fail if the 3rd
party source has gone away or is offline for a bit. I know it's caused
me more than a few headaches in the past.

You could put the RPM in the cookbook but that's possibly a little ugly,
depending on the size of it. Alternatively you could keep a copy on
your own server to fetch from. An added advantage of this is you know
exactly what is being installed on your servers.

I've got something based on this in one of our recipes:

 remote_file 

"#{Chef::Config[:file_cache_path]}/check_mk-agent-#{version}.noarch.rpm" do
source
"https://foo.bar.baz/checkmk/check_mk-agent-#{version}.noarch.rpm"
not_if "rpm -qa | grep -q '^check_mk-agent-#{version}'"
notifies :install, "rpm_package[check_mk]", :immediately
end

 rpm_package "check_mk" do
   source 

"#{Chef::Config[:file_cache_path]}/check_mk-agent-#{version}.noarch.rpm"
only_if
{::File.exists?("#{Chef::Config[:file_cache_path]}/check_mk-agent-#{version}.noarch.rpm")}
action :nothing
end

It occurs to me that maybe the latter isn't such a smart idea. I'm not
sure what Chef does underneath it all, but if there are dependencies
then using RPM will probably fail. Thinking possibly better to
substitute the 2nd block with this (and adjust the notifies in the 1st
block). According to docs.opscode.com specifying "source" in the
yum_package resource will cause it to do "yum localinstall"

 yum_package "check_mk" do
   source 

"#{Chef::Config[:file_cache_path]}/check_mk-agent-#{version}.noarch.rpm"
only_if
{::File.exists?("#{Chef::Config[:file_cache_path]}/check_mk-agent-#{version}.noarch.rpm")}
action :nothing
end

Paul

On 01/06/2013 12:00 PM, Sean OMeara wrote:

Hi Jordi!

try this:

package "rabbit" do
source "http://www.rabbitmq.com/releases/rabbitmq-server/v3.0.1/rabbitmq-server-3.0.1-1.noarch.rpm"
action :install
provider Chef::Provider::package::Rpm
end

-s

On Sun, Jan 6, 2013 at 4:47 PM, Jordi Llonch llonchj@gmail.com wrote:

Hi,

How can I run the following command using a recipe?

yum install -y
http://www.rabbitmq.com/releases/rabbitmq-server/v3.0.1/rabbitmq-server-3.0.1-1.noarch.rpm

Thanks,
Jordi

Hi Jordi,

package "rabbit" do
source "http://www.rabbitmq.com/releases/rabbitmq-server/v3.0.1/rabbitmq-server-3.0.1-1.noarch.rpm"
action :install
provider Chef::Provider::package::Rpm
end

You can also add some checking to Sean's code to prevent it from
running on another platform (debian based for instance):

case node[:platform]
when "redhat","centos","fedora","scientific"
package "rabbit" do
action :install
source "http://www.rabbitmq.com/releases/rabbitmq-server/v3.0.1/rabbitmq-server-3.0.1-1.noarch.rpm"
provider Chef::Provider::package::Rpm
not_if "test -f /usr/sbin/rabbitmq-server"
end
end

regards,

Thank you all for the reply!

2013/1/7 O. T. Suarez otsuarez@gmail.com

package "rabbit" do
action :install
source "
http://www.rabbitmq.com/releases/rabbitmq-server/v3.0.1/rabbitmq-server-3.0.1-1.noarch.rpm
"
provider Chef::Provider::package::Rpm
not_if "test -f /usr/sbin/rabbitmq-server"
end