Works fine, thanks!

Le mardi 11 février 2014 02:56:02 UTC-5, Daniele Sluijters a écrit :
>
> Hi,
>
> What you're actually running into is that you want the nagios::commandes 
> class to be executed after the nagios package has been installed.
>
> In that case, use the before metaparameter:
>
> package { 'nagios':
>     ensure => present,
>     before => Class['nagios::commandes'],
> }
>
> This should fix your ordering and ensure everything works as you expect. 
> Generally when you run into an issue with Puppet where you want to 
> conditionally order something al you need are the 
> require/before/notify/subscribe parameters.
>
>
> On Monday, 10 February 2014 23:20:06 UTC+1, Pascal Robert wrote:
>>
>> Hi,
>>
>> I'm using Puppet for the first time, and for my tests, I'm recreating our 
>> Nagios setup into a Puppet modules. It works at 95%, but I do have a 
>> problem: my module include files but I also need to modify a couple of 
>> Nagios configuration files that comes with the Nagios RPM package. Example:
>>
>> commandes.pp:
>>
>> class nagios::commandes {
>>
>> nagios_command { 'process-service-perfdata':
>> command_name => 'process-service-perfdata',
>> ensure => present,
>> command_line => '/usr/bin/perl /usr/libexec/pnp4nagios/
>> process_perfdata.pl',
>> target => '/etc/nagios/objects/commands.cfg',
>> }
>>
>> }
>>
>> init.pp:
>>
>> class nagios {
>>
>>   include nagios::commandes
>>   
>>   package { 'nagios':
>>     ensure => present,
>>   }
>>
>>   package { 'nagios-plugins-all':
>>     ensure => present,
>>   }
>>
>>   package { 'nrpe':
>>     ensure => present,
>>   }
>>
>>   service { 'nagios':
>>     ensure => running,
>>     hasstatus => true,
>>     hasrestart => true,
>>     enable => true,
>>     require => Package["nagios"],
>>   }
>> }
>>
>>
>> It works fine when Nagios is already installed, but if not, the include 
>> of the class in init.pp is done before the package is installed so it fails.
>>
>> Error: Puppet::Util::FileType::FileTypeFlat could not write 
>> /etc/nagios/objects/commands.cfg: No such file or directory - 
>> /etc/nagios/objects/commands.cfg
>> Error: 
>> /Stage[main]/Nagios::Commandes/Nagios_command[process-service-perfdata]: 
>> Could not evaluate: Puppet::Util::FileType::FileTypeFlat could not write 
>> /etc/nagios/objects/commands.cfg: No such file or directory - 
>> /etc/nagios/objects/commands.cfg
>>
>> If there a way to include the class only if the package is installed?
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/062e8774-1d0a-486a-b07b-be8e9933c85f%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to