- From: Simon Detheridge <
>
- To:
- Subject: [chef] Programmatic creation/deletion of resources
- Date: Thu, 7 May 2015 14:17:17 +0100 (BST)
Hello,
I'm putting together a cookbook to manage nxlog
(
https://git.widgit.com/widgit-cookbooks/nxlog) which manages routing log
data from one place to another. I've created some LWRPs for log sources and
destinations. (nxlog_source, nxlog_destination)
I'd like to add a mechanism to automatically create log sources and
destinations from node attributes. For example:
node['nxlog']['sources'] = [ { some_data }, { different_data } ]
I figured this could be easier in some cases than modifying existing recipes
or creating new ones.
I'm not sure about the best way to go about this... The things I'm currently
stuck on are:
- How do I programatically create a new resource? i.e.
node['nxlog']['sources'].each { |source| create_source(source) }
-- I'm not sure how I would implement `create_source`
- How do I enumerate currently-extant resources so that I can delete ones
that have been removed? (or... is this even possible?)
for example: If I've removed an element from the 'sources' array how can I
ensure that the resource's config file is cleaned up on the node?
Hope this makes sense... Thanks,
Simon
--
Simon Detheridge - CTO, Widgit Software
26 Queen Street, Cubbington, CV32 7NA - Tel: +44 (0)1926 333680
- [chef] Programmatic creation/deletion of resources, Simon Detheridge, 05/07/2015
Archive powered by MHonArc 2.6.16.