Skip to content

Commit

Permalink
This is the big one.
Browse files Browse the repository at this point in the history
Bring in support for a rpm based installation of chef server/client via
bootstrap. This is done by adding a dist_only? attribute that, if passed to the
bootstrap, would attempt to install packages via yum as opposed to the current
gem+deb install.

This commit also brings in init scripts for chef-client and chef-indexer as
opposed to carrying them in rpms.
  • Loading branch information
mdkent authored and jtimberman committed May 21, 2009
1 parent ca724f2 commit b20f0ed
Show file tree
Hide file tree
Showing 14 changed files with 281 additions and 23 deletions.
25 changes: 18 additions & 7 deletions apache2/recipes/mod_rails.rb
Expand Up @@ -24,12 +24,23 @@

include_recipe "passenger"

template "#{node[:apache][:dir]}/mods-available/passenger.load" do
cookbook "passenger"
source "passenger.load.erb"
owner "root"
group "root"
mode 0755
if platform?("centos","redhat") and dist_only?
package "mod_passenger" do
notifies :run, resources(:execute => "generate-module-list"), :immediately
end

file "#{node[:apache][:dir]}/conf.d/mod_passenger.conf" do
action :delete
backup false
end
else
template "#{node[:apache][:dir]}/mods-available/passenger.load" do
cookbook "passenger"
source "passenger.load.erb"
owner "root"
group "root"
mode 0755
end
end

template "#{node[:apache][:dir]}/mods-available/passenger.conf" do
Expand All @@ -40,4 +51,4 @@
mode 0755
end

apache_module "passenger"
apache_module "passenger"
1 change: 1 addition & 0 deletions chef/attributes/chef.rb
Expand Up @@ -20,3 +20,4 @@
chef Mash.new unless attribute?("chef")

chef[:path] = "/srv/chef" unless chef.has_key?(:path)
chef[:run_path] = "/var/run/chef" unless chef.has_key?(:run_path)
1 change: 1 addition & 0 deletions chef/attributes/indexer.rb
@@ -0,0 +1 @@
chef[:indexer_log] = "/var/log/chef/indexer.log" unless chef.has_key?(:indexer_log)
37 changes: 31 additions & 6 deletions chef/recipes/client.rb
Expand Up @@ -19,10 +19,17 @@
# See the License for the specific language governing permissions and
# limitations under the License.

include_recipe "runit"
# no runit here!
if ! platform?("centos","redhat")
include_recipe "runit"
end

gem_package "chef" do
version node[:chef][:client_version]
if platform?("centos","redhat") and dist_only?
package "rubygem-chef"
else
gem_package "chef" do
version node[:chef][:client_version]
end
end

group "chef" do
Expand All @@ -38,6 +45,17 @@
shell "/bin/bash"
end

if platform?("centos","redhat") and dist_only?
template "/etc/init.d/chef-client" do
owner "chef"
mode 0755
source "chef-client.init.erb"
action :create
backup false
end
end


directory "/etc/chef" do
owner "chef"
group "chef"
Expand All @@ -63,10 +81,10 @@
mode "644"
end

directory "/var/chef" do
directory node[:chef][:run_path] do
owner "chef"
group "chef"
mode 0775
mode "755"
end

execute "Register client node with Chef Server" do
Expand All @@ -81,4 +99,11 @@
# File.exists?("#{node[:chef][:path]}/cache/registration") }
end

runit_service "chef-client"
if platform?("centos","redhat") and dist_only?
service "chef-client" do
supports [ :restart, :reload, :status ]
action [ :enable, :start ]
end
else
runit_service "chef-client"
end
50 changes: 41 additions & 9 deletions chef/recipes/server.rb
Expand Up @@ -19,7 +19,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

include_recipe "runit"
include_recipe "packages"

# no runit here!
if ! platform?("centos","redhat")
include_recipe "runit"
end

case node[:platform]
when "ubuntu"
Expand All @@ -30,8 +35,8 @@
if node[:platform_version].to_f >= 5.0
include_recipe "couchdb"
end
# when "centos","redhat","fedora"
# include_recipe "couchdb"
when "centos","redhat","fedora"
include_recipe "couchdb"
end

include_recipe "stompserver"
Expand All @@ -40,14 +45,34 @@
include_recipe "apache2::mod_rails"
include_recipe "chef::client"

gem_package "chef-server" do
version node[:chef][:server_version]
end
if platform?("centos","redhat") and dist_only?
package "rubygem-chef-server"
package "rubygem-chef-server-slice"

template "/etc/init.d/chef-indexer" do
owner "chef"
mode 0755
source "chef-indexer.init.erb"
action :create
backup false
end

if node[:chef][:server_version] >= "0.5.7"
gem_package "chef-server-slice" do
template "/etc/chef/indexer.rb" do
owner "chef"
mode 0644
source "indexer.conf.erb"
action :create
end
else
gem_package "chef-server" do
version node[:chef][:server_version]
end

if node[:chef][:server_version] >= "0.5.7"
gem_package "chef-server-slice" do
version node[:chef][:server_version]
end
end
end

template "/etc/chef/server.rb" do
Expand Down Expand Up @@ -88,7 +113,14 @@
not_if { File.exists?("/etc/chef/certificates/#{node[:chef][:server_fqdn]}.pem") }
end

runit_service "chef-indexer"
if platform?("centos","redhat") and dist_only?
service "chef-indexer" do
supports [ :restart, :reload, :status ]
action [ :enable, :start ]
end
else
runit_service "chef-indexer"
end

template "#{node[:chef][:server_path]}/config.ru" do
source "config.ru.erb"
Expand Down
69 changes: 69 additions & 0 deletions chef/templates/default/chef-client.init.erb
@@ -0,0 +1,69 @@
#!/bin/bash
# Startup script for chef-client. This version is deployed by chef itself.
#
# chkconfig: - 98 02
# description: Client component of the Chef systems integration framework.
# processname: chef-client
#
# pidfile: <%= @node[:chef][:run_path] %>/chef-client.pid

# Source function library
. /etc/init.d/functions

prog="chef-client"
pidfile=<%= @node[:chef][:run_path] %>/chef-client.pid
lockfile=/var/lock/subsys/$prog
config=/etc/chef/client.rb

start() {
echo -n "Starting $prog:"
daemon chef-client -d -c "$config" -i <%= @node[:chef][:client_interval] %> -s <%= @node[:chef][:client_splay] %> -L <%= @node[:chef][:client_log] %> "&>/dev/null"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch ${lockfile}
return $RETVAL
}

stop() {
echo -n "Stopping $prog: "
if [ -f $pidfile ]; then
killproc chef-client
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
failure;
fi;
else
RETVAL=1
failure;
fi
rm -f $lockfile
echo
return $RETVAL
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f $lockfile ]; then
stop
start
fi
;;
status)
status chef-client
;;
*)
echo "Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac

exit $RETVAL
71 changes: 71 additions & 0 deletions chef/templates/default/chef-indexer.init.erb
@@ -0,0 +1,71 @@
#!/bin/bash
# Startup script for chef-indexer. This version is deployed by chef itself.
#
# chkconfig: - 75 25
# description: Server component of the Chef systems integration framework.
# processname: chef-indexer
#
# pidfile: <%= @node[:chef][:run_path] %>/chef-indexer.pid

# Source function library
. /etc/init.d/functions

prog="chef-indexer"
pidfile=<%= @node[:chef][:run_path] %>/chef-client.pid
lockfile=/var/lock/subsys/$prog
config=/etc/chef/indexer.rb
user="chef"
group="chef"

start() {
echo -n "Starting $prog:"
daemon chef-indexer -d -c "$config" -u "$user" -g "$group" -L <%= @node[:chef][:indexer_log] %> "&>/dev/null"
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch ${lockfile}
return $RETVAL
}

stop() {
echo -n "Stopping $prog: "
if [ -f $pidfile ]; then
killproc chef-indexer
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
failure;
fi;
else
RETVAL=1
failure;
fi
rm -f $lockfile
echo
return $RETVAL
}

case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
condrestart)
if [ -f $lockfile ]; then
stop
start
fi
;;
status)
status chef-indexer
;;
*)
echo "Usage: $0 {start|stop|restart|condrestart|status}"
exit 1
esac

exit $RETVAL
2 changes: 2 additions & 0 deletions chef/templates/default/client.rb.erb
Expand Up @@ -16,4 +16,6 @@ search_url "https://<%= @node[:chef][:server_fqdn] %>"
file_store_path "<%= @node[:chef][:path] %>/file_store"
file_cache_path "<%= @node[:chef][:path] %>/cache"

pid_file "<%= @node[:chef][:run_path] %>/chef-client.pid"

Chef::Log::Formatter.show_time = true
11 changes: 11 additions & 0 deletions chef/templates/default/indexer.conf.erb
@@ -0,0 +1,11 @@
#
# Chef Indxer Config File
#
# Dynamically generated by Chef - local modifications will be replaced
#

search_index_path "<%= @node[:chef][:path] %>/search_index"

pid_file "<%= @node[:chef][:run_path] %>/chef-indexer.pid"

Chef::Log::Formatter.show_time = false
5 changes: 5 additions & 0 deletions packages/attributes/packages.rb
@@ -0,0 +1,5 @@
packages Mash.new unless attribute?("packages")

# Toggle for recipes to determine if we should rely on distribution packages
# or gems.
packages[:dist_only] = false unless packages.has_key?(:dist_only)
9 changes: 9 additions & 0 deletions packages/libraries/packages.rb
@@ -0,0 +1,9 @@
# Yay for helpers!

class Chef
class Recipe
def dist_only?
@node[:packages][:dist_only]
end
end
end
Empty file added packages/recipes/default.rb
Empty file.
8 changes: 8 additions & 0 deletions passenger/recipes/default.rb
Expand Up @@ -22,8 +22,16 @@
# See the License for the specific language governing permissions and
# limitations under the License.

include_recipe "packages"
include_recipe "ruby"

if platform?("centos","redhat") and dist_only?
# just the gem, we'll install the apache module within apache2
package "rubygem-passenger"

return
end

%w{ apache2-prefork-dev libapr1-dev }.each do |pkg|
package pkg do
action :upgrade
Expand Down

0 comments on commit b20f0ed

Please sign in to comment.