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

httpd-nagios.conf.erb undefined method `each' for nil:NilClass #19

Open
pythianali opened this issue Jun 10, 2014 · 10 comments
Open

httpd-nagios.conf.erb undefined method `each' for nil:NilClass #19

pythianali opened this issue Jun 10, 2014 · 10 comments

Comments

@pythianali
Copy link

Hi,

I am using v0.4.7 of the module and have also installed your apache_httpd (v0.4.2) and php (v0.3.12) modules as well. The following error shows up on my puppet run:

Filepath: /etc/puppet/environments/production/modules/nagios/templates/apache_httpd/httpd-nagios.conf.erb
Line: 7
Detail: undefined method `each' for nil:NilClass
at /etc/puppet/environments/production/modules/nagios/manifests/server.pp:20 on node

Whats noticeable is that I do not have a value for apache_httpd_conf_content in my class, which was copied from an older running installation.

Any ideas?

@pythianali
Copy link
Author

I was able to pass this error by adding the following directive in the nagios::server class

apache_allowed_from => '127.0.0.1'

@bartlomiej2
Copy link

Confirming, I have same issue too.

@thias
Copy link
Owner

thias commented Jul 29, 2014

This might be fixed in the master branch of the nagios module, could you maybe try it out and report back?

@bartlomiej2
Copy link

I've install nagios module from git and now it fails with this error:

Error: Could not retrieve catalog from remote server: Error 400 on SERVER: Failed to parse template nagios/apache_httpd/httpd-nagios.conf.erb:
  Filepath: /etc/puppet/modules/nagios/templates/apache_httpd/httpd-nagios.conf.erb
  Line: 4
  Detail: undefined method `empty?' for nil:NilClass
 at /etc/puppet/manifests/classes/nagios_server.pp:5 on node samas
Warning: Not using cache on failed catalog
Error: Could not retrieve catalog; skipping run

I have two questions.

How to define "allowed_from" apache directive in puppet?
I tried this two ways:
apache_allowed_from => [ "192.168.0.0/24" ],
apache_allowed_from => "192.168.0.0/24",
but without any success.

Does nagios module require ruby version > 2? Because I've 1.8.7

ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [i386-linux]

@NMerch
Copy link

NMerch commented Jul 30, 2014

I'm running 1.8.7 on CentOS 6.5 without issue.

$ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [x86_64-linux]
$puppet --version
3.5.1

@bartlomiej2
Copy link

NMerc, can you show how you define "allowed_from" in puppet config for nagios server? Do you use "apache_allowed_from"?

@NMerch
Copy link

NMerch commented Jul 30, 2014

I'm not using it, sorry.

@bartlomiej2
Copy link

Anyway if I delete "apache_allowed_from" from puppet config it fails with error I've listed above.

@thias
Copy link
Owner

thias commented Sep 18, 2014

It should work with apache_allowed_from => [ '192.168.0.0/24' ], as it expects an array. Could you please double check with the git master code?

@andybrucenet
Copy link

Use the Source, Luke.

Solved. Problem is early compilation of template('filename') as in Thias' example:

class { 'nagios::server':
  apache_httpd_ssl             => false,
  apache_httpd_conf_content    => template('my/httpd-nagios.conf.erb'),

That loses; the template causes compile before class variables are available!

I patched Thias' nagios/manifests/server.pp file to permit new variable:

$apache_httpd_conf_content_name    = undef,

Then further down, modified block as follows:

# Set a default content template if no content/source is specified
  # ABr, 20141029: use new variable apache_httpd_conf_content_name
  if $apache_httpd_conf_source == '' {
    if $apache_httpd_conf_content_name != '' {
      # ABr, 20141029: permit late compilation of ERB
      $apache_httpd_conf_content_final = template($apache_httpd_conf_content_name)
    } elsif $apache_httpd_conf_content == '' {
      $apache_httpd_conf_content_final = template("${module_name}/apache_httpd/httpd-nagios.conf.erb")
    } else {
      $apache_httpd_conf_content_final = $apache_httpd_conf_content
    }
  }

That wins! All variables are now available.

Let me know if any interest, I'll post the modified files and send them to Thias.

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

5 participants