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

Change in case for operatingsystem fact on opensuse #184

Open
mattqm opened this issue Jul 16, 2022 · 0 comments
Open

Change in case for operatingsystem fact on opensuse #184

mattqm opened this issue Jul 16, 2022 · 0 comments

Comments

@mattqm
Copy link
Contributor

mattqm commented Jul 16, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant