"russell.fulton" <russell.ful...@gmail.com> writes:

I am going to mostly use this as a soapbox to expound on how I do this sort of
thing, but will answer your questions along the way.  I hope you don't mind. :)

> I have a requirement to generate several very similar config files
> which are just a couple of tokens different and with different names.

...so, at this point I am thinking that this is a pretty clear case for
modelling each individual configuration file as a puppet 'define', because you
can have more than one of them, and they are almost-but-not-quite identical.

> These are barnyard conf files if anyone is interested and differ only in the
> interface name which is also part of the file name.  I can include [eth1,
> eth2] in the manifest and I want to get files:

So, I would look to something like this:

modules/barnyard/manifests/config.pp

define barnyard::config () {
  file { "/path/to/config.${name}":
    # ...
    content => template('barnyard/config.erb')
}

modules/barnyard/templates/config.erb
[<%= name %>]
# ...

manifests/nodes.pp

node "example.com" {
  barnyard::config { ["eth0", "eth1"]: }
  # ...or do I want this:
  barnyard::config { split($interfaces, ','): }
}


Anyway, the essential point is that when you identify a collection of things
that are similar but not identical, and are all related to a single "product"
you generally want to use a 'define' to model them.

Look to where your software management treats things like objects and
instances in traditional programming, and leverage that to model the data.

Regards,
        Daniel
-- 
✣ Daniel Pittman            ✉ dan...@rimspace.net            ☎ +61 401 155 707
               ♽ made with 100 percent post-consumer electrons

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To post to this group, send email to puppet-us...@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.

Reply via email to