diff --git a/attributes/default.rb b/attributes/default.rb index 74fc238..82480e1 100644 --- a/attributes/default.rb +++ b/attributes/default.rb @@ -5,7 +5,10 @@ # Copyright 2012-2013, Escape Studios # -default[:beanstalkd][:opts] = {} +default["beanstalkd"]["opts"] = {} #Ubuntu only -default[:beanstalkd][:start_during_boot] = false \ No newline at end of file +default["beanstalkd"]["start_during_boot"] = false + +default["beanstalkd"]["upgrade"] = true +default["beanstalkd"]["repo"] = false diff --git a/recipes/conf.rb b/recipes/conf.rb new file mode 100644 index 0000000..03c3918 --- /dev/null +++ b/recipes/conf.rb @@ -0,0 +1,26 @@ +case node["platform_family"] +when "debian" + template "beanstalkd default file" do + source "beanstalkd.default.erb" + path "/etc/default/beanstalkd" + owner "root" + group "root" + mode 0640 + variables( + :opts => node["beanstalkd"]["opts"], + :start_during_boot => node["beanstalkd"]["start_during_boot"] + ) + end +when "rhel" + template "beanstalkd sysconfig file" do + source "beanstalkd.sysconfig.erb" + path "/etc/sysconfig/beanstalkd" + owner "root" + group "root" + mode 0640 + variables( + :opts => node["beanstalkd"]["opts"] + ) + notifies :restart, "service[beanstalkd]" + end +end diff --git a/recipes/default.rb b/recipes/default.rb index c108a1f..84d24a8 100644 --- a/recipes/default.rb +++ b/recipes/default.rb @@ -5,34 +5,7 @@ # Copyright 2012-2013, Escape Studios # -package "beanstalkd" do - action :upgrade -end - -case node[:platform] - when "debian", "ubuntu" - template_path = "/etc/default/beanstalkd" #templates/ubuntu - else - template_path = "/etc/sysconfig/beanstalkd" #templates/default -end - -template "#{template_path}" do - source "beanstalkd.erb" - owner "root" - group "root" - mode 0640 - variables( - :opts => node[:beanstalkd][:opts], - :start_during_boot => node[:beanstalkd][:start_during_boot] - ) - notifies :restart, "service[beanstalkd]" -end - -service "beanstalkd" do - start_command "/etc/init.d/beanstalkd start" - stop_command "/etc/init.d/beanstalkd stop" - status_command "/etc/init.d/beanstalkd status" - supports [:start, :stop, :status] - #starts the service if it's not running and enables it to start at system boot time - action [:enable, :start] -end \ No newline at end of file +include_recipe "beanstalkd::repo" if node["beanstalkd"]["repo"] +include_recipe "beanstalkd::install" +include_recipe "beanstalkd::conf" +include_recipe "beanstalkd::service" diff --git a/recipes/install.rb b/recipes/install.rb new file mode 100644 index 0000000..de357ee --- /dev/null +++ b/recipes/install.rb @@ -0,0 +1 @@ +include_recipe "beanstalkd::install_#{node["beanstalk"]["install_method"]}" diff --git a/recipes/install_package.rb b/recipes/install_package.rb new file mode 100644 index 0000000..fa3177a --- /dev/null +++ b/recipes/install_package.rb @@ -0,0 +1,3 @@ +package "beanstalkd" do + action :upgrade if node["beanstalkd"]["upgrade"] +end diff --git a/recipes/repo.rb b/recipes/repo.rb new file mode 100644 index 0000000..38820cd --- /dev/null +++ b/recipes/repo.rb @@ -0,0 +1,10 @@ +case node["platform"] +when "ubuntu" + apt_repository "beanstalkd" do + uri "http://ppa.launchpad.net/jernej/beanstalkd/ubuntu" + distribution node['lsb']['codename'] + components ["main"] + keyserver "keyserver.ubuntu.com" + key "422D2977" + end +end diff --git a/recipes/service.rb b/recipes/service.rb new file mode 100644 index 0000000..b3bc638 --- /dev/null +++ b/recipes/service.rb @@ -0,0 +1,5 @@ +service "beanstalkd" do + supports :status => true + #starts the service if it's not running and enables it to start at system boot time + action [:enable, :start] +end diff --git a/templates/debian/beanstalkd.erb b/templates/default/beanstalkd.default.erb similarity index 100% rename from templates/debian/beanstalkd.erb rename to templates/default/beanstalkd.default.erb diff --git a/templates/default/beanstalkd.erb b/templates/default/beanstalkd.sysconfig.erb similarity index 100% rename from templates/default/beanstalkd.erb rename to templates/default/beanstalkd.sysconfig.erb diff --git a/templates/ubuntu/beanstalkd.erb b/templates/ubuntu/beanstalkd.erb deleted file mode 100644 index 4707bc5..0000000 --- a/templates/ubuntu/beanstalkd.erb +++ /dev/null @@ -1,13 +0,0 @@ -# -# /etc/default/beanstalkd -# -# Generated by Chef for <%= node[:fqdn] %> -# - -## Defaults for the beanstalkd init script, /etc/init.d/beanstalkd on -## Debian systems. Append ``-b /var/lib/beanstalkd'' for persistent -## storage. -DAEMON_OPTS="<% @opts.each do |k,v| %><%= "-#{k} #{v}" %> <% end %>" - -## Uncomment to enable startup during boot. -<% unless @start_during_boot %>#<% end %>START=yes \ No newline at end of file