forked from b/cookbooks
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cook-39, initial commit solr cookbook, need testing.
- Loading branch information
jtimberman
committed
Apr 1, 2009
1 parent
a449dc2
commit 90a4fca
Showing
9 changed files
with
200 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
= DESCRIPTION: | ||
|
||
Sets up user and environment for running solr instances. | ||
|
||
= REQUIREMENTS: | ||
|
||
== Platform and Application Environment: | ||
|
||
Tested on Ubuntu 8.10. May work on other platforms, esp Ubuntu/Debian. | ||
|
||
Requires solr installed, such as a vendor plugin for a Rails application. Assumes 'start.jar' exists. Also requires ssh keys for solr user. See usage. | ||
|
||
== Cookbooks: | ||
|
||
Opscode cookbooks, http://github.com/opscode/cookbooks/tree/master: | ||
|
||
* capistrano (capistrano_setup) | ||
* java | ||
* runit (runit_service) | ||
|
||
= ATTRIBUTES: | ||
|
||
No specific attributes are used. See Parameters under usage. | ||
|
||
= USAGE: | ||
|
||
To create a solr instance for an application, use the solr_instance define: | ||
|
||
solr_instance "my_app" | ||
|
||
The recipe assumes that id_rsa ssh key pair has been created for the solr user. The files should be located in the cookbook where the solr_instance is used (for example a site-cookbook) | ||
|
||
== Parameters: | ||
|
||
The following parameters are prototyped for usage. | ||
|
||
* params[:path] - Location where this instance lives. | ||
* params[:xms] - Initial java heap size. | ||
* params[:xmx] - Maximum java heap size. | ||
* params[:user] - User for the instance process. | ||
* params[:uid] - UID for user. | ||
* params[:group] - Group for the instance process. | ||
* params[:gid] - GID for group. | ||
* params[:type] - master or false. Not currently used. | ||
|
||
Optionally specify a cookbook where the ssh keypair is located, otherwise generate keys and put the files in the solr cookbook. Empty files are located there for placeholders. | ||
|
||
= LICENSE and AUTHOR: | ||
|
||
Author:: Joshua Timberman (<joshua@opscode.com>) | ||
Copyright:: 2009, Opscode, Inc | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://www.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# | ||
# Cookbook Name:: solr | ||
# Attributes:: solr | ||
# | ||
# Copyright 2008, Opscode, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
solr Mash.new unless attribute?("solr") | ||
|
||
solr[:user] = 'solr' unless solr.has_key?(:user) | ||
solr[:uid] = 551 unless solr.has_key?(:uid) | ||
solr[:group] = 'solr' unless solr.has_key?(:group) | ||
solr[:gid] = 551 unless solr.has_key?(:gid) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# | ||
# Cookbook Name:: solr | ||
# Definition:: solr_instance | ||
# | ||
# Copyright 2009, Opscode, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
define :solr_instance, :path => "/srv", :xms => "128M", :xmx => "1024M", :type => "master" do | ||
include_recipe "solr" | ||
|
||
cap_setup "#{params[:name]}" do | ||
path "#{params[:path]}/#{params[:name]}" | ||
appowner "solr" | ||
end | ||
|
||
%w{ solr solr/data }.each do |dir| | ||
directory "#{params[:path]}/#{params[:name]}/#{dir}" do | ||
owner node[:solr][:user] | ||
group node[:solr][:group] | ||
mode 0755 | ||
end | ||
end | ||
|
||
%w{ bin conf }.each do |dir| | ||
directory "#{params[:path]}/#{params[:name]}/#{dir}" do | ||
owner "root" | ||
group "nogroup" | ||
mode 0755 | ||
end | ||
end | ||
|
||
runit_service params[:name] | ||
|
||
# directory for ssh, files for ssh keys | ||
directory "#{params[:path]}/#{params[:name]}/.ssh" do | ||
owner node[:solr][:user] | ||
group node[:solr][:group] | ||
mode 0700 | ||
end | ||
|
||
%w{ id_rsa id_rsa.pub authorized_keys }.each do |ssh_file| | ||
remote_file "#{params[:path]}/#{params[:name]}/.ssh/#{ssh_file}" do | ||
source ssh_file | ||
owner node[:solr][:user] | ||
group node[:solr][:group] | ||
mode 0600 | ||
if params[:cookbook] | ||
cookbook params[:cookbook] | ||
else | ||
cookbook "solr" | ||
end | ||
end | ||
end | ||
end |
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
# | ||
# Cookbook Name:: solr | ||
# Recipe:: default | ||
# | ||
# Copyright 2009, Opscode, Inc. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
# | ||
|
||
include_recipe "java" | ||
include_recipe "capistrano" | ||
include_recipe "runit" | ||
|
||
group node[:solr][:group] do | ||
gid node[:solr][:gid] | ||
action :create | ||
end | ||
|
||
user node[:solr][:user] do | ||
comment "Solr replication" | ||
home "/srv/solr" | ||
shell "/bin/bash" | ||
uid node[:solr][:uid] | ||
gid node[:solr][:gid] | ||
action :create | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
#!/bin/sh | ||
exec svlogd -tt ./main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#!/bin/sh | ||
|
||
export JAVA_HOME=/usr/java/jdk | ||
cd <%= @params[:path] %>/current | ||
exec 2>&1 | ||
exec \ | ||
chpst -u <%= @node[:solr][:user] %> /usr/bin/java -Xms<%= @params[:xms] %> -Xmx<%= @params[:xmx] %> \ | ||
-jar start.jar |