Understanding ResourcesAndRelationships

Martin Marcher
Wed, 12 Dec 2007 02:19:23 -0000

Hello,

we are quite happily using puppet but our setup needs a bit of
cleanup. Forgive me minor errors I''m writing this from scratch now:

The following layout:

--- File site.pp:
import "groups/*"
import "users/*"

node default{
  # I''d like to avoid the following line to be uncommented
  # include "group_users"
  include "user_james"
}

--- File groups/sshallowed_users.pp:
class sshallowed_users{ "sshallowed_users":
  name => "sshallowed",
  ensure => present
}
class group_users{ "group_users":
  name => "users",
  gid => 1000,
  ensure => present
}

--- File users/user_james.pp:
class user_james{ "user_james":
  name => "james",
  gid => "james",
  # This could fail if not all groups are already present
  # for which I''d need require - correct?
  groups => ["sshallowed", "users"]
  # Now this obviously fails
  require => [Group["sshallowed_users"], Group["users"]
],
  ensure => present
}

in users/user_james.pp I''d like to specify that

a) james is in the groups "sshallowed" and "users"
b) then of course require those groups to be present at the time of
creating james.

I could include the group classes in the node but that seems not the
way to go. How do you typically layout such things. Looking at the
best practices I can''t quite figure out how to do that.

Generally how can I require something that i need to import
like
>>import "../groups/*"<< (am I still making sense?). I
think I''m on
the totally wrong track right now as this throws an import loop at
me...

thanks
martin

--