diff --git a/manifests/config.pp b/manifests/config.pp index 22447c2..fde4c0e 100644 --- a/manifests/config.pp +++ b/manifests/config.pp @@ -23,6 +23,12 @@ group => $solr::solr_user, } + file { $::solr::solr_home: + ensure => directory, + owner => $solr::solr_user, + group => $solr::solr_user, + } + # After solr v 7.4.0 SOLR now uses log4j2.xml if versioncmp($solr::version, '7.4.0') >= 0 { # setup log4j2 configuration file. @@ -31,10 +37,11 @@ ensure => file, owner => 'solr', group => 'solr', - content => epp('solr/log4j2.xml.epp',{ + content => epp($solr::log4j_config_path, { log4j_rootlogger_loglevel => $solr::log4j_rootlogger_loglevel, log4j_maxfilesize => $solr::log4j_maxfilesize, log4j_maxbackupindex => $solr::log4j_maxbackupindex, + log4j_config_options => $solr::log4j_config_options }), } } else { @@ -86,10 +93,14 @@ include '::systemd' ::systemd::unit_file { 'solr.service': content => epp('solr/solr.service.epp',{ - solr_pid_dir => $solr::solr_pid_dir, - solr_port => $solr::solr_port, - solr_bin => $solr::solr_bin, - solr_env => $solr::solr_env, + solr_pid_dir => $solr::solr_pid_dir, + solr_port => $solr::solr_port, + solr_bin => $solr::solr_bin, + solr_env => $solr::solr_env, + solr_start_args => $solr::solr_start_args, + solr_stop_args => $solr::solr_stop_args, + solr_status_args => $solr::solr_status_args, + }), require => File[$::solr::solr_env], } @@ -103,9 +114,13 @@ ensure => file, mode => '0755', content => epp('solr/solr.sh.epp',{ - solr_bin => $solr::solr_bin, - solr_user => $solr::solr_user, - solr_env => $solr::solr_env, + solr_bin => $solr::solr_bin, + solr_user => $solr::solr_user, + solr_env => $solr::solr_env, + solr_start_args => $solr::solr_start_args, + solr_stop_args => $solr::solr_stop_args, + solr_status_args => $solr::solr_status_args, + }), require => File[$::solr::solr_env], } diff --git a/manifests/init.pp b/manifests/init.pp index 4c97f5a..0db02f7 100644 --- a/manifests/init.pp +++ b/manifests/init.pp @@ -43,6 +43,10 @@ # Sets if this module should manage the install directory. # True if this module should manage and false otherwise. # +# @param [Boolean] manage_java +# Sets if this module should manage the install of Java. +# True if this module should manage and false otherwise. +# # @param [String] solr_home # The home directory for solr. # @@ -62,6 +66,9 @@ # Bash style environment variables passed at the end of the solr # server environment. # +# @param [Optional[String]] solr_url_scheme +# Set the URL scheme to use (e.g. https) +# # @param [Hash] cores # An array of hashes that define a core which will be created with the # create_resources function. @@ -70,6 +77,9 @@ # @param [Array[String]] required_packages # Specified in params and is platform dependent. # +# @param [Array[String]] java_packages +# Specified in params and is platform dependent. +# # @param [Optional[Array]] zk_hosts # For configuring ZooKeeper ensemble. # @@ -83,6 +93,12 @@ # @param log4j_rootlogger_loglevel # The loglevel to set for log4j. # +# @param [String] log4j_config_template +# Provide path of the log4j2.xml config file to use. +# +# @param [Hash] log4j_config_options +# Hash of additional options for your log4j template. +# # @param [Optional[String]] schema_name # The Solr cores' schema name. This should be set to `schema.xml` if using # the classic schema.xml method. If using a managed schema, set this to @@ -141,9 +157,9 @@ # GPL-3.0+ # class solr ( - String $version = '6.2.0', - String $url = - 'http://archive.apache.org/dist/lucene/solr/', + String $version = '6.2.0', + String $url = + 'https://dlcdn.apache.org/solr/solr/', Boolean $manage_user = true, String $solr_user = 'solr', String $solr_host = '127.0.0.1', @@ -152,28 +168,37 @@ String $solr_downloads = '/opt/solr_downloads', String $install_dir = '/opt', Boolean $install_dir_mg = false, + Boolean $manage_java = true, String $var_dir = '/var/solr', String $solr_logs = '/var/log/solr', String $solr_home = '/opt/solr/server/solr', String $java_home = $solr::params::java_home, Optional[Array] $solr_environment = undef, + Optional[String] $solr_url_scheme = undef, Hash $cores = {}, Array[String] $required_packages = $solr::params::required_packages, - Optional[Array] $zk_hosts = undef, - String $log4j_maxfilesize = '4MB', - String $log4j_maxbackupindex = '9', + Array[String] $java_packages = + $solr::params::java_packages, + Optional[Array] $zk_hosts = undef, + String $log4j_maxfilesize = '4MB', + String $log4j_maxbackupindex = '9', Variant[ Enum['ALL', 'DEBUG', 'ERROR', 'FATAL', 'INFO', 'OFF', 'TRACE', 'TRACE_INT', 'WARN'], - String] $log4j_rootlogger_loglevel = 'INFO', - Optional[String] $schema_name = undef, + String] $log4j_rootlogger_loglevel = 'INFO', + String $log4j_config_path = 'solr/log4j2.xml.epp', + Hash $log4j_config_options = {}, + Optional[Array] $solr_start_args = [], + Optional[Array] $solr_status_args = [], + Optional[Array] $solr_stop_args = [], + Optional[String] $schema_name = undef, Optional[String] $ssl_key_store = undef, Optional[String] $ssl_key_store_password = undef, Optional[String] $ssl_key_store_type = 'JKS', Optional[String] $ssl_trust_store = undef, Optional[String] $ssl_trust_store_password = undef, - Optional[String] $ssl_trust_store_type = 'JKS', + Optional[String] $ssl_trust_store_type = 'JKS', Optional[Boolean] $ssl_need_client_auth = undef, Optional[Boolean] $ssl_want_client_auth = undef, Optional[String] $ssl_client_key_store = undef, @@ -225,8 +250,8 @@ Class['solr::config'] ~> Class['solr::service'] - if is_hash($cores) { - create_resources(::solr::core, $cores) + if $cores =~ Hash { + ensure_resources(::solr::core, $cores) } } diff --git a/manifests/install.pp b/manifests/install.pp index 3cb5c2e..0868606 100644 --- a/manifests/install.pp +++ b/manifests/install.pp @@ -9,6 +9,11 @@ # install requirements ensure_packages($solr::required_packages) + # Install java if desired. + if ($solr::manage_java) { + ensure_packages($solr::java_packages) + } + ## create a solr user user {$solr::solr_user: ensure => present, @@ -33,7 +38,7 @@ # download solr archive{$tarball: - source => "${solr::url}/${solr::version}/solr-${solr::version}.tgz", + source => "${solr::url}/${solr::version}/solr-${solr::version}.tgz?action=download", require => File[$solr::solr_downloads], } diff --git a/manifests/params.pp b/manifests/params.pp index aded3e7..51cab47 100644 --- a/manifests/params.pp +++ b/manifests/params.pp @@ -6,7 +6,8 @@ # OS Specific configuration case $::osfamily { 'RedHat': { - $required_packages = ['java-1.8.0-openjdk','unzip','lsof','wget'] + $required_packages = ['unzip','lsof','wget'] + $java_packages =['java-1.8.0-openjdk'] $java_home = '/usr/lib/jvm/jre-1.8.0' $solr_env = '/etc/sysconfig/solr' if versioncmp($::operatingsystemrelease, '7.0') >= 0 { @@ -21,10 +22,12 @@ if $::operatingsystem == 'Ubuntu' and versioncmp($::operatingsystemrelease, '15.04') >= 0 { $is_systemd = true - $required_packages = ['unzip','lsof','software-properties-common', 'openjdk-8-jre','wget'] + $required_packages = ['unzip','lsof','software-properties-common', 'wget'] + $java_packages =['openjdk-8-jre'] } else { $is_systemd = false - $required_packages = ['unzip','lsof','openjdk-8-jre','wget'] + $required_packages = ['unzip','lsof','wget'] + $java_packages =['openjdk-8-jre'] } } default: { diff --git a/templates/log4j2.xml.epp b/templates/log4j2.xml.epp index aa83e20..67e8622 100644 --- a/templates/log4j2.xml.epp +++ b/templates/log4j2.xml.epp @@ -2,6 +2,7 @@ String $log4j_rootlogger_loglevel, String $log4j_maxfilesize, String $log4j_maxbackupindex, + Hash $log4j_config_options, |-%>