voxpupuli / puppet-nrpe

Puppet module for NRPE
http://forge.puppetlabs.com/puppet/nrpe
Apache License 2.0
2 stars 14 forks source link

Support IP addresses with subnets in allowed_hosts #47

Closed mleiner closed 3 years ago

mleiner commented 3 years ago

This fixes Issue #46.

allowed_hosts of nrpe.cfg can be set to

The current code uses Stdlib::Host which ultimatively resolves to FQDNs and pure IP addresses, but not subnets. It uses Stdlib::Compat, too.

Changing Stdlib::Host to Variant[Stdlib::Fqdn,Stdlib::IP::Address] solves this by

This gets rid of the Stdlib::Compat layer and allows allowed_hosts to accept IP addresses with subnets, too.

I have not found any spec tests for allowed_hosts, thus didn't change existing ones. I can try to add those if you like.

I've tested locally with

nrpe::allowed_hosts:
  - "::1"
  - "2001::/96"
  - "127.0.0.1"
  - "192.168.0.0/24"

Improvement suggestions welcome

egmont1227 commented 3 years ago

@alexjfisher @bastelfreak @blkperl can you have a look and merge this ?

bastelfreak commented 3 years ago

thanks for the work! can you please add some tests in https://github.com/voxpupuli/puppet-nrpe/blob/master/spec/classes/nrpe_spec.rb that verify it works with the different ip/cidr/fqdn formats?

mleiner commented 3 years ago

@bastelfreak I've fixed the syntax and added positive spec tests for allowed_hosts. I skipped negative tests since I expect stdlib to catch type mismatches. Is that correct?

bastelfreak commented 3 years ago

looks good to me. can you take a look at the indentation in templates/nrpe.cfg.epp ?

mleiner commented 3 years ago

I have fixed the template syntax, too. Sorry for not checking while I already worked on init.pp.

bastelfreak commented 3 years ago

thanks!

mleiner commented 3 years ago

Are you planning a new release?

bastelfreak commented 3 years ago

I would like to, but that's currently blocked by https://github.com/voxpupuli/puppet-nrpe/pull/48