Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I am trying to set up some virtual users in puppet. The basic users work fine, but for some reason when I try to add "groups" to the user definition the run fails.

Here is the basic virtual user config...

class users::virtual {
    define localuser ($uid,$gid) {

            user { $title:
                    ensure  =>      "present",
                    uid     =>      $uid,
                    gid     =>      $gid,
                    shell   =>      "/bin/bash",
                    home    =>      "/home/$title",
                    comment =>      $realname,
                    managehome =>   true,
            }
      }
}

and here is a user called out...

class my::users {
include users::virtual
    @users::virtual::localuser { "jdehnert": 
    uid =>  "504",
    gid =>  "users",
    groups  =>  ["wheel", "rvm"],
    require =>  Group["rvm"],
    }
}

the init.pp is...

class people {
include my::users
realize (
    Users::Virtual::Localuser["jdehnert"],
    )
}

When I run a test --noop on a client, I get this message on the client...

# puppetd --test --noop
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Invalid parameter groups at /etc/puppet/manifests/users/users.pp:7 on node dev-web-1.

and this one on the server...

Aug 23 04:29:38 centos63 puppet-master[21713]: Invalid parameter groups at /etc/puppet/manifests/users/users.pp:7 on node dev-web-1

If I pull the "groups" line out, this config works just fine.

I also discovered that if I just make a plain user resource I can pass the "groups" parameter just fine. So, why does it not work with a virtual user?

Thanks,

James "Zeke" Dehnert
jdehnert@dehnert.com

share|improve this question

1 Answer 1

You are misunderstanding something here:

@users::virtual::localuser { "jdehnert": 
uid =>  "504",
gid =>  "users",
groups  =>  ["wheel", "rvm"],
require =>  Group["rvm"],
}

Above you are declaring a localuser, which is thus defined:

define localuser ($uid,$gid) {

That means the only parameters it receives are uid, gid and the metaparameters (such as require). Since groups is not a metaparameter nor, obviously, is it uid or gid, then it is invalid.

share|improve this answer
    
Thanks Daniel! There is still a lot about puppet that confuses me. If I was to use define... localuser ($uid,$gid, $groups) then I should be able to declare them I suspect. –  jdehnert Aug 23 '12 at 22:21
    
@jdehnert Correct. You can declare undef as default for $groups, and then you don't need to specify it always. Unfortunately, you'll need an if below to select between a user declaration with groups, and one without. Note too that if you do not pass groups to the user, it will not have one. –  Daniel C. Sobral Aug 23 '12 at 22:49

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.