On Sunday, October 21, 2012 11:37:25 AM UTC-5, Panaman wrote: > > Is it possible to use regex to ensure directories are deleted..... > > I want to be able to do something like: > > file { '/var/directory[1-9]': > ensure => absent, > } > > Would also be nice to use regex to ensure directories are present... >
Puppet is not a scripting language. You can dress up this sort of thing in various ways, but in the end you need to either create a separate resource for each file you want to manage (directly), or use an Exec. For example, you could do this: define patternfile($pattern, $replace) { $filename = regsubst($pattern, $replace, $name) file { $filename: ensure => absent } } patternfile { [1, 2, 3, 4, 5, 6, 7, 8, 9]: pattern => '/var/directoryREPLACEME', $replace => 'REPLACEME' } You could write something slightly more concise in Puppet's Ruby DSL, but it would still amount to declaring a separate resource for each file you want to ensure absent. In practice, what you ask, in the general form about which you ask, is not often the best approach to the task. It may help to step back and look at the bigger picture. John -- You received this message because you are subscribed to the Google Groups "Puppet Users" group. To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/t2p2h6GEZ8MJ. 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.