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

add server parameter on collectd::plugin::network::server #995

Open
wants to merge 1 commit 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
1 change: 1 addition & 0 deletions manifests/plugin/network/server.pp
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
Optional[String] $interface = undef,
Optional[Boolean] $forward = undef,
Optional[Integer[1]] $resolveinterval = undef,
String[1] $server = $name,
) {
include collectd
include collectd::plugin::network
Expand Down
17 changes: 16 additions & 1 deletion spec/defines/collectd_plugin_network_server_spec.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# frozen_string_literal: true

require 'spec_helper'

describe 'collectd::plugin::network::server', type: :define do
on_supported_os(baseline_os_hash).each do |os, facts|
context "on #{os} " do
context "on #{os}" do
let :facts do
facts
end
Expand Down Expand Up @@ -41,6 +43,19 @@
is_expected.to contain_file("#{options[:plugin_conf_dir]}/network-server-node1.conf").with(ensure: 'absent')
end
end

context 'with specifique title' do
let(:title) { 'eatapples' }
let :params do
{ server: '10.0.0.1', port: 1234 }
end

it do
is_expected.to contain_file(
"#{options[:plugin_conf_dir]}/network-server-eatapples.conf"
).with_content(%r{<Server "10\.0\.0\.1" "1234">\n})
end
end
end
end
end
4 changes: 2 additions & 2 deletions templates/plugin/network/server.conf.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Plugin network>
<% if scope.lookupvar('collectd::collectd_version_real') and (scope.function_versioncmp([scope.lookupvar('collectd::collectd_version_real'), '4.7']) >= 0) -%>
<Server "<%= @name %>" "<%= @port %>">
<Server "<%= @server %>" "<%= @port %>">
<% if @securitylevel -%>
SecurityLevel "<%= @securitylevel %>"
<% end -%>
Expand All @@ -18,7 +18,7 @@
<% end %>
</Server>
<% else -%>
Server "<%= @name %>" "<%= @port %>"
Server "<%= @server %>" "<%= @port %>"
<% end -%>
<% if ! @forward.nil? -%>
Forward <%= @forward %>
Expand Down