On 01/07/2011 03:27 PM, Ace wrote: > Can you please state an example explaining how relating classes would > execute one class before another?
Ace, in this simple case, you could probably get away with define appendifnosuchline($file="", $line="") { exec { "appendline_${file}_${line}": path => "/bin:/usr/bin", command => "/bin/echo ${line} >> ${file}", unless => "grep -qx ${line} ${file}", require => File[$file], } } Note the require parameter to the exec resource. This will prevent you from using this define on non-puppetmanaged files though. For more flexibility: define appendifnosuchline($file="", $line="", $disable_autorequire => false) { if !$disable_autorequire { Exec { require => File[$file] } } exec { "appendline_${file}_${line}": path => "/bin:/usr/bin", command => "/bin/echo ${line} >> ${file}", unless => "grep -qx ${line} ${file}", } } Then specify "disable_autorequire => true" where applicable. The third route is not to touch the define at all and add the require each time you declare it as a resource. But that's redundant, and we don't like that. There, much safer now ;) Cheers, Felix -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To post to this group, send email to puppet-us...@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.