Glenn Poston
2012-Aug-28 19:51 UTC
[Puppet Users] How to delete previous resources from directory
I''m using hiera to define a list of database engine id''s for a
node. I''m
using this variable to feed into a defined type to create a set of files
(upstart configs). The problem I would like to solve isÅ .
How do I delete files/resources that were previously created but are now
removed (without deleting files that are there by default)?
Here is an example (Please ignore syntax. I hope it''s clear what
I''m trying
to do. If not, let me know).
/hiera/config.yaml
--------------------------------------------------------------
engines:
- 1
- 2
/modules/queue/manifests/upstart.pp
--------------------------------------------------------------
define upstart{
file{"/etc/init/queue-$name.conf":
ensure => file,
content => template(''queue/upstart.conf.erb''),
# The below would be nice, but is not supported
#purge => true,
#ignore => !(queue*)
}
}
/modules/queue/manifests/init.pp
--------------------------------------------------------------
define queue {
upstart::queue{hiera_lookup(''engines''):}
}
Puppet apply will create the following files correctly:
/etc/init/queue-1.conf
/etc/init/queue-2.conf
Now I update the hiera config file to only include 1 engine:
/hiera/config.yaml
--------------------------------------------------------------
engines:
- 1
But the /etc/init/queue02.conf file is not removed.
I can''t purge the directory because there are other scripts in that
directory that I do not want to remove.
If ruby supported extended globs I could use the purge and ignore parameters
to accomplish this.
Is there a good pattern for handling this?
--
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+unsubscribe@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/puppet-users?hl=en.