Skip to content

Instantly share code, notes, and snippets.

@joshourisman
Created December 4, 2012 14:34
Show Gist options
  • Save joshourisman/4204531 to your computer and use it in GitHub Desktop.
Save joshourisman/4204531 to your computer and use it in GitHub Desktop.
#
# Cookbook Name:: solr
# Recipe:: default
#
# Copyright 2012, Example Com
#
# 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.
#
case node[:platform]
when "debian", "ubuntu"
package "tomcat7" do
action :install
end
# add tomcat group
group "tomcat" do
members ["root"]
end
# configuring tomcat
template "/var/lib/tomcat7/conf/Catalina/localhost/solr.xml" do
source "tomcat_solr.xml.erb"
owner "root"
group "tomcat"
mode "0664"
end
# creating solr home and solr core
directory "#{node[:solr][:home]}/#{node[:solr][:core_name]}" do
owner "root"
group "tomcat"
mode "0777"
action :create
recursive true
end
# directory "#{node[:solr][:home]}/#{node[:solr][:core_name]}/conf" do
# owner "root"
# group "tomcat"
# mode "0777"
# action :create
# end
remote_directory "#{node[:solr][:home]}/#{node[:solr][:core_name]}/conf" do
source "config"
owner "root"
group "tomcat"
mode "0777"
recursive true
action :nothing
end.run_action(:create)
# configuring solr
template "#{node[:solr][:home]}/solr.xml" do
source "solr.xml.erb"
owner "root"
group "root"
mode "0664"
end
template "#{node[:solr][:home]}/#{node[:solr][:core_name]}/conf/solrconfig.xml" do
source "solrconfig.xml.erb"
owner "root"
group "root"
mode "0644"
end
template "#{node[:solr][:home]}/#{node[:solr][:core_name]}/conf/schema.xml" do
source "schema.xml.erb"
owner "root"
group "root"
mode "0644"
end
cookbook_file "/var/lib/tomcat7/webapps/solr.war" do
source "solr.war"
owner "root"
group "root"
mode "0644"
# notifies :restart, resources(:service => "tomcat7")
end
service "tomcat7" do
action :restart
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment