On Tuesday, July 3, 2012 at 5:31 AM, Itamar Landsman wrote: > Hi All, > > First I want to apologize, I never completely dove into the fine details of > puppet. I just use it on my network of +-100 VMs for odd jobs. > > my question is: I know how to set up a class that would, for example, install > a package on a machine based on a facter variable (e.g. operating system > version). > within the curly braces I can even put a list of operation that would all not > be run if the machine in question does not conform to the specific variable. > > I am looking for a way to do something similar using something like if a file > on the host exists (similar to the 'onlyif' that is available in the exec > type). > > my dream is: > > class foo{ > onlyif "test[ condition ]" { > file{.....} > exec{.......} > } > }
Itamar, You should take a look at the Puppet Language Guide (http://docs.puppetlabs.com/guides/language_guide.html) - and in general the rest of the docs site, in particular Learning Puppet, which might help you with some of the fundamentals. There are a number of ways to express what you are attempting to do, but you nearly have it. If you have a fact "myfile_present" for which the value is true, for instance, you can do the following: class foo { if $::myfile_present == true { file { … } exec { … } } } In the above mentioned Language Guide, check out the section on Conditionals. -Eric -- Eric Shamow Professional Services http://puppetlabs.com/ (c)631.871.6441 -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-users@googlegroups.com. To unsubscribe from this group, send email to puppet-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.