You are on the right track with the External Node Classifier. It is a bit difficult to wrap your head around, but one you get it working you will never look back and I cannot recommend doing it strongly enough. I went to the puppet IRC room when i had trouble and they helped me get mine working.
Applying different modules based on OS is fine. I run a 300+ node environment with BSD and RHEL and we do it. Instead of having the the OS be a node, we have it as own class because . So instead of "node OS inherits basenode", we do have the ENC pass back something like this:
node web-prod-007 {
$node_environment="production"
include web_server_class # this then inherits basenode
include centos6::server #
include logging::rsyslog
}
...etc
how you do it depends on how you want your inheritance to work, if you want to modify the things in basenode depending on operating system, then having OS inherit basenode is the right way to go.
TLDR, what you are doing is okay, and look into ENC's because they make life easier.
EDIT: 2. I dont use Dashboard so I dont know.
Two things regarding your puppet code.
The define should be in it's own file (named add_user.pp, and located in the <modulename>/manifests/
folder) , rather than in the class file.
Set the define up (change $name to $username, as $name is a reserved variable), and then add the same set of parameters as the define uses to the class. (which in your example would be $modulepath/users/manifests/add.pp
to make it work with the autoloader)
If you change the class as follows:
class users::add( $u_name, $u_comment, $u_home, $u_shell, $u_uid, $u_gid, $u_password)
{
users::add_user{ $u_name:
$username => $u_name,
$comment => $u_comment,
$home => $u_home,
$shell => $u_shell,
$uid => $u_uid,
$gid => $u_gid,
$password => $u_password,
}
}
And change the site.pp to:
import "classes/*.pp"
node default{
class { 'add_user':
username => "saga",
comment => "Arun Sag",
gid => "100",
home => "/home/saga",
password => '$1$passwordhash/',
shell => "/bin/bash",
uid => "70960",
}
}
For the yaml, something like this will do it, please refer to the documentation for more details:
---
classes:
users::add:
parameters:
name: some_name
comment: some_comment
home: home_value
shell: /bin/sh
uid: 3990
gid: 3990
password: superstrongpassword
environment:
production
Best Answer
One approach to this is expressed in Designing Puppet – Roles and Profiles. The basic tenets are as follows: