On Friday, March 1, 2013 2:00:24 PM UTC-6, Tiago Cruz wrote:
>
> Hello all!
>
> I would like to install one package, but only with some condition was ok, 
> like:
>
>  package { "nagios-plugins-basic":
>     ensure => "1.4.15-personal1",
>     unless => "test `ls -ld /opt/nrpe* 2>/dev/null | wc -l` -ge 1",
>   }
>
> but this not work =/
>
> Could not retrieve catalog from remote server: Error 400 on SERVER: 
> Invalid parameter unless at 
> /etc/puppet/modules/nagios/manifests/ubuntu.pp:13 on node 
> domu-12-31-39-0c-24-ce.compute-1.internal
>
> How can I do this?
>
>
If you must do that, then you need to create a custom fact (it's not 
difficult) to report on the condition you want to test (for example, the 
output of `ls -ld /opt/nrpe* 2>/dev/null | wc -l).  Then put your Package 
declaration in an 'if' or 'case' block that selects the desired behavior 
based on the fact value.

With that said, you are probably going about this the wrong way.  It is 
usually better to centralize decisions about how nodes are supposed to be 
configured on the master.  In this case, that would mean Puppet knows, 
based on essential characteristics of the node such as its name, network, 
etc., not only whether the nagios plugins should be present, but also 
whether nrpe should be present.  It can then ensure *both* are installed if 
they are supposed to be there (or that they are absent otherwise).

Also, you should consider whether you are making unnecessary work for 
yourself.  It may be that you are duplicating work that your package 
management system would be happy to do for you.


John

-- 
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 post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to