Hi, Thanks for your help. I tried the stuff. It works. Learing somethng new everday.
On 27 Apr., 19:22, Nan Liu <n...@puppetlabs.com> wrote: > On Wed, Apr 27, 2011 at 8:17 AM, linuxbsdfreak <linuxbsdfr...@gmail.com> > wrote: > > Hi, > > > Thanks for your reply. The problem with the tagging is solved. However > > i am confused with the 2nd part. I actually want to do somethng like > > this to delete files: > > > I am creating a class called config_variables in which i want to have > > an array of dirs of files to delete: > > > class config_variables { > > > $oldfilestoremove = [ "file1", "file2" ] > > $path_to_data = "/tmp" > > $path_to_data2 = "/opt" > > > } > > > Then i want to declare another class according to different > > environments. However i would like to do some sort of if condition > > with the path variable and change it according to different > > environments using the tags. The purge-data is a general define i have > > and has a delete function which uses the $name variable and the path > > variable defined below as parameters: > > > class purge_old_data inherits config_variables { > > > purge-data::delete{ > > $oldfilestoremove > > if tagged(tst_env) or if tagged(stg_env) > > { > > path => "$path_to_data", > > } > > if tagged(prd_env) > > { > > path => "$path_to_data2", > > } > > > } > > } > > You can't use an if statement within a resource declaration only > selectors. So do the if conditional before you declare > purge-data::delete custom resource. > > if ... { > $my_path = $path_to_data} elsif ... { > > $my_path = $path_to_data2 > > } > > purge-data::delete { $oldfilestoremove: > path => $my_path, > > } > > Thanks, > > Nan -- 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.