Puppet: how do namespaces work with virtual resources, classes, and definitions?

New puppet user trying to wrap his head around namespaces, etc.

I am currently working on a module called user. It has a class unixuserand a class unixgroupin unixuser.ppand unixgroup.pp. I will limit my question to creating users.

init.pp currently contains only:

class user {
  class {'user::unixuser': }
  class {'user::unixgroup': }

  # Create groups before creating users
  Class['user::unixgroup'] -> ['user::unixuser']
}

In unixuser.ppand unixgroup.ppI only want to define virtual resources. The functions that do this should be in functions.ppfor readability.

Question 1: Should it functions.ppcontain only definitions or should definitions be inside a class? So, in the code, it functions.ppshould contain the following:

class user::functions {
  define login ($uid, $gid) {
    user { $title:
      ensure  => present,
      uid     => $uid,
      gid     => $gid,
    }
  }
}

define login user:: functions? , define define user::login - ?

, unixuser.pp () :

class user::unixuser {
  @something { 'admin':
    uid => 1000,
    gid => 1000,
  }
}

, realize nodes.pp - realize User::Something['admin'].

2: user::unixuser login? class user::unixuser inherits user::functions include user::functions class {'user::functions': } ...?

3: 2, @something, user::unixuser functions.pp?

, , .:)

+3
1

, , , :

  # Create groups before creating users
  Class['user::unixgroup'] -> ['user::unixuser']

functions.pp , init.pp:

class user {
  include user::functions
  include user::unixgroup
  include user::unixuser
}

unixuser.pp:

class user::unixuser {
  login { 'admin':
    uid => 1000,
    gid => 1000,
  }
  ...
}
+1

All Articles