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

Fix listen_ip bug and relax interface regex #494

Merged
merged 3 commits into from
Mar 29, 2018
Merged
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
2 changes: 1 addition & 1 deletion manifests/agent.pp
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,7 @@
# can find the ipaddress of this specific interface if listenip
# is set to for example "eth1" or "bond0.73".
$listen_ip = $listenip ? {
/^(eth|lo|bond|lxc|eno|tap|tun|virbr).*/ => fact("networking.interfaces.${listen_ip}.ip"),
/^(e|lo|bond|lxc|tap|tun|virbr).*/ => fact("networking.interfaces.${listenip}.ip"),
'*' => undef,
default => $listenip,
}
Expand Down
41 changes: 41 additions & 0 deletions spec/acceptance/agent_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,47 @@ class { 'zabbix::agent':
it { is_expected.to be_running }
it { is_expected.to be_enabled }
end

describe file('/etc/zabbix/zabbix_agentd.conf') do
its(:content) { is_expected.not_to match %r{ListenIP=} }
end
end
end
end

describe 'zabbix::agent class' do
context 'With ListenIP set to an IP-Address' do
it 'works idempotently with no errors' do
pp = <<-EOS
class { 'zabbix::agent':
server => '192.168.20.11',
zabbix_package_state => 'latest',
listenip => '127.0.0.1',
zabbix_version => '3.4'
}
EOS
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
describe file('/etc/zabbix/zabbix_agentd.conf') do
its(:content) { is_expected.to match %r{ListenIP=127.0.0.1} }
end
end
context 'With ListenIP set to lo' do
it 'works idempotently with no errors' do
pp = <<-EOS
class { 'zabbix::agent':
server => '192.168.20.11',
zabbix_package_state => 'latest',
listenip => 'lo',
zabbix_version => '3.4'
}
EOS
apply_manifest(pp, catch_failures: true)
apply_manifest(pp, catch_changes: true)
end
describe file('/etc/zabbix/zabbix_agentd.conf') do
its(:content) { is_expected.to match %r{ListenIP=127.0.0.1} }
end
end
end