[chef] help needed with memcached instances


Chronological Thread 
  • From: Joshua Miller < >
  • To:
  • Subject: [chef] help needed with memcached instances
  • Date: Tue, 18 May 2010 09:50:43 -0700
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:date:subject:to :message-id:mime-version:x-mailer; b=CxXkmZhnS+4AyIhmOFtT32HcEpkCb05rCO6JB6wz5h9W3oZN509LIiL+c+30p1z0Jb q4y61Q+eLKz7C3XyrghnwwtnbgP/9sHausPupJPaZ99h2JJMgOc2l0h9k3hI7ieNSI+Q fyKFiLoKoA4m+Cmvs/CEiRkGIg231Fwnf/BBc=

Env: Ubuntu 9.10 running chef 0.8.12

Problem: need to run multiple instances of memcached on one host, but seem to 
be doing something all wrong.

for the recipe below I have to create a template for each runit instance, 
also in the define the "#{params[:name]}" is not passed along. 

joshua-millers-macbook-pro:site-cookbooks jmiller$ ls -l 
memcached/templates/default/sv-memcached-11212-*
-rw-r--r--  1 jmiller  staff   33 May 17 23:58 
memcached/templates/default/sv-memcached-11212-log-run.erb
-rw-r--r--  1 jmiller  staff  133 May 17 23:55 
memcached/templates/default/sv-memcached-11212-run.erb
joshua-millers-macbook-pro:site-cookbooks jmiller$ 


So I can hack around all this and get a fully working instance but to do that 
I had to do two defines with hard coded settings, and template for each 
instance ... kind of defeats the point of using any variables.

Question is am I missing something major, is there a better way, or am I just 
hitting a limit of the runit_service 


Thank you,

Joshua





Modified Recipe:
joshua-millers-macbook-pro:site-cookbooks jmiller$ more 
memcached/recipes/default.rb 


package "memcached" do
  action :upgrade
end

package "libmemcache-dev" do
  action :upgrade
end


node[:memcached][:ports].each do |port|

  memcached_instance "#{port}"

end

joshua-millers-macbook-pro:site-cookbooks jmiller$ 


Memcached_Instance_Def:

joshua-millers-macbook-pro:site-cookbooks jmiller$ more 
memcached/definitions/memcached_instance.rb 

define :memcached_instance do
  include_recipe "memcached"

  runit_service "memcached-#{params[:name]}" do
    options({
      :memory => node[:memcached][:memory],
      :port => "#{params[:name]}",
      :user => node[:memcached][:user]}.merge(params)
    )
  end
end

joshua-millers-macbook-pro:site-cookbooks jmiller$ 

Memcached Modifed Attributes:
joshua-millers-macbook-pro:site-cookbooks jmiller$ more 
memcached/attributes/default.rb 
set_unless[:memcached][:memory] = 7680
set_unless[:memcached][:ports] = [ "11212","11213" ]
set_unless[:memcached][:user] = "nobody"
joshua-millers-macbook-pro:site-cookbooks jmiller$ 




  • [chef] help needed with memcached instances, Joshua Miller, 05/18/2010

Archive powered by MHonArc 2.6.16.

§