puppet-fail2ban icon indicating copy to clipboard operation
puppet-fail2ban copied to clipboard

Change in case for operatingsystem fact on opensuse

Open mattqm opened this issue 2 years ago • 0 comments

Affected Puppet, Ruby, OS and module versions/distributions

  • Puppet: 7.17.0
  • Facter: 4.2.10
  • Ruby: 2.5.9p229 (2021-04-05 revision 67939) [aarch64-linux-gnu]
  • Distribution: openSUSE 15.4
  • Module version: latest

How to reproduce (e.g Puppet code you use)

just calling in the module to write jail.conf

What are you seeing

cannot find template file

What behaviour did you expect instead

found template file

Output log

Error: Could not retrieve catalog from remote server: Error 500 on SERVER: Server Error: Evaluation Error: Error while evaluating a Resource Statement, Evaluation Error: Error while evaluating a Function Call, Could not find template 'fail2ban/openSUSE/15/etc/fail2ban/jail.conf.epp' (file: /etc/puppetlabs/code/environments/dev/modules/fail2ban/manifests/init.pp, line: 51, column: 26) on node blah

Any additional information you'd like to impart

It seems the newer version of facter is reporting the operating system name differently: facter 3.14.12 reports OpenSuSE facter 4.2.10 reports openSUSE

This will fix it:

git diff

diff --git a/manifests/init.pp b/manifests/init.pp
index bebc12b..806408b 100644
--- a/manifests/init.pp
+++ b/manifests/init.pp
@@ -48,7 +48,7 @@ class fail2ban (
   Hash $sendmail_config = {},
   Hash $sendmail_actions = {},
 ) {
-  $config_file_content = extlib::default_content($config_file_string, $config_file_template)
+  $config_file_content = extlib::default_content($config_file_string, $config_file_template.downcase)

   if $config_file_hash {
     create_resources('fail2ban::define', $config_file_hash)

	renamed:    CentOS/6/etc/fail2ban/jail.conf.epp -> centos/6/etc/fail2ban/jail.conf.epp
	renamed:    CentOS/7/etc/fail2ban/jail.conf.epp -> centos/7/etc/fail2ban/jail.conf.epp
	renamed:    Debian/10/etc/fail2ban/jail.conf.epp -> debian/10/etc/fail2ban/jail.conf.epp
	renamed:    Debian/11/etc/fail2ban/jail.conf.epp -> debian/11/etc/fail2ban/jail.conf.epp
	renamed:    Debian/8/etc/fail2ban/jail.conf.epp -> debian/8/etc/fail2ban/jail.conf.epp
	renamed:    Debian/9/etc/fail2ban/jail.conf.epp -> debian/9/etc/fail2ban/jail.conf.epp
	renamed:    OpenSuSE/15/etc/fail2ban/jail.conf.epp -> opensuse/15/etc/fail2ban/jail.conf.epp
	renamed:    RedHat/6/etc/fail2ban/jail.conf.epp -> redhat/6/etc/fail2ban/jail.conf.epp
	renamed:    RedHat/7/etc/fail2ban/jail.conf.epp -> redhat/7/etc/fail2ban/jail.conf.epp
	renamed:    RedHat/8/etc/fail2ban/jail.conf.epp -> redhat/8/etc/fail2ban/jail.conf.epp
	renamed:    RedHat/9/etc/fail2ban/jail.conf.epp -> redhat/9/etc/fail2ban/jail.conf.epp
	renamed:    Ubuntu/16.04/etc/fail2ban/jail.conf.epp -> ubuntu/16.04/etc/fail2ban/jail.conf.epp
	renamed:    Ubuntu/18.04/etc/fail2ban/jail.conf.epp -> ubuntu/18.04/etc/fail2ban/jail.conf.epp
	renamed:    Ubuntu/20.04/etc/fail2ban/jail.conf.epp -> ubuntu/20.04/etc/fail2ban/jail.conf.epp

I'm happy to submit a PR for this, but I imagine all the test cases need to be updated also. Since this is not a PDK module, how do I run the test cases to check whether they need updating. Also are people happy with this strategy - I'm not sure how else to get both situations to work.

mattqm avatar Jul 16 '22 01:07 mattqm