Skip to content
This repository has been archived by the owner on May 5, 2023. It is now read-only.

Commit

Permalink
Adding core functionality, clear up home vs root naming conv
Browse files Browse the repository at this point in the history
  • Loading branch information
Kris Buytaert committed Sep 5, 2012
1 parent 00b369a commit 7f3d232
Show file tree
Hide file tree
Showing 24 changed files with 275 additions and 33 deletions.
11 changes: 11 additions & 0 deletions Modulefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name 'puppet-solr'
version '0.0.1'
source 'UNKNOWN'
author 'puppet'
license 'UNKNOWN'
summary 'UNKNOWN'
description 'UNKNOWN'
project_page 'UNKNOWN'

## Add dependencies, if any:
# dependency 'username/name', '>= 1.2.0'
3 changes: 3 additions & 0 deletions README
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
solr

This is the solr module.
22 changes: 22 additions & 0 deletions files/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Files
=====

Puppet comes with both a client and server for copying files around. The file
serving function is provided as part of the central Puppet daemon,
puppetmasterd, and the client function is used through the source attribute of
file objects. Learn more at
http://projects.puppetlabs.com/projects/puppet/wiki/File_Serving_Configuration

You can use managed files like this:

class myclass {
package { mypackage: ensure => latest }
service { myservice: ensure => running }
file { "/etc/myfile":
source => "puppet://$servername/modules/mymodule/myfile"
}
}

The files are searched for in:

$modulepath/mymodule/files/myfile
22 changes: 22 additions & 0 deletions lib/puppet/facter/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
Facter
======

Define facts in this directory.

Sometimes you need to be able to write conditional expressions based
on site-specific data that just isn’t available via Facter. The
solution may be to add a fact to Facter. These additional facts can
then be distributed to Puppet clients and are available for use in
manifests. Learn more at
http://projects.puppetlabs.com/projects/puppet/wiki/Adding_Facts

File paths should match the fact name; for example, a fact
`hardware_platform`, defined like this:

Facter.add("hardware_platform") do
setcode do
%x{/bin/uname -i}.chomp
end
end

Should be found in `hardware_platform.rb` in this directory.
17 changes: 17 additions & 0 deletions lib/puppet/parser/functions/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
Functions
=========

Define functions in this directory.

File paths should match the function name; for example, a function
`myfunction`, defined like this:

Puppet::Parser::Functions::newfunction(
:myfunction,
:type => :statement,
:doc => "Documentation here."
) do |vals|
# ...
end

Should be found in `myfunction.rb` in this directory.
14 changes: 14 additions & 0 deletions lib/puppet/provider/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Providers
=========

Define providers under this directory.

File paths should match the resource type name and provider name; for
example, a provider `myprovider` for a resource type `mytype`, defined like this:

Puppet::Type.type(:mytype).provide(:myprovider) do
desc "Documentation here"
# ...
end

Should be found in `mytype/myprovider.rb` under this directory.
14 changes: 14 additions & 0 deletions lib/puppet/type/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Resource Types
==============

Define resource types in this directory.

Filenames should match the resource type name; for example, a resource
type `mytype`, defined like this:

Puppet::Type.newtype(:mytype) do
@doc = "Documentation here."
# ...
end

Should be found in `mytype.rb`
28 changes: 28 additions & 0 deletions manifests/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
Manifests
=========

Module manifest files belong in this directory.

`init.pp` defines how the module will carry out its tasks in this file.

Add additional definitions in this directory. Their file paths should match the
definition name; for example, a definition `mydefinition`, defined like this:

# Definition: mydefinition
#
# This is the mydefinition in the mymodule module.
#
# Parameters:
#
# Actions:
#
# Requires:
#
# Sample Usage:
#
# [Remember: No empty lines between comments and class definition]
define mydefinition {
# ...
}

Should be found in `mydefinition.pp` in this directory.
57 changes: 37 additions & 20 deletions manifests/config.pp
Original file line number Diff line number Diff line change
@@ -1,32 +1,49 @@
class solr::config {
file {
# Not actually using this anymore as we are deploying in tomcat
'solr initscript':
ensure => "present",
path => '/etc/init.d/solr',
owner => "root",
group => "root",
mode => "0755",
'solrinitscript':
ensure => 'present',
path => '/etc/init.d/solr',
owner => 'root',
group => 'root',
mode => '0755',
content => template('solr/solr.init.erb');

'solr conf':
ensure => present,
path => '/usr/share/solr/solr.xml',
owner => root,
group => root,
mode => '0755',
content => template('solr/solr.xml.erb');
"${solr::home}":
ensure => 'directory',
owner => "${solr::tomcat_user}",
group => "${solr::tomcat_group}",
mode => '0755';
}
$warlocation = "${solr::home}/dist/apache-solr-${solr::version}.war"
$warlocation = "${solr::root}/dist/apache-solr-${solr::version}.war"

file { '/etc/tomcat6/Catalina/localhost/solr.xml':
ensure => present,
owner => root,
group => root,
mode => '0755',
content => template('solr/Catalina.solr.xml.erb'),
ensure => 'present',
owner => 'root',
group => 'root',
mode => '0755',
content => template('solr/Catalina.solr.xml.erb');
}



include concat::setup
concat {"${solr::home}/solr.xml":
# path => "${solr::home}/solr.xml",
owner => 'root',
group => 'root',
mode => '0755',
}
concat::fragment {'header':
target => "${solr::home}/solr.xml",
order => 0,
content => template('solr/solr.xml.erb.head');
}

concat::fragment {'footer':
target => "${solr::home}/solr.xml",
order => 99,
content => template('solr/solr.xml.erb.foot');
}

}

19 changes: 19 additions & 0 deletions manifests/core.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
define solr::core (
$path = "${solr::home}/$name",
$source = 'to be implemented')
{
concat::fragment {"$name":
target => "${solr::home}/solr.xml",
order => 15,
content => template('solr/core.xml.erb');
}

file {"${path}":
ensure => directory,
owner => "${solr::tomcat_user}",
group => "${solr::tomcat_group}",
mode => '0755',
}

}

15 changes: 8 additions & 7 deletions manifests/init.pp
Original file line number Diff line number Diff line change
@@ -1,17 +1,18 @@
class solr (
$backend = 'tomcat',
$home = '/usr/share/solr',
$root = '/usr/share/solr',
$home = '/var/lib/solr',
$tomcat_root = $::operatingsystem ? {
default => '/var/lib/tomcat6',
centos => '/usr/share/tomcat6',
default => '/var/lib/tomcat6',
centos => '/usr/share/tomcat6',
},
$tomcat_user = $::operatingsystem ? {
default => 'tomcat',
debian => 'tomcat6',
default => 'tomcat',
debian => 'tomcat6',
},
$tomcat_group = $::operatingsystem ? {
default => 'tomcat',
debian => 'tomcat6',
default => 'tomcat',
debian => 'tomcat6',
},
$version = '3.6.1'
)
Expand Down
7 changes: 7 additions & 0 deletions spec/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
Specs
=====

The Puppet project uses RSpec for testing.

For more information on RSpec, see http://rspec.info/

6 changes: 6 additions & 0 deletions spec/spec.opts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
--format
s
--colour
--loadby
mtime
--backtrace
18 changes: 18 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
require 'pathname'
dir = Pathname.new(__FILE__).parent
$LOAD_PATH.unshift(dir, dir + 'lib', dir + '../lib')

require 'mocha'
require 'puppet'
gem 'rspec', '=1.2.9'
require 'spec/autorun'

Spec::Runner.configure do |config|
config.mock_with :mocha
end

# We need this because the RAL uses 'should' as a method. This
# allows us the same behaviour but with a different method name.
class Object
alias :must :should
end
4 changes: 4 additions & 0 deletions spec/unit/puppet/provider/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Provider Specs
==============

Define specs for your providers under this directory.
4 changes: 4 additions & 0 deletions spec/unit/puppet/type/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Resource Type Specs
===================

Define specs for your resource types in this directory.
23 changes: 23 additions & 0 deletions templates/README.markdown
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
Templates
=========

Puppet supports templates and templating via ERB, which is part of the Ruby
standard library and is used for many other projects including Ruby on Rails.
Templates allow you to manage the content of template files, for example
configuration files that cannot yet be managed as a Puppet type. Learn more at
http://projects.puppetlabs.com/projects/puppet/wiki/Puppet_Templating

You can use templates like this:

class myclass {
package { mypackage: ensure => latest }
service { myservice: ensure => running }
file { "/etc/myfile":
content => template("mymodule/myfile.erb")
}
}

The templates are searched for in:

$templatedir/mymodule/myfile.erb
$modulepath/mymodule/templates/myfile.erb
1 change: 1 addition & 0 deletions templates/core.xml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<core name="<%= scope.lookupvar('name') %>" instancdDir="<%= scope.lookupvar('path') %>">
2 changes: 1 addition & 1 deletion templates/solr.init.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
NAME="solr"
PIDFILE="/var/run/solr-production.pid"
LOG_FILE="/var/log/solr-production.log"
SOLR_DIR="<%= scope.lookupvar('solr::home') %>/example"
SOLR_DIR="<%= scope.lookupvar('solr::root') %>/example"
JAVA_OPTIONS="-Xmx1024m -DSTOP.PORT=8079 -DSTOP.KEY=stopkey -jar start.jar"
JAVA="/usr/bin/java"

Expand Down
5 changes: 0 additions & 5 deletions templates/solr.xml.erb

This file was deleted.

2 changes: 2 additions & 0 deletions templates/solr.xml.erb.foot
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
</cores>
</solr>
4 changes: 4 additions & 0 deletions templates/solr.xml.erb.head
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="false">
<property name="masterUrl" value="http://solrmaster:8080/solr"/>
<cores adminPath="/admin/cores" shareSchema="true">
9 changes: 9 additions & 0 deletions templates/solr.xml.erb.orig
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<?xml version="1.0" encoding="UTF-8" ?>
<solr persistent="false">
<property name="masterUrl" value="http://solrmaster:8080/solr"/>
<cores adminPath="/admin/cores" shareSchema="true">
<core name="core0" instanceDir="core0" />
<core name="core1" instanceDir="core1" />
<core name="core2" instanceDir="core2" />
</cores>
</solr>
1 change: 1 addition & 0 deletions tests/init.pp
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
include solr

0 comments on commit 7f3d232

Please sign in to comment.