Skip to content

Commit 403f81b

Browse files
committed
Modify linux_forwarder to template outputs.cfg
Just like windows. This approach seems potentially less flexible eventually, but eliminates one need to keep track of the admin password for performing changes. It should be the case that Puppet is always able to update local config.
1 parent 25ae98f commit 403f81b

File tree

1 file changed

+12
-11
lines changed

1 file changed

+12
-11
lines changed

manifests/linux_forwarder.pp

+12-11
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
class splunk::linux_forwarder {
2+
3+
$server = $splunk::params::logging_server
4+
$port = $splunk::params::logging_port
5+
26
file {"${splunk::params::linux_stage_dir}":
37
ensure => directory,
48
owner => "root",
@@ -18,22 +22,12 @@
1822
},
1923
notify => Exec['start_splunk'],
2024
}
21-
# firewall { "100 allow Splunkd":
22-
# action => "accept",
23-
# proto => "tcp",
24-
# dport => "${splunk::params::splunkd_port}",
25-
# }
25+
2626
exec {"start_splunk":
2727
creates => "/opt/splunkforwarder/etc/licenses",
2828
command => "/opt/splunkforwarder/bin/splunk start --accept-license",
2929
timeout => 0,
3030
}
31-
exec {"set_forwarder_port":
32-
unless => "/bin/grep \"server \= ${splunk::params::logging_server}:${splunk::params::logging_port}\" /opt/splunkforwarder/etc/system/local/outputs.conf",
33-
command => "/opt/splunkforwarder/bin/splunk add forward-server ${splunk::params::logging_server}:${splunk::params::logging_port} -auth ${splunk::params::splunk_admin}:${splunk::params::splunk_admin_pass}",
34-
require => Exec['set_monitor_default'],
35-
notify => Service['splunk'],
36-
}
3731
exec {"set_monitor_default":
3832
unless => "/bin/grep \"\/var\/log\" /opt/splunkforwarder/etc/apps/search/local/inputs.conf",
3933
command => "/opt/splunkforwarder/bin/splunk add monitor \"/var/log/\" -auth ${splunk::params::splunk_admin}:${splunk::params::splunk_admin_pass}",
@@ -55,4 +49,11 @@
5549
hasrestart => true,
5650
require => File['/etc/init.d/splunk'],
5751
}
52+
53+
file { '/opt/splunkforwarder/etc/system/local/outputs.conf':
54+
ensure => file,
55+
content => template('splunk/outputs.conf.erb'),
56+
require => Package['splunkforwarder'],
57+
notify => Service['splunk'],
58+
}
5859
}

0 commit comments

Comments
 (0)