Skip to content

Commit d3312a2

Browse files
authored
Merge pull request #215 from nick-markowski/7_2_support
Add 7.2 support and refactor module
2 parents 04b798c + b21d168 commit d3312a2

File tree

29 files changed

+1975
-1107
lines changed

29 files changed

+1975
-1107
lines changed

README.md

Lines changed: 292 additions & 84 deletions
Large diffs are not rendered by default.

lib/puppet/provider/ini_setting/splunk.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ class << self
1212
end
1313

1414
def self.file_path
15-
raise Puppet::Error, 'file_path must be set with splunk_config type before provider can be used' if @file_path.nil?
15+
raise Puppet::Error, 'file_path must be set with splunkenterprise_config or splunkforwarder_config type before provider can be used' if @file_path.nil?
1616
raise Puppet::Error, 'Child provider class does not support a file_name method' unless respond_to?(:file_name)
1717
@file_path
1818
end

manifests/addon.pp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,37 @@
3232
# }
3333
# }
3434
#
35-
3635
define splunk::addon (
37-
$splunk_home = '/opt/splunkforwarder',
38-
$package_manage = true,
39-
Optional[String] $package_name = undef,
40-
$inputs = {},
36+
Optional[Stdlib::Absolutepath] $splunk_home = undef,
37+
Boolean $package_manage = true,
38+
Optional[String[1]] $package_name = undef,
39+
Hash $inputs = {},
4140
) {
4241

42+
include 'splunk::params'
43+
44+
if $splunk_home {
45+
$_splunk_home = $splunk_home
46+
}
47+
else {
48+
$_splunk_home = $splunk::params::forwarder_homedir
49+
}
4350

4451
if $package_manage {
4552
package { $package_name:
4653
ensure => installed,
47-
before => File["${splunk_home}/etc/apps/${name}/local"],
54+
before => File["${_splunk_home}/etc/apps/${name}/local"],
4855
}
4956
}
5057

51-
file { "${splunk_home}/etc/apps/${name}/local":
58+
file { "${_splunk_home}/etc/apps/${name}/local":
5259
ensure => directory,
5360
}
5461

5562
if $inputs {
5663
concat { "splunk::addon::inputs_${name}":
57-
path => "${splunk_home}/etc/apps/${name}/local/inputs.conf",
58-
require => File["${splunk_home}/etc/apps/${name}/local"],
64+
path => "${_splunk_home}/etc/apps/${name}/local/inputs.conf",
65+
require => File["${_splunk_home}/etc/apps/${name}/local"],
5966
}
6067

6168
create_resources('splunk::addon::input', $inputs, {'addon' => $name })

manifests/addon/input.pp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
# Private defined type callled by splunk::addon
2-
1+
# Private defined type called by splunk::addon
2+
#
33
define splunk::addon::input (
44
$addon,
55
$attributes={},

manifests/enterprise.pp

Lines changed: 280 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,280 @@
1+
# Class splunk::enterprise
2+
#
3+
# @param version
4+
#
5+
# Specifies the version of Splunk Enterprise the module should install and
6+
# manage. Defaults to the value set in splunk::params.
7+
#
8+
# @param package_name
9+
#
10+
# The name of the package(s) Puppet will use to install Splunk.
11+
#
12+
# @param package_ensure
13+
#
14+
# Ensure parameter which will get passed to the Splunk package resource.
15+
# Defaults to the value in splunk::params.
16+
#
17+
# @param staging_dir
18+
#
19+
# Root of the archive path to host the Splunk package. Defaults to the value in
20+
# splunk::params.
21+
#
22+
# @param path_delimiter
23+
#
24+
# The path separator used in the archived path of the Splunk package. Defaults to
25+
# the value in splunk::params.
26+
#
27+
# @param enterprise_package_src
28+
#
29+
# The source URL for the splunk installation media (typically an RPM, MSI,
30+
# etc). If a `$src_root` parameter is set in splunk::params, this will be
31+
# automatically supplied. Otherwise it is required. The URL can be of any
32+
# protocol supported by the nanliu/staging module. On Windows, this can be
33+
# a UNC path to the MSI. Defaults to the value in splunk::params.
34+
#
35+
# @param package_provider
36+
#
37+
# The package management system used to host the Splunk packages. Defaults to the
38+
# value in splunk::params.
39+
#
40+
# @param manage_package_source
41+
#
42+
# Whether or not to use the supplied `enterprise_package_src` param. Defaults to
43+
# true.
44+
#
45+
# @param package_source
46+
#
47+
# *Optional* The source URL for the splunk installation media (typically an RPM,
48+
# MSI, etc). If `enterprise_package_src` parameter is set in splunk::params and
49+
# `manage_package_source` is true, this will be automatically supplied. Otherwise
50+
# it is required. The URL can be of any protocol supported by the nanliu/staging
51+
# module. On Windows, this can be a UNC path to the MSI. Defaults to undef.
52+
#
53+
# @param install_options
54+
#
55+
# This variable is passed to the package resources' *install_options* parameter.
56+
# Defaults to the value in ::splunk::params.
57+
#
58+
# @param splunk_user
59+
#
60+
# The user to run Splunk as. Defaults to the value set in splunk::params.
61+
#
62+
# @param enterprise_homedir
63+
#
64+
# Specifies the Splunk Enterprise home directory. Defaults to the value set in
65+
# splunk::params.
66+
#
67+
# @param enterprise_confdir
68+
#
69+
# Specifies the Splunk Enterprise configuration directory. Defaults to the value
70+
# set in splunk::params.
71+
#
72+
# @param service_name
73+
#
74+
# The name of the Splunk Enterprise service. Defaults to the value set in
75+
# splunk::params.
76+
#
77+
# @param service_file
78+
#
79+
# The path to the Splunk Enterprise service file. Defaults to the value set in
80+
# splunk::params.
81+
#
82+
# @param boot_start
83+
#
84+
# Whether or not to enable splunk boot-start, which generates a service file to
85+
# manage the Splunk Enterprise service. Defaults to the value set in
86+
# splunk::params.
87+
#
88+
# @param use_default_config
89+
#
90+
# Whether or not the module should manage a default set of Splunk Enterprise
91+
# configuration parameters. Defaults to true.
92+
#
93+
# @param input_default_host
94+
#
95+
# Part of the default config. Sets the `splunk_input` default host. Defaults to
96+
# `facts['fqdn']`.
97+
#
98+
# @param input_connection_host
99+
#
100+
# Part of the default config. Sets the `splunk_input` connection host. Defaults
101+
# to dns.
102+
#
103+
# @param splunkd_listen
104+
#
105+
# The address on which splunkd should listen. Defaults to 127.0.0.1.
106+
#
107+
# @param logging_port
108+
#
109+
# The port to receive TCP logs on. Defaults to the port specified in
110+
# splunk::params.
111+
#
112+
# @param splunkd_port
113+
#
114+
# The management port for Splunk. Defaults to the value set in splunk::params.
115+
#
116+
# @param web_port
117+
#
118+
# The port on which to service the Splunk Web interface. Defaults to 8000.
119+
#
120+
# @param purge_inputs
121+
#
122+
# If set to true, inputs.conf will be purged of configuration that is
123+
# no longer managed by the `splunk_input` type. Defaults to false.
124+
#
125+
# @param purge_outputs
126+
#
127+
# If set to true, outputs.conf will be purged of configuration that is
128+
# no longer managed by the `splunk_output` type. Defaults to false.
129+
#
130+
# @param purge_authentication
131+
#
132+
# If set to true, authentication.conf will be purged of configuration
133+
# that is no longer managed by the `splunk_authentication` type. Defaults to false.
134+
#
135+
# @param purge_authorize
136+
#
137+
# If set to true, authorize.conf will be purged of configuration that
138+
# is no longer managed by the `splunk_authorize` type. Defaults to false.
139+
#
140+
# @param purge_distsearch
141+
#
142+
# If set to true, distsearch.conf will be purged of configuration that
143+
# is no longer managed by the `splunk_distsearch` type. Defaults to false.
144+
#
145+
# @param purge_indexes
146+
#
147+
# If set to true, indexes.conf will be purged of configuration that is
148+
# no longer managed by the `splunk_indexes` type. Defaults to false.
149+
#
150+
# @param purge_limits
151+
#
152+
# If set to true, limits.conf will be purged of configuration that is
153+
# no longer managed by the `splunk_limits` type. Defaults to false.
154+
#
155+
# @param purge_props
156+
#
157+
# If set to true, props.conf will be purged of configuration that is
158+
# no longer managed by the `splunk_props` type. Defaults to false.
159+
#
160+
# @param purge_server
161+
#
162+
# If set to true, server.conf will be purged of configuration that is
163+
# no longer managed by the `splunk_server` type. Defaults to false.
164+
#
165+
# @param purge_transforms
166+
#
167+
# If set to true, transforms.conf will be purged of configuration that
168+
# is no longer managed by the `splunk_transforms` type. Defaults to false.
169+
#
170+
# @param purge_web
171+
#
172+
# If set to true, web.conf will be purged of configuration that is no
173+
# longer managed by the `splunk_web type`. Defaults to false.
174+
#
175+
# @param manage_password
176+
#
177+
# If set to true, Manage the contents of splunk.secret and passwd. Defaults to
178+
# the value set in splunk::params.
179+
#
180+
# @param password_config_file
181+
#
182+
# Which file to put the password in i.e. in linux it would be
183+
# /opt/splunk/etc/passwd. Defaults to the value set in splunk::params.
184+
#
185+
# @param password_content
186+
#
187+
# The hashed password username/details for the user. Defaults to the value set
188+
# in splunk::params.
189+
#
190+
# @param secret_file
191+
#
192+
# Which file we should put the secret in. Defaults to the value set in
193+
# splunk::params.
194+
#
195+
# @param secret
196+
#
197+
# The secret used to salt the splunk password. Defaults to the value set in
198+
# splunk::params.
199+
#
200+
#
201+
class splunk::enterprise (
202+
String[1] $version = $splunk::params::version,
203+
String[1] $package_name = $splunk::params::enterprise_package_name,
204+
String[1] $package_ensure = $splunk::params::enterprise_package_ensure,
205+
String[1] $staging_dir = $splunk::params::staging_dir,
206+
String[1] $path_delimiter = $splunk::params::path_delimiter,
207+
String[1] $enterprise_package_src = $splunk::params::enterprise_package_src,
208+
Optional[String[1]] $package_provider = $splunk::params::package_provider,
209+
Boolean $manage_package_source = true,
210+
Optional[String[1]] $package_source = undef,
211+
Array[String[1]] $install_options = $splunk::params::enterprise_install_options,
212+
String[1] $splunk_user = $splunk::params::splunk_user,
213+
Stdlib::Absolutepath $enterprise_homedir = $splunk::params::enterprise_homedir,
214+
Stdlib::Absolutepath $enterprise_confdir = $splunk::params::enterprise_confdir,
215+
String[1] $service_name = $splunk::params::enterprise_service,
216+
Stdlib::Absolutepath $service_file = $splunk::params::enterprise_service_file,
217+
Boolean $boot_start = $splunk::params::boot_start,
218+
Boolean $use_default_config = true,
219+
String[1] $input_default_host = $facts['fqdn'],
220+
String[1] $input_connection_host = 'dns',
221+
Stdlib::IP::Address $splunkd_listen = '127.0.0.1',
222+
Stdlib::Port $splunkd_port = $splunk::params::splunkd_port,
223+
Stdlib::Port $logging_port = $splunk::params::logging_port,
224+
Stdlib::Port $web_httpport = 8000,
225+
Boolean $purge_alert_actions = false,
226+
Boolean $purge_authentication = false,
227+
Boolean $purge_authorize = false,
228+
Boolean $purge_deploymentclient = false,
229+
Boolean $purge_distsearch = false,
230+
Boolean $purge_indexes = false,
231+
Boolean $purge_inputs = false,
232+
Boolean $purge_limits = false,
233+
Boolean $purge_outputs = false,
234+
Boolean $purge_props = false,
235+
Boolean $purge_server = false,
236+
Boolean $purge_serverclass = false,
237+
Boolean $purge_transforms = false,
238+
Boolean $purge_uiprefs = false,
239+
Boolean $purge_web = false,
240+
Boolean $manage_password = $splunk::params::manage_password,
241+
Stdlib::Absolutepath $password_config_file = $splunk::params::enterprise_password_config_file,
242+
String[1] $password_content = $splunk::params::password_content,
243+
Stdlib::Absolutepath $secret_file = $splunk::params::enterprise_secret_file,
244+
String[1] $secret = $splunk::params::secret,
245+
246+
) inherits splunk {
247+
248+
if (defined(Class['splunk::forwarder'])) {
249+
fail('Splunk Universal Forwarder provides a subset of Splunk Enterprise capabilities, and has potentially conflicting resources when included with Splunk Enterprise on the same node. Do not include splunk::forwarder on the same node as splunk::enterprise. Configure Splunk Enterprise to meet your forwarding needs.'
250+
)
251+
}
252+
253+
contain 'splunk::enterprise::install'
254+
contain 'splunk::enterprise::config'
255+
contain 'splunk::enterprise::service'
256+
257+
Class['splunk::enterprise::install']
258+
-> Class['splunk::enterprise::config']
259+
~> Class['splunk::enterprise::service']
260+
261+
# Purge resources if option set
262+
Splunk_config['splunk'] {
263+
purge_alert_actions => $purge_alert_actions,
264+
purge_authentication => $purge_authentication,
265+
purge_authorize => $purge_authorize,
266+
purge_deploymentclient => $purge_deploymentclient,
267+
purge_distsearch => $purge_distsearch,
268+
purge_indexes => $purge_indexes,
269+
purge_inputs => $purge_inputs,
270+
purge_limits => $purge_limits,
271+
purge_outputs => $purge_outputs,
272+
purge_props => $purge_props,
273+
purge_server => $purge_server,
274+
purge_serverclass => $purge_serverclass,
275+
purge_transforms => $purge_transforms,
276+
purge_uiprefs => $purge_uiprefs,
277+
purge_web => $purge_web
278+
}
279+
280+
}

0 commit comments

Comments
 (0)