Skip to content

Instantly share code, notes, and snippets.

@thommay
Created March 1, 2011 17:25
Show Gist options
  • Select an option

  • Save thommay/849511 to your computer and use it in GitHub Desktop.

Select an option

Save thommay/849511 to your computer and use it in GitHub Desktop.
ruby_block "get rabbit version" do
block do
rmqver = ''
out = %x[dpkg -l rabbitmq-server] # |grep "^ii" |awk "{print $3}"]
out.split("\n").each do |line|
if line =~ /^ii\s*[\w\-]*\s*([0-9\.]+)-\d*/
rmqver = $1
end
end
run_context = Chef::RunContext.new(node, {})
d = Chef::Resource::Directory.new("/usr/lib/rabbitmq/lib/rabbitmq_server-#{rmqver}/plugins", run_context)
d.recursive(true)
d.run_action(:create)
amq = Chef::Resource::RemoteFile.new("/usr/lib/rabbitmq/lib/rabbitmq_server-#{rmqver}/plugins/amqp_client-#{rmqver}.ez", run_context)
amq.source("http://www.rabbitmq.com/releases/plugins/v#{rmqver}/amqp_client-#{rmqver}.ez")
amq.notifies(:restart, "service[rabbitmq-server]")
amq.mode("0644")
amq.run_action(:create_if_missing)
stomp = Chef::Resource::RemoteFile.new("/usr/lib/rabbitmq/lib/rabbitmq_server-#{rmqver}/plugins/rabbit_stomp-#{rmqver}.ez", run_context)
stomp.source("http://www.rabbitmq.com/releases/plugins/v#{rmqver}/rabbit_stomp-#{rmqver}.ez")
stomp.notifies(:restart, "service[rabbitmq-server]")
stomp.mode("0644")
stomp.run_action(:create_if_missing)
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment