Puppet Class: solr::config

Inherits:
solr::params
Defined in:
manifests/config.pp

Overview

Class: solr::config

This class sets up solr install

Parameters

  • The $cores to create

Actions

  • Copies a new jetty default file

  • Creates solr home directory

  • Downloads the required solr version, extracts war and copies logging jars

  • Creates solr data directory

  • Creates solr config file with cores specified

  • Links solr home directory to jetty webapps directory

Parameters:

  • cores (Any) (defaults to: $solr::params::cores)
  • version (Any) (defaults to: $solr::params::solr_version)
  • mirror (Any) (defaults to: $solr::params::mirror_site)
  • jetty_home (Any) (defaults to: $solr::params::jetty_home)
  • solr_home (Any) (defaults to: $solr::params::solr_home)


15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
# File 'manifests/config.pp', line 15

class solr::config(
  $cores          = $solr::params::cores,
  $version        = $solr::params::solr_version,
  $mirror         = $solr::params::mirror_site,
  $jetty_home     = $solr::params::jetty_home,
  $solr_home      = $solr::params::solr_home,
  ) inherits solr::params {

  $dl_name        = "solr-${version}.tgz"
  $download_url   = "${mirror}/${version}/${dl_name}"

  #Copy the jetty config file
  file { '/etc/default/jetty':
    ensure  => file,
    source  => 'puppet:///modules/solr/jetty-default',
    require => Package['jetty'],
  }

  file { $solr_home:
    ensure  => directory,
    owner   => 'jetty',
    group   => 'jetty',
    require => Package['jetty'],
  }

  # download only if WEB-INF is not present and tgz file is not in /tmp:
  exec { 'solr-download':
    path    =>  ['/usr/bin', '/usr/sbin', '/bin'],
    command =>  "wget ${download_url}",
    cwd     =>  '/tmp',
    creates =>  "/tmp/${dl_name}",
    onlyif  =>  "test ! -d ${solr_home}/WEB-INF && test ! -f /tmp/${dl_name}",
    timeout =>  0,
    require => File[$solr_home],
  }

  exec { 'extract-solr':
    path    =>  ['/usr/bin', '/usr/sbin', '/bin'],
    command =>  "tar xvf ${dl_name}",
    cwd     =>  '/tmp',
    onlyif  =>  "test -f /tmp/${dl_name} && test ! -d /tmp/solr-${version}",
    require =>  Exec['solr-download'],
  }

  # have to copy logging jars separately from solr 4.3 onwards
  exec { 'copy-solr':
    path    =>  ['/usr/bin', '/usr/sbin', '/bin'],
    command =>  "jar xvf /tmp/solr-${version}/dist/solr-${version}.war; cp /tmp/solr-${version}/example/lib/ext/*.jar WEB-INF/lib",
    cwd     =>  $solr_home,
    onlyif  =>  "test ! -d ${solr_home}/WEB-INF",
    require =>  Exec['extract-solr'],
  }

  file { '/var/lib/solr':
    ensure  => directory,
    owner   => 'jetty',
    group   => 'jetty',
    mode    => '0700',
    require => Package['jetty'],
  }

  file { "${solr_home}/solr.xml":
    ensure  => 'file',
    owner   => 'jetty',
    group   => 'jetty',
    content => template('solr/solr.xml.erb'),
    require => File['/etc/default/jetty'],
  }

  file { "${jetty_home}/webapps/solr":
    ensure  => 'link',
    target  => $solr_home,
    require => File["${solr_home}/solr.xml"],
  }

  solr::core { $cores:
    require   =>  File["${jetty_home}/webapps/solr"],
  }
}