Skip to content
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
34 changes: 34 additions & 0 deletions spec/classes/splunk_ouputs_indexandforward_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,5 +30,39 @@
it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/server = server1.example.com:50514/) }
it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/indexAndForward = True/) }
end
describe "with multiple servers in target group" do
let(:params) { {
:configure_outputs => true,
:indexandforward => true,
:port => '50514',
:path => '/opt/splunk/etc/system/local',
:output_hash => { },
:target_group => { "example1" => ["server1.example.com","server2.example.com"] }
} }

it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/[tcpout]/) }
it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/defaultGroup = example1/) }
it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/disabled = false/) }
it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/tcpout:example1/) }
it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/server = server1.example.com:50514,server2.example.com:50514/) }
it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/indexAndForward = True/) }
end
describe "with an Array of server in target group" do
let(:params) { {
:configure_outputs => true,
:indexandforward => true,
:port => '50514',
:path => '/opt/splunk/etc/system/local',
:output_hash => { },
:target_group => { "example1" => ["server1.example.com"] }
} }

it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/[tcpout]/) }
it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/defaultGroup = example1/) }
it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/disabled = false/) }
it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/tcpout:example1/) }
it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/server = server1.example.com:50514/) }
it { should contain_file('/opt/splunk/etc/system/local/outputs.conf').with_content(/indexAndForward = True/) }
end
end
end
5 changes: 4 additions & 1 deletion templates/opt/splunk/etc/system/local/outputs.conf.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ disabled = <%= @tcpout_disabled %>

<% @groupkeys.sort.each do |group| -%>
[tcpout:<%= group -%>]
<% if @target_group[group].is_a?(Array) -%>
server = <%= @target_group[group].map { |server| "#{server}:#{@port}"}.join(',') %>
<% else -%>
server = <%= @target_group[group] -%>:<%= @port %>

<% end -%>
<% end -%>
<% end -%>
<% if @indexandforward == true || @indexandforward == 'true' || @indexandforward == 'True' -%>
Expand Down