Eric Snow <es...@verio.net> writes:

> How do you dynamically create classes?

You pretty much can't: puppet is aimed at being a deterministic system, and so
it wants to have a non-programmatic state to achieve.[1]

> For instance, I have a bunch of users to make.  I have all their
> usernames.  Each is the same as the others except for the username and
> one other value.  I don't want to have to spell out a User for each,
> but would rather set up them up dynamically, in a much cleaner way
> (and more maintainable).

The conventional way would be this:

  define my::user () {
    user { $name: whatever => 'foo' }
  }
  my::user { ["one", "two", "red", "blue"]: }

Puppet will create all those resources nicely.

[...]

> As well, I was hoping to set up some defines in the dynamically created user
> so that they could be used from the class's namespace.  The alternative is
> to do them separately and pass in the same information that I already passed
> in to the class, which seems messier than just providing them from the
> class's namespace.

I strongly suspect that a worked example of what you want to do, but that is
failing, would help make the whole thing a lot clearer...

Anyhow, my final bit of (now unsolicited) advice here:

Don't do that anyhow.  Use LDAP, or some other network directory service, to
manage your user accounts.  It hurts way less than trying to do this at scale,
once you start to discover needs for things like consistent UIDs, etc.

Regards,
        Daniel

Footnotes: 
[1]  Like the English language, puppet isn't that pure, and you can work
     around this in a whole bunch of ways.  Pure-ruby manifests in 2.6 might
     be a way to do that, for example.

-- 
✣ 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