Ask Your Question
0

Does file_line trigger a "subscribe" on the file?

asked 2016-04-05 08:46:08 -0500

erichymowitz gravatar image

Here is my class definition, in part:

  file { nrpecfg :
    ensure => file,
    path => "/etc/nagios/nrpe.cfg",
  }
  file_line { 'check_file_count_nrpe' :
    line => 'command[check_rsyslog_files]=sudo /usr/lib64/nagios/plugins/check_file_count',
    path => '/etc/nagios/nrpe.cfg',
  }
  exec { nrpereload :
        command => "/sbin/service nrpe reload",
        subscribe => File["/etc/nagios/nrpe.cfg"],
        refreshonly => true,
  }

The "nrpereload" is not happening. It works fine when I take out the subscribe and refreshonly options -- that is, the exec works in general. But when I subscribe to the file, and then I change the file with file_line, it looks like the subscribe doesn't happen.

It works this way:

  file_line { 'check_file_count_nrpe' :
    line => 'command[check_rsyslog_files]=sudo /usr/lib64/nagios/plugins/check_file_count ' ,
    path => '/etc/nagios/nrpe.cfg',
    notify => Exec["nrpereload"],
  }
  exec { nrpereload :
        command => "/sbin/service nrpe reload",
        refreshonly => true,
  }

but it makes more sense (to me) to tell the exec to watch the file, rather than to tell each individual file_line to notify.

Anyway, is subscribe just not supported? Or did I do something wrong?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2016-04-05 11:44:49 -0500

updated 2016-04-05 11:45:10 -0500

I haven't tried this before, but I believe you'll need:

  exec { 'nrpereload':
    command     => '/sbin/service nrpe reload',
    subscribe   => [File['nrpecfg'], File_line['check_file_count_nrpe']],
    refreshonly => true,
  }

As far as Puppet's concerned, the File and File_line are separate resources, and you need to identify resources by their titles when you reference them.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2016-04-05 08:46:08 -0500

Seen: 900 times

Last updated: Apr 05 '16