Initial version of solr module
This commit is contained in:
parent
317780be0f
commit
0630f22306
7 changed files with 321 additions and 0 deletions
18
solr/Makefile
Normal file
18
solr/Makefile
Normal file
|
@ -0,0 +1,18 @@
|
|||
include $(CURDIR)/../Makefile.inc
|
||||
|
||||
VERSION = 4.2.1
|
||||
|
||||
TARGET = solr-$(VERSION).tgz
|
||||
SOURCE = http://ftp.funet.fi/pub/mirrors/apache.org/lucene/solr/$(VERSION)/solr-$(VERSION).tgz
|
||||
|
||||
all: download manifest
|
||||
download: $(PACKAGES)/$(TARGET)
|
||||
manifest: $(MANIFESTS)/solr.pp
|
||||
|
||||
$(PACKAGES)/$(TARGET):
|
||||
@umask 022; echo $@; \
|
||||
test -f $@ || curl -o $@ $(SOURCE)
|
||||
|
||||
$(MANIFESTS)/solr.pp: $(PACKAGES)/$(TARGET)
|
||||
@umask 022; echo $@; \
|
||||
echo '$$solr_package_latest = "$(TARGET)"' > $@
|
10
solr/files/.htaccess
Normal file
10
solr/files/.htaccess
Normal file
|
@ -0,0 +1,10 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteRule ^(.*)$ http://localhost:8080/solr/$1 [P,L]
|
||||
</IfModule>
|
||||
|
||||
AuthType Basic
|
||||
AuthUserFile /etc/solr/htpasswd
|
||||
AuthName "Password Required"
|
||||
|
||||
require valid-user
|
10
solr/files/htaccess
Normal file
10
solr/files/htaccess
Normal file
|
@ -0,0 +1,10 @@
|
|||
<IfModule mod_rewrite.c>
|
||||
RewriteEngine On
|
||||
RewriteRule ^(.*)$ http://localhost:8983/solr/$1 [P,L]
|
||||
</IfModule>
|
||||
|
||||
AuthType Basic
|
||||
AuthUserFile /etc/solr/htpasswd
|
||||
AuthName "Password Required"
|
||||
|
||||
require valid-user
|
3
solr/files/solr-httpd.conf
Normal file
3
solr/files/solr-httpd.conf
Normal file
|
@ -0,0 +1,3 @@
|
|||
<Directory "/srv/www/https/*/solr">
|
||||
AllowOverride All
|
||||
</Directory>
|
88
solr/files/solr.init
Normal file
88
solr/files/solr.init
Normal file
|
@ -0,0 +1,88 @@
|
|||
#!/bin/sh
|
||||
|
||||
# chkconfig: 2345 90 10
|
||||
# description: Solr Server
|
||||
# processname: solr
|
||||
|
||||
### BEGIN INIT INFO
|
||||
# Provides: solr
|
||||
# Required-Start: $local_fs $network $syslog
|
||||
# Should-Start:
|
||||
# Required-Stop:
|
||||
# Default-Start: 2 3 4 5
|
||||
# Default-Stop: 0 1 6
|
||||
# Short-Description: Solr server
|
||||
# Description: Solr server
|
||||
### END INIT INFO
|
||||
|
||||
SOLRUSER=solr
|
||||
SOLRPATH="/srv/solr/run"
|
||||
CONFIGPATH="/srv/solr/cores"
|
||||
MEMORYLIMIT="-Xms1024M -Xmx4096M"
|
||||
|
||||
if [ `id -u` != "0" ]; then
|
||||
echo "This script must be run with root privileges." && exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e "${SOLRPATH}/start.jar" ]; then
|
||||
echo "Failed to find Solr jar file: ${SOLRPATH}/start.jar"
|
||||
echo "Check /etc/init.d/solr file for correct settings."
|
||||
RETVAL=1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if [ ! -e "${CONFIGPATH}/solr.xml" ]; then
|
||||
echo "Failed to find Solr config files: ${CONFIGPATH}/solr.xml"
|
||||
echo "Check /etc/init.d/solr file for correct settings."
|
||||
RETVAL=1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
start_solr() {
|
||||
# Check to see if Solr is running
|
||||
pgrep -u solr -f start.jar > /dev/null
|
||||
RUNNING=$?
|
||||
if [ $RUNNING -eq 0 ]; then
|
||||
echo "[FAILED]"
|
||||
echo
|
||||
echo "Reason: Solr already running"
|
||||
RETVAL=1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Start Solr
|
||||
echo "Starting Solr"
|
||||
COMMAND="java -Dsolr.solr.home=${CONFIGPATH} ${MEMORYLIMIT} -jar start.jar > solr.log 2>&1 &"
|
||||
su -s /bin/sh - ${SOLRUSER} -c "umask 007; cd ${SOLRPATH}; ${COMMAND}"
|
||||
}
|
||||
|
||||
stop_solr() {
|
||||
echo -n "Stopping Solr: "
|
||||
pkill -u solr -f start.jar
|
||||
RETVAL=$?
|
||||
if [ $RETVAL -eq 0 ]; then
|
||||
echo "Success"
|
||||
else
|
||||
echo "Failed"
|
||||
fi
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
start)
|
||||
start_solr
|
||||
;;
|
||||
stop)
|
||||
stop_solr
|
||||
;;
|
||||
restart)
|
||||
stop_solr
|
||||
sleep 2
|
||||
start_solr
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|restart}"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
|
||||
exit 0
|
182
solr/manifests/init.pp
Normal file
182
solr/manifests/init.pp
Normal file
|
@ -0,0 +1,182 @@
|
|||
# Install Apache Solr.
|
||||
#
|
||||
class solr {
|
||||
|
||||
if !$solr_package {
|
||||
if $solr_package_latest {
|
||||
$solr_package = $solr_package_latest
|
||||
} else {
|
||||
fail("Must define \$solr_package or \$solr_package_latest")
|
||||
}
|
||||
}
|
||||
|
||||
if !$solr_core {
|
||||
fail("Must define \$solr_core")
|
||||
}
|
||||
|
||||
file { "/usr/local/src/solr.tgz":
|
||||
ensure => present,
|
||||
mode => "0644",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
source => "puppet:///files/packages/${solr_package}"
|
||||
}
|
||||
|
||||
util::extract::tar { "/usr/local/share/solr":
|
||||
ensure => latest,
|
||||
strip => 1,
|
||||
source => "/usr/local/src/solr.tgz",
|
||||
require => File['/usr/local/src/solr.tgz'],
|
||||
}
|
||||
|
||||
include user::system
|
||||
realize(User["solr"], Group["solr"])
|
||||
|
||||
if $solr_datadir {
|
||||
file { $solr_datadir:
|
||||
ensure => directory,
|
||||
mode => "0770",
|
||||
owner => "solr",
|
||||
group => "solr",
|
||||
require => User["solr"],
|
||||
}
|
||||
|
||||
file { "/srv/solr":
|
||||
ensure => link,
|
||||
target => $solr_datadir,
|
||||
require => File[$solr_datadir],
|
||||
}
|
||||
} else {
|
||||
file { "/srv/solr":
|
||||
ensure => directory,
|
||||
mode => "0770",
|
||||
owner => "solr",
|
||||
group => "solr",
|
||||
require => User["solr"],
|
||||
}
|
||||
}
|
||||
|
||||
file { [ "/srv/solr/cores",
|
||||
"/srv/solr/cores/lib",
|
||||
"/srv/solr/index",
|
||||
"/srv/solr/run",
|
||||
"/srv/solr/run/solr-webapp",
|
||||
"/srv/solr/spool", ]:
|
||||
ensure => directory,
|
||||
mode => "0770",
|
||||
owner => "solr",
|
||||
group => "solr",
|
||||
require => File["/srv/solr"],
|
||||
}
|
||||
|
||||
file { "/srv/solr/cores/solr.xml"
|
||||
ensure => present,
|
||||
mode => "0660",
|
||||
owner => "solr",
|
||||
group => "solr",
|
||||
content => template("solr/solr.xml.erb"),
|
||||
require => File["/srv/solr/cores"],
|
||||
}
|
||||
|
||||
file { "/srv/solr/run/start.jar":
|
||||
ensure => link,
|
||||
target => "/usr/local/share/solr/example/start.jar"
|
||||
require => File["/srv/solr/run"],
|
||||
}
|
||||
file { "/srv/solr/run/contexts":
|
||||
ensure => link,
|
||||
target => "/usr/local/share/solr/example/contexts"
|
||||
require => File["/srv/solr/run"],
|
||||
}
|
||||
file { "/srv/solr/run/etc":
|
||||
ensure => link,
|
||||
target => "/usr/local/share/solr/example/etc"
|
||||
require => File["/srv/solr/run"],
|
||||
}
|
||||
file { "/srv/solr/run/lib":
|
||||
ensure => link,
|
||||
target => "/usr/local/share/solr/example/lib"
|
||||
require => File["/srv/solr/run"],
|
||||
}
|
||||
file { "/srv/solr/run/webapps":
|
||||
ensure => link,
|
||||
target => "/usr/local/share/solr/example/webapps"
|
||||
require => File["/srv/solr/run"],
|
||||
}
|
||||
|
||||
file { "/etc/init.d/solr":
|
||||
ensure => present,
|
||||
mode => "0755",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
source => "puppet:///modules/solr/solr.init",
|
||||
notify => Exec["add-service-solr"],
|
||||
}
|
||||
exec { "add-service-solr":
|
||||
path => "/bin:/usr/bin:/sbin:/usr/sbin",
|
||||
command => $::operatingsystem ? {
|
||||
"debian" => "update-rc.d solr defaults",
|
||||
"ubuntu" => "update-rc.d solr defaults",
|
||||
default => "chkconfig --add solr",
|
||||
},
|
||||
refreshonly => true,
|
||||
before => Service["solr"],
|
||||
}
|
||||
|
||||
service { "solr":
|
||||
enable => true,
|
||||
}
|
||||
|
||||
file { "/etc/solr":
|
||||
ensure => directory,
|
||||
mode => "0755",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
}
|
||||
file { "/etc/solr/htpasswd":
|
||||
ensure => present,
|
||||
mode => "0640",
|
||||
owner => "root",
|
||||
group => $apache::sslserver::group,
|
||||
require => File["/etc/solr"],
|
||||
}
|
||||
|
||||
$htdocs = "/usr/local/share/solr/htdocs"
|
||||
|
||||
file { $htdocs:
|
||||
ensure => directory,
|
||||
mode => "0755",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
require => Util::Extract::Tar["/usr/local/share/solr"],
|
||||
}
|
||||
file { "${htdocs}/.htaccess":
|
||||
ensure => present,
|
||||
mode => "0644",
|
||||
owner => "root",
|
||||
group => "root",
|
||||
source => [ "puppet:///files/solr/htaccess",
|
||||
"puppet:///modules/solr/htaccess", ],
|
||||
require => File[$htdocs],
|
||||
}
|
||||
|
||||
define configwebhost($htdocs) {
|
||||
file { "/srv/www/https/${name}/solr":
|
||||
ensure => link,
|
||||
target => $htdocs,
|
||||
require => File["/srv/www/https/${name}"],
|
||||
}
|
||||
}
|
||||
|
||||
if $solr_webhosts {
|
||||
apache::configfile { "solr.conf":
|
||||
http => false,
|
||||
source => "puppet:///modules/solr/solr-httpd.conf",
|
||||
}
|
||||
|
||||
configwebhost { $solr_webhosts:
|
||||
htdocs => $htdocs,
|
||||
}
|
||||
}
|
||||
|
||||
}
|
10
solr/templates/solr.xml.erb
Normal file
10
solr/templates/solr.xml.erb
Normal file
|
@ -0,0 +1,10 @@
|
|||
<?xml version="1.0" encoding="UTF-8" ?>
|
||||
<solr persistent="false" sharedLib="lib">
|
||||
<cores adminPath="/admin/cores">
|
||||
<% @solr_core.each do |core| -%>
|
||||
<core name="<%= core %>" instanceDir="<%= core %>">
|
||||
<property name="dataDir" value="/srv/solr/index/<%= core %>" />
|
||||
</core>
|
||||
<% end -%>
|
||||
</cores>
|
||||
</solr>
|
Loading…
Add table
Reference in a new issue