Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Solaris 11 support #74

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 24 additions & 4 deletions files/RedHat/etc/init.d/splunk
Original file line number Diff line number Diff line change
Expand Up @@ -12,27 +12,47 @@ RETVAL=0

. /etc/init.d/functions

test -f /etc/sysconfig/splunk && . /etc/sysconfig/splunk

CMD=${CMD-/opt/splunk/bin/splunk}
USER="${USER-root}"

CURRENT_USER=`id -nu`

run_splunk() {
if [[ $CURRENT_USER == $USER ]]; then
$CMD "$@"
else
if [[ "${CURRENT_USER}" != "root" ]]; then
echo "Script must be run from $USER or root. You are '${CURRENT_USER}'"
exit 1
fi

su ${USER} --command="$CMD $*"
fi
}

splunk_start() {
echo Starting Splunk...
"/opt/splunk/bin/splunk" start --accept-license --no-prompt --answer-yes
run_splunk start --accept-license --no-prompt --answer-yes
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/splunk
}
splunk_stop() {
echo Stopping Splunk...
"/opt/splunk/bin/splunk" stop
run_splunk stop
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/splunk
}
splunk_restart() {
echo Restarting Splunk...
"/opt/splunk/bin/splunk" restart --accept-license --no-prompt --answer-yes
run_splunk restart --accept-license --no-prompt --answer-yes
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/splunk
}
splunk_status() {
echo Splunk status:
"/opt/splunk/bin/splunk" status
run_splunk status
RETVAL=$?
}
case "$1" in
Expand Down
2 changes: 2 additions & 0 deletions manifests/init.pp
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,8 @@
$package_provider = undef,
$version = $::splunk::params::version,
$replace_passwd = $::splunk::params::replace_passwd,
$user = $::splunk::params::user,
$group = $::splunk::params::group,
) inherits splunk::params {

# Added the preseed hack after getting the idea from very cool
Expand Down
61 changes: 52 additions & 9 deletions manifests/install.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,11 @@
$version = $::splunk::version,
$package_source = $::splunk::package_source,
$package_provider = $::splunk::package_provider,
$replace_passwd = $::splunk::replace_passwd
$replace_passwd = $::splunk::replace_passwd,
$user = $::splunk::user,
$group = $::splunk::group,
$init_system = $::splunk::init_system,
$init_confdir = $::splunk::init_confdir,
) {

package { $pkgname:
Expand All @@ -17,12 +21,13 @@
source => $package_source,
}->

file { '/etc/init.d/splunk':
ensure => present,
mode => '0700',
owner => 'root',
group => 'root',
source => "puppet:///modules/splunk/${::osfamily}/etc/init.d/${pkgname}"
file { "${splunkhome}/etc/splunk-launch.conf":
ensure => present,
mode => '0444',
owner => $user,
group => $group,
backup => true,
content => template('splunk/opt/splunk/etc/splunk-launch.conf.erb'),
} ->

# inifile
Expand Down Expand Up @@ -54,8 +59,8 @@
ensure => present,
replace => $replace_passwd,
mode => '0600',
owner => 'root',
group => 'root',
owner => $user,
group => $group,
backup => true,
content => template('splunk/opt/splunk/etc/passwd.erb'),
} ->
Expand All @@ -70,4 +75,42 @@
purge => false,
source => 'puppet:///modules/splunk/noarch/opt/splunk/etc/auth',
}

# On operatingsystems that use init scripts, include the configuration file
# Separate from the above dependency chain because it might not exist
if $init_system == 'sysv_compat' {
file { "${init_confdir}/${pkgname}":
ensure => present,
mode => '0700',
owner => 'root',
group => 'root',
content => template('splunk/init_conf.erb'),
require => Package[$pkgname],
} ->

file { '/etc/init.d/splunk':
ensure => present,
mode => '0700',
owner => 'root',
group => 'root',
source => "puppet:///modules/splunk/${::osfamily}/etc/init.d/${pkgname}"
}
}
elsif $init_system == 'smf' {
file { '/var/svc/manifest/site/splunk.smf.xml':
content => template('splunk/Solaris/splunk.smf.xml.erb'),
owner => 'root',
group => 'root',
mode => '0444',
require => Package[$pkgname],
notify => Exec['splunk-smf-importer'];
}

exec { 'splunk-smf-importer':
refreshonly => true,
command => '/usr/sbin/svcadm restart manifest-import';

}
}

}
13 changes: 13 additions & 0 deletions manifests/params.pp
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@
$purge = undef
$version = 'installed'
$replace_passwd = 'no'
$user = 'root'
$group = 'root'

if $::osfamily == 'RedHat' {
$init_system = 'sysv_compat'
$init_confdir = '/etc/sysconfig'
} elsif $::osfamily == 'Debian' {
$init_system = 'sysv_compat'
$init_confdir = '/etc/default'
} elsif $::osfamily == 'Solaris' {
$init_system = 'smf'
$init_confdir = undef
}

if $::mode == maintenance {
$service_ensure = 'stopped'
Expand Down
12 changes: 6 additions & 6 deletions manifests/ulimit.pp
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,15 @@
# value => '16384',
# }
#
define splunk::ulimit ( $value = '40960' ) {
define splunk::ulimit ( $user = 'root', $value = '40960' ) {
augeas { "set splunk ${name} ulimit":
context => '/files/etc/security/limits.conf/',
changes => [
"set \"domain[last()]\" root",
"set \"domain[.='root']/type\" -",
"set \"domain[.='root']/item\" ${name}",
"set \"domain[.='root']/value\" ${value}",
"set \"domain[last()]\" ${user}",
"set \"domain[.='${user}']/type\" -",
"set \"domain[.='${user}']/item\" ${name}",
"set \"domain[.='${user}']/value\" ${value}",
],
onlyif => "match domain[.='root'][type='-'][item='${name}'][value='${value}'] size == 0",
onlyif => "match domain[.='${user}'][type='-'][item='${name}'][value='${value}'] size == 0",
}
}
47 changes: 47 additions & 0 deletions templates/Solaris/splunk.smf.xml.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
<?xml version='1.0'?>
<!DOCTYPE service_bundle SYSTEM '/usr/share/lib/xml/dtd/service_bundle.dtd.1'>
<service_bundle type='manifest' name='export'>
<service name='site/splunk' type='service' version='0'>
<create_default_instance enabled='false'/>
<single_instance/>
<dependency name='fs-local' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/system/filesystem/local'/>
</dependency>
<dependency name='splunk_multi-user' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/milestone/multi-user'/>
</dependency>
<dependency name='splunk_network' grouping='require_all' restart_on='none' type='service'>
<service_fmri value='svc:/milestone/network'/>
</dependency>
<dependency name='splunk-binary' grouping='require_all' restart_on='refresh' type='path'>
<service_fmri value='file://localhost<%= @splunkhome %>/bin/splunk'/>
</dependency>
<dependency name='splunk-license' grouping='require_all' restart_on='refresh' type='path'>
<service_fmri value='file://localhost<%= @splunkhome %>/etc/splunk.license'/>
</dependency>
<dependent name='splunk_multi-user-server' restart_on='none' grouping='optional_all'>
<service_fmri value='svc:/milestone/multi-user-server'/>
</dependent>
<method_context project=':default' resource_pool=':default' working_directory=':default'>
<method_credential group='splunk' limit_privileges=':default' privileges='basic,file_dac_read,net_privaddr' supp_groups=':default' user='<%= @user %>'/>
<method_environment>
<envvar name='SPLUNK_HOME' value='<%= @splunkhome %>'/>
</method_environment>
</method_context>
<exec_method name='start' type='method' exec='<%= @splunkhome %>/bin/splunk %m --accept-license' timeout_seconds='300'>
<method_context/>
</exec_method>
<exec_method name='stop' type='method' exec='<%= @splunkhome %>/bin/splunk %m' timeout_seconds='300'>
<method_context/>
</exec_method>
<exec_method name='refresh' type='method' exec='<%= @splunkhome %>/bin/splunk restart' timeout_seconds='600'>
<method_context/>
</exec_method>
<stability value='Unstable'/>
<template>
<common_name>
<loctext xml:lang='C'>splunk log server</loctext>
</common_name>
</template>
</service>
</service_bundle>
2 changes: 2 additions & 0 deletions templates/init_conf.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
USER="<%= @user %>"

26 changes: 20 additions & 6 deletions templates/opt/splunk/etc/splunk-launch.conf.erb
Original file line number Diff line number Diff line change
@@ -1,19 +1,33 @@
#### THIS FILE MANAGED BY PUPPET ####
# Copyright (C) 2005-2010 Splunk Inc. All Rights Reserved. Version 4.1.5
#

# Modify the following line to suit the location of your Splunk install.
# If unset, Splunk will use the parent of the directory this configuration
# file was found in
#
SPLUNK_HOME=/opt/splunk
SPLUNK_HOME="<%= @splunkhome %>"

#
# By default, Splunk stores its indexes under SPLUNK_HOME in the
# var/lib/splunk subdirectory. This can be overridden
# here:
#
# SPLUNK_DB=/opt/splunk/var/lib/splunk
http_proxy = <%= proxyserver -%>:3128
# SPLUNK_DB=/home/build/build-home/ember/var/lib/splunk

# Splunkd daemon name
SPLUNK_SERVER_NAME=Splunkd

# Splunkweb daemon name
SPLUNK_WEB_NAME=splunkweb

# If SPLUNK_OS_USER is set, then Splunk service will only start
# if the 'splunk [re]start [splunkd]' command is invoked by a user who
# is, or can effectively become via setuid(2), $SPLUNK_OS_USER.
# (This setting can be specified as username or as UID.)
#
# SPLUNK_OS_USER
SPLUNK_OS_USER="<%= @user %>"

<% if @proxyserver -%>
http_proxy="<%= @proxyserver %>"
<% end -%>

#### THIS FILE MANAGED BY PUPPET ####