Commit 1a05cb5d authored by Stefan Galinski's avatar Stefan Galinski 🎮
Browse files

[TASK] Initial release

parents
.vagrant
Berksfile.lock
*~
*#
.#*
\#*#
.*.sw[a-z]
*.un~
/cookbooks
Gemfile.lock
bin/*
.bundle/*
.kitchen/
.kitchen.local.yml
/.idea/*
\ No newline at end of file
---
driver:
name: vagrant
provisioner:
name: chef_solo
platforms:
- name: debian-7
driver:
box: opendo_debian-7-amd64
box_url: http://ci.opendo.at:8080/job/Packer-Debian7Amd64/ws/packer_debian-7-amd64-typo3-nginx_virtualbox.box
network:
- ["private_network", {ip: "172.16.1.3"}]
suites:
- name: default
run_list:
- recipe[apt::default]
- recipe[typo3_solr::default]
attributes:
- name: typo3_solr_2-1_java6
run_list:
- recipe[apt::default]
- recipe[typo3_solr::default]
- recipe[fake::typo3_solr_2-1]
- name: typo3_solr_2-1_java7
run_list:
- recipe[apt::default]
- recipe[typo3_solr::default]
- recipe[fake::typo3_solr_2-1]
attributes:
java:
jdk_version: "7"
- name: typo3_solr_3-0_java7
run_list:
- recipe[apt::default]
- recipe[typo3_solr::default]
- recipe[fake::typo3_solr_3-0]
attributes:
java:
jdk_version: "7"
\ No newline at end of file
site :opscode
metadata
group :integration do
cookbook 'apt', '~> 1.10.0'
cookbook 'tomcat', '~> 0.11.0'
cookbook 'fake', path: 'test/fixtures/cookbooks/fake'
end
\ No newline at end of file
2014-10-28 5aa726a Merge branch 'release/1.2.0' (Jenkins)
2014-10-28 5a3cde9 [TASK] Generates ChangeLog (Jenkins)
2014-10-28 be1eadf [TASK] Raises versionnumber (Jenkins)
2014-10-28 0073ee0 [TASK] Solr Cookbook (pbergsmann)
2014-10-28 14c1168 Merge branch 'release/1.1.5' (Jenkins)
2014-10-28 d2c147d Merge branch 'release/1.1.5' into develop (Jenkins)
2014-10-28 1172979 [TASK] Generates ChangeLog (Jenkins)
2014-10-28 b0df63b [TASK] Raises versionnumber (Jenkins)
2014-10-28 0ea0adc [BUGFIX] Solr Cookbook (pbergsmann)
2014-08-07 fb66fe1 [BUGFIX] Fixes integration-test (pbergsmann)
2014-08-07 cf9b5b3 [BUGFIX] Conditionally loads stopwords (pbergsmann)
2014-08-07 7043697 [BUGFIX] Excludes stopwords.txt (pbergsmann)
2014-08-07 3e44c95 [BUGFIX] Changes resource-path for master (pbergsmann)
2014-08-07 c4b396e [BUGFIX] Fixes release-branch-check (pbergsmann)
2014-07-30 1b702c0 Revert "[BUGFIX] Cookbook is broken" (Josef Florian Glatz)
2014-07-24 c6690ff [BUGFIX] Cookbook is broken (Josef Florian Glatz)
2014-07-24 5b687bd [TASK] Extends .gitignore (Josef Florian Glatz)
2014-07-21 8e52a12 [TASK] Raises versionnumber (pbergsmann)
2014-07-21 2852948 [BUGFIX] Marks codeblock (pbergsmann)
2014-07-21 953fde2 [TASK] Enhances documentation (pbergsmann)
2014-07-21 83c551b [FEATURE] Enhances documentation for EXT:solr >= 3.0 (pbergsmann)
2014-07-21 e07c275 [FEATURE] Adds integration tests (pbergsmann)
2014-07-21 ecaa001 [FEATURE] Adds compatibility for Solr v4 (pbergsmann)
2013-11-12 6ce975c Initial commit (pbergsmann)
2013-01-30 b79bceb [FEATURE] Adds resources/providers removes attributes and default recipe (pbergsmann)
2013-01-24 16a5d79 removes install bash script (pbergsmann)
2013-01-24 30c084a First commit (pbergsmann)
\ No newline at end of file
Description
===========
**This is alpha software! It is used in production, but it is not guaranteed to work with your setup!***
This chef cookbook is based on the shell-scripts which are distributed with the EXT:solr (thank you Ingo Renner!). The
cookbook offers two LWRPs which should be enough to setup a solr app with unlimited solr cores.
Requirements
============
Platform:
* Debian, Ubuntu
The following Opscode cookbooks are dependencies:
* tomcat
If you want to user this cookbook with EXT:solr >= 3.0 you have to install java 7 on your system. When using the
java-cookbook, you need to override this attribute:
```ruby
node[:java][:jdk_version] = "7"
```
Attributes
==========
* `node[:typo3_solr][:solr][:solr_home]` - Path to the directory in which the apps should be located
Usage
=====
The following LWRPs are included:
`typo3_solr_app` is used to create a new webapp with the given configuration
*For instances requiring Apache Solr < 4*
```ruby
typo3_solr_app "MySolrAppName" do
solr '3.5.0'
extension '2.2'
plugin '1.2.0'
languages %w{ german english french italian generic hungarian }
end
```
*For instances requiring Apache Solr > 4*
```ruby
typo3_solr_app "MySolrAppName" do
solr '4.7.1'
extension '3.0'
plugin_access '2.0'
plugin_utils '1.1'
plugin_lang '3.1'
languages %w{ german english french italian generic hungarian }
end
```
`typo3_solr_core` is used to attach cores to a already created webapp
```ruby
typo3_solr_core "de-TestWeb-123-de_DE" do
language 'german'
app 'MySolrAppName'
action :add
end
```
License and Author
==================
Author: Philipp Bergsmann (<p.bergsmann@opendo.at>)
Copyright: 2014 opendo GmbH (http://opendo.at)
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.
=begin
default[:typo3_solr][:versions] = {
:Client15_Metallbringts => {
:solr => '3.6.2',
:ext => '2.8',
:plugin => '1.2.0',
:languages => %w{ german english french italian generic hungarian }
},
:Client8_MacHoffmann => {
:solr => '3.5.0',
:ext => '2.2',
:plugin => '1.2.0',
:languages => %w{ german english french italian generic hungarian }
}
}
=end
default[:typo3_solr][:solr][:solr_home] = "/srv/solr"
\ No newline at end of file
name "typo3_solr"
maintainer "Philipp Bergsmann, opendo GmbH"
maintainer_email "p.bergsmann@opendo.at"
license "All rights reserved"
description "Installs/Configures TYPO3 EXT:solr"
long_description IO.read(File.join(File.dirname(__FILE__), 'README.md'))
version "1.2.0"
%w{ tomcat }.each do |cb|
depends cb
end
action :add do
uri = URI.parse("https://forge.typo3.org/projects/extension-solr/repository/show?rev=solr_#{new_resource.extension}.x")
request = Net::HTTP.new(uri.host, uri.port)
request.use_ssl = true
request.verify_mode = OpenSSL::SSL::VERIFY_NONE
response = request.request_head uri.request_uri
if response.code.to_i == 200
remote_branch = "solr_#{new_resource.extension}.x"
else
remote_branch = "master"
end
resources_path = "Resources/Solr"
service "tomcat" do
service_name "tomcat6"
supports :restart => true, :reload => true, :status => true
end
#remote_file "/home/vagrant/apache-solr-#{new_resource.solr}.tar.gz" do
# source "http://www.us.apache.org/dist/lucene/solr/#{new_resource.solr}/solr-#{new_resource.solr}.tgz"
# action :create_if_missing
#end
bash 'Fetch Solr' do
user 'vagrant'
timeout 3000000
only_if {
not ::File.exists?("/home/vagrant/apache-solr-#{new_resource.solr}.tar.gz")
}
code <<-EOF
rsync --delete -auvz --progress -e "ssh -o StrictHostKeyChecking=no" \
--no-o --no-g deploy@deploy.sgalinski.de:~/solr/solr-#{new_resource.solr}.tgz \
"/home/vagrant/apache-solr-#{new_resource.solr}.tar.gz";
EOF
action :run
end
execute "decompress-solr-archive - #{new_resource.name}" do
cwd '/home/vagrant/'
command "tar -xzf apache-solr-#{new_resource.solr}.tar.gz"
creates "#{Chef::Config[:file_cache_path]}/apache-solr-#{new_resource.solr}/dist/apache-solr-#{new_resource.solr}.war"
end
# copy solr war-file
execute "rename-solr-dir - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path]
command "mv solr-#{new_resource.solr} apache-solr-#{new_resource.solr}"
creates "#{Chef::Config[:file_cache_path]}/apache-solr-#{new_resource.solr}"
end
execute "copy-solr-app - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path]
command "cp apache-solr-#{new_resource.solr}/dist/solr-#{new_resource.solr}.war #{node[:tomcat][:webapp_dir]}/#{new_resource.name}.war"
creates "#{node[:tomcat][:webapp_dir]}/#{new_resource.name}.war"
end
execute "copy-solr-libs - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path]
command "cp apache-solr-#{new_resource.solr}/example/lib/ext/*.jar #{node["tomcat"]["home"]}/lib/"
only_if { Gem::Version.new(new_resource.solr) >= Gem::Version.new('4.0.0') }
end
execute "chmod - #{new_resource.name}" do
command "chmod -R 777 #{node["tomcat"]["home"]}/lib/"
end
execute "copy-log4j-properties - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path]
command "cp apache-solr-#{new_resource.solr}/example/resources/log4j.properties #{node["tomcat"]["home"]}/lib/log4j.properties"
creates "#{node["tomcat"]["home"]}/lib/log4j.properties"
only_if { Gem::Version.new(new_resource.solr) >= Gem::Version.new('4.0.0') }
end
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf" do
owner node[:tomcat][:user]
group "root"
mode 0775
action :create
recursive true
end
execute "copy-solr-files - #{new_resource.name}" do
cwd Chef::Config[:file_cache_path]
command "cp -r apache-solr-#{new_resource.solr}/example/solr/* #{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/"
creates
end
new_resource.languages.each do |language|
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf/#{language}" do
owner node[:tomcat][:user]
group "root"
mode 0775
action :create
end
%w{ protwords.txt schema.xml synonyms.txt }.each do |file|
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf/#{language}/#{file}" do
source "https://forge.typo3.org/projects/extension-solr/repository/revisions/#{remote_branch}/raw/#{resources_path}/typo3cores/conf/#{language}/#{file}"
action :create_if_missing
owner node[:tomcat][:user]
mode 0644
end
end
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf/#{language}/_schema_analysis_stopwords_#{language}.json" do
source "https://forge.typo3.org/projects/extension-solr/repository/revisions/#{remote_branch}/raw/#{resources_path}/typo3cores/conf/#{language}/_schema_analysis_stopwords_#{language}.json"
action :create_if_missing
owner node[:tomcat][:user]
mode 0644
end
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf/#{language}/german-common-nouns.txt" do
source "https://forge.typo3.org/projects/extension-solr/repository/revisions/#{remote_branch}/raw/#{resources_path}/typo3cores/conf/#{language}/german-common-nouns.txt"
action :create_if_missing
owner node[:tomcat][:user]
mode 0644
only_if { language === 'german' }
end
end
%w{ elevate.xml general_schema_fields.xml general_schema_types.xml solrconfig.xml }.each do |file|
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf/#{file}" do
source "https://forge.typo3.org/projects/extension-solr/repository/revisions/#{remote_branch}/raw/#{resources_path}/typo3cores/conf/#{file}"
action :create_if_missing
owner node[:tomcat][:user]
mode 0664
end
end
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3cores/conf/currency.xml" do
source "https://forge.typo3.org/projects/extension-solr/repository/revisions/#{remote_branch}/raw/#{resources_path}/typo3cores/conf/currency.xml"
action :create_if_missing
owner node[:tomcat][:user]
mode 0644
only_if { Gem::Version.new(new_resource.extension) >= Gem::Version.new('2.8.0') }
end
file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/solr.xml" do
action :delete
end
template "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/solr.xml" do
source "solr.xml.erb"
#variables(:cores => node[:typo3_solr][:cores][new_resource.extension])
owner node[:tomcat][:user]
mode 0644
cookbook 'typo3_solr'
end
%w{ bin conf data }.each do |directory|
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/#{directory}" do
action :delete
recursive true
end
end
file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/README.txt" do
action :delete
end
template "#{node[:tomcat][:context_dir]}/#{new_resource.name}.xml" do
source "tomcat_solr.xml.erb"
variables(:app => new_resource.name)
owner node[:tomcat][:user]
mode 0644
cookbook 'typo3_solr'
end
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/dist" do
action :create
mode 0775
end
execute "copy-dist - #{new_resource.name}" do
command "cp -r #{Chef::Config[:file_cache_path]}/apache-solr-#{new_resource.solr}/dist #{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/"
end
execute "copy-contrib - #{new_resource.name}" do
command "cp -r #{Chef::Config[:file_cache_path]}/apache-solr-#{new_resource.solr}/contrib #{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/"
end
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3lib" do
action :create
mode 0775
end
# old typo3 solr plugin
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3lib/solr-typo3-plugin-#{new_resource.plugin}.jar" do
source "http://www.typo3-solr.com/fileadmin/files/solr/solr-typo3-plugin-#{new_resource.plugin}.jar"
mode 0644
notifies :restart, "service[tomcat]", :immediately
only_if { Gem::Version.new(new_resource.plugin) > Gem::Version.new('0.0.0') }
end
# new typo3-solr plugins
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3lib/solr-typo3-access-#{new_resource.plugin_access}.jar" do
source "http://www.typo3-solr.com/fileadmin/files/solr/Solr4x/solr-typo3-access-#{new_resource.plugin_access}.jar"
mode 0644
notifies :restart, "service[tomcat]", :immediately
only_if { Gem::Version.new(new_resource.plugin_access) > Gem::Version.new('0.0.0') }
end
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3lib/solr-typo3-utils-#{new_resource.plugin_utils}.jar" do
source "http://www.typo3-solr.com/fileadmin/files/solr/Solr4x/solr-typo3-utils-#{new_resource.plugin_utils}.jar"
mode 0644
notifies :restart, "service[tomcat]", :immediately
only_if { Gem::Version.new(new_resource.plugin_utils) > Gem::Version.new('0.0.0') }
end
remote_file "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}/typo3lib/commons-lang3-#{new_resource.plugin_lang}.jar" do
source "http://www.typo3-solr.com/fileadmin/files/solr/Solr4x/commons-lang3-#{new_resource.plugin_lang}.jar"
mode 0644
notifies :restart, "service[tomcat]", :immediately
only_if { Gem::Version.new(new_resource.plugin_lang) > Gem::Version.new('0.0.0') }
end
# reset directory access restrictions
execute "chown - #{new_resource.name}" do
command "chown -R #{node[:tomcat][:user]}:#{node[:tomcat][:group]} #{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name} && chmod -R o+rw #{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}"
end
new_resource.updated_by_last_action(true)
end
action :remove do
service "tomcat" do
service_name "tomcat6"
supports :restart => true, :reload => true, :status => true
end
directory "#{node[:typo3_solr][:solr][:solr_home]}/#{new_resource.name}" do
action :delete
recursive true
end
file "#{node[:tomcat][:context_dir]}/#{new_resource.name}.xml" do
action :delete
end
file "#{node[:tomcat][:webapp_dir]}/#{new_resource.name}.war" do
action :delete
end
directory "#{node[:tomcat][:webapp_dir]}/#{new_resource.name}" do
action :delete
recursive true
notifies :restart, "service[tomcat]", :immediately
end
new_resource.updated_by_last_action(true)
end
\ No newline at end of file
action :add do
new_resource.updated_by_last_action(false)
status_url = "http://127.0.0.1:8080/#{new_resource.app}/admin/cores?action=STATUS&core=#{new_resource.name}&wt=json"
puts status_url
status_response = Net::HTTP.get_response(URI.parse(status_url))
status = JSON.parse(status_response.body)
#unless status['status'][new_resource.name].has_key?('dataDir')
create_url = "http://127.0.0.1:8080/#{new_resource.app}/admin/cores?action=CREATE&name=#{new_resource.name}&instanceDir=typo3cores&schema=#{new_resource.language}/schema.xml&dataDir=data/#{new_resource.name}"
puts create_url
Net::HTTP.get_response(URI.parse(create_url))
new_resource.updated_by_last_action(true)
#end
end
action :remove do
delete_url = "http://127.0.0.1:8080/#{new_resource.app}/admin/cores?action=UNLOAD&core=#{new_resource.name}&deleteIndex=true"
Net::HTTP.get_response(URI.parse(delete_url))
new_resource.updated_by_last_action(true)
end
\ No newline at end of file
#
# Cookbook Name:: typo3_solr
# Recipe:: default
#
# Copyright 2012, Philipp Bergsmann, opendo GmbH
#
# All rights reserved - Do Not Redistribute
#
include_recipe "tomcat"
directory node[:typo3_solr][:solr][:solr_home] do
owner node[:tomcat][:user]
group "root"
mode 0770
action :create
end
#execute "chmod" do
# command "chmod -R 777 #{node[:typo3_solr][:solr][:solr_home]}"
#end
\ No newline at end of file
actions :add, :remove
attribute :name, :kind_of => String, :name_attribute => true
attribute :solr, :kind_of => String, :default => '3.6.2'
attribute :extension, :kind_of => String, :default => '2.8'
attribute :plugin, :kind_of => String, :default => '0.0.0'
attribute :plugin_access, :kind_of => String, :default => '0.0.0'
attribute :plugin_utils, :kind_of => String, :default => '0.0.0'
attribute :plugin_lang, :kind_of => String, :default => '0.0.0'
attribute :languages, :kind_of => Array, :default => %w{ english }
def initialize(*args)
super
@action = :add
end
\ No newline at end of file
actions :add, :remove
attribute :name, :kind_of => String, :name_attribute => true
attribute :language, :kind_of => String, :default => "english"
attribute :app, :kind_of => String
def initialize(*args)
super
@action = :add
end
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="true">
<cores adminPath="/admin/cores" shareSchema="true">
<%
#puts @cores
if @cores then
@cores.each do |coreName, coreConf|
%>
<core name="<%=coreName%>" instanceDir="typo3cores" schema="<%=coreConf[:language]%>/schema.xml" dataDir="data/<%=coreName%>" />
<%
end
end
%>
</cores>
</solr>
\ No newline at end of file
<Context docBase="<%= @app %>.war" debug="0" crossContext="true" >
<Environment name="solr/home" type="java.lang.String" value="<%= node[:typo3_solr][:solr][:solr_home] %>/<%= @app %>" override="true" />
</Context>
name 'fake'
version '1.0.0'
depends 'typo3_solr'
\ No newline at end of file
typo3_solr_app "c015" do
solr '3.5.0'
extension '2.1'
plugin '1.2.0'
languages %w{ german english }
end
typo3_solr_core "live-MetallbringtsAt-1-0-de_AT" do
language 'german'
app 'c015'
action :add
notifies :restart, resources(:service => "tomcat")
end
\ No newline at end of file
typo3_solr_app "c015" do
solr '4.7.2'
solr '4.8.1'
extension '3.0'
plugin_access '2.0'
plugin_utils '1.1'
plugin_lang '3.1'
languages %w{ german english }
end
typo3_solr_core "live-MetallbringtsAt-1-0-de_AT" do
language 'german'
app 'c015'
action :add
notifies :restart, resources(:service => "tomcat")
end