Add ranges to the puppet DSL
Currently for a resource that may take a number as a namevar, declaring multiple resources looks something like this:
This is easy for small numbers of resources, but when declaring 100s or 1000s of these types of resources its get very tiresome to type (or script) the values needed and paste them in. What I am suggesting is a range operator to populate an array with the values of a range. Something like this:
This may not be a big deal for small use-cases, but we have a situation where we are declaring upwards of a 100 resources and the following manifest would be much easier to maintain:
I have a work-around for my implementation which parses the namevar as if its a range and handles the management of multiple resources in the provider, however this method is very hacky and prevents me from using self.instances and self.prefetch as they operate under the assumption that only a single resource is used.
My implementation looks like this:
An alternative solution to the same problem is to support more looping than just iterations. For example if I have two part namevars (which I also have), for example a location and an ip make up the name var, I could generate an array that way. For example, instead of this:
We generate an array: (This is Ruby, not DSL, I don't know how this would look in DSL)
Which can easily scale to:
To manage a huge amount of resources. My current implementation looks like this: (Also handles multiple resources through a single provider)
I think that ranges and more advanced looping would be a great addition to the Puppet DSL, especially in fields like networking where we deal with managing large volumes of IP related resources.