Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor #3

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions attributes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@
# Copyright 2012-2013, Escape Studios
#

default[:beanstalkd][:opts] = {}
default["beanstalkd"]["opts"] = {}

#Ubuntu only
default[:beanstalkd][:start_during_boot] = false
default["beanstalkd"]["start_during_boot"] = false

default["beanstalkd"]["upgrade"] = true
default["beanstalkd"]["repo"] = false
26 changes: 26 additions & 0 deletions recipes/conf.rb
Original file line number Diff line number Diff line change
@@ -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
35 changes: 4 additions & 31 deletions recipes/default.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
include_recipe "beanstalkd::repo" if node["beanstalkd"]["repo"]
include_recipe "beanstalkd::install"
include_recipe "beanstalkd::conf"
include_recipe "beanstalkd::service"
1 change: 1 addition & 0 deletions recipes/install.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include_recipe "beanstalkd::install_#{node["beanstalk"]["install_method"]}"
3 changes: 3 additions & 0 deletions recipes/install_package.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
package "beanstalkd" do
action :upgrade if node["beanstalkd"]["upgrade"]
end
10 changes: 10 additions & 0 deletions recipes/repo.rb
Original file line number Diff line number Diff line change
@@ -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
5 changes: 5 additions & 0 deletions recipes/service.rb
Original file line number Diff line number Diff line change
@@ -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
13 changes: 0 additions & 13 deletions templates/ubuntu/beanstalkd.erb

This file was deleted.