Skip to content

Commit 4943084

Browse files
committed
add server parameter on collectd::plugin::network::server
This feature include the possibility to add a specific title on `collectd::plugin::network::server` for the configuration file name. The server should be define with the `server` option.
1 parent 12791f3 commit 4943084

File tree

3 files changed

+19
-3
lines changed

3 files changed

+19
-3
lines changed

manifests/plugin/network/server.pp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
Optional[String] $interface = undef,
99
Optional[Boolean] $forward = undef,
1010
Optional[Integer[1]] $resolveinterval = undef,
11+
String[1] $server = $name,
1112
) {
1213
include collectd
1314
include collectd::plugin::network

spec/defines/collectd_plugin_network_server_spec.rb

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
# frozen_string_literal: true
2+
13
require 'spec_helper'
24

35
describe 'collectd::plugin::network::server', type: :define do
46
on_supported_os(baseline_os_hash).each do |os, facts|
5-
context "on #{os} " do
7+
context "on #{os}" do
68
let :facts do
79
facts
810
end
@@ -41,6 +43,19 @@
4143
is_expected.to contain_file("#{options[:plugin_conf_dir]}/network-server-node1.conf").with(ensure: 'absent')
4244
end
4345
end
46+
47+
context 'with specifique title' do
48+
let(:title) { 'eatapples' }
49+
let :params do
50+
{ server: '10.0.0.1', port: 1234 }
51+
end
52+
53+
it do
54+
is_expected.to contain_file(
55+
"#{options[:plugin_conf_dir]}/network-server-eatapples.conf"
56+
).with_content(%r{<Server "10\.0\.0\.1" "1234">\n})
57+
end
58+
end
4459
end
4560
end
4661
end

templates/plugin/network/server.conf.erb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<Plugin network>
22
<% if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '4.7']) >= 0) -%>
3-
<Server "<%= @name %>" "<%= @port %>">
3+
<Server "<%= @server %>" "<%= @port %>">
44
<% if @securitylevel -%>
55
SecurityLevel "<%= @securitylevel %>"
66
<% end -%>
@@ -18,7 +18,7 @@
1818
<% end %>
1919
</Server>
2020
<% else -%>
21-
Server "<%= @name %>" "<%= @port %>"
21+
Server "<%= @server %>" "<%= @port %>"
2222
<% end -%>
2323
<% if ! @forward.nil? -%>
2424
Forward <%= @forward %>

0 commit comments

Comments
 (0)