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

/etc/puppet/manifests/classes/users.pp

class users
{
define add_user($uname, $comment, $home, $shell, $uid, $gid, $password)
{


# Create the user. This is where most of the magic happens.
user { "$uname":
username => $uname,
ensure => present,
comment => "$comment",
home => "$home",
shell => "$shell",
uid => "$uid",
password => "$password",
gid => "$gid"
}


file { "/home/$uname/":
ensure => directory,
owner => $uname,
group => $gid,
mode => 750,
require => [ user[$uname] ]
}

# And a place with the right permissions for the SSH related configs
file { "/home/$uname/.ssh":
ensure => directory,
owner => $uname,
group => $gid,
mode => 700,
require => file["/home/$uname/"]
}


# Now make sure that the ssh key authorized files is around

file { "/home/$uname/.ssh/authorized_keys":
ensure => present,
owner => $uname,
group => $gid,
mode => 600,
require => file["/home/$uname/.ssh"]
}

}
create_resources(users::add_user, $users)

}

/etc/puppet/manifests/site.pp

"classes/*.pp"
node default{}

yaml output from ENC

---
classes:
  users:
    jeckman:
      comment: Jack
      gid: 100
      home: /home/jeckman
      name: jeckman
      password: $1$hash
      shell: /bin/bash
      uid: 10146
    saga:
      comment: Arun
      gid: 100
      home: /home/saga
      name: saga
      password: $1$hash
      shell: /bin/bash
      uid: 70960
    sandipb:
      comment: Sandip
      gid: 100
      home: /home/sandipb
      name: sandipb
      password: $1$hash
      shell: /bin/bash
      uid: 24838
    vartika:
      comment: Vartika
      gid: 100
      home: /home/vartika
      name: vartika
      password: $1$hash
      shell: /bin/bash
      uid: 38599

When trying to compile it

saga@battleoffer-dr ~]$ sudo puppet master --compile=darkguard-dr.eglbp.corp.company.com --debug --verbose                    
    info: Not using expired node for darkguard-dr.eglbp.corp.company.com from cache; expired at Thu Jul 19 01:21:25 +0530 2012     
    debug: Executing '/etc/puppet/manifests/enc/puppet_enc.py darkguard-dr.eglbp.corp.company.com'                                 
    info: Caching node for darkguard-dr.eglbp.corp.company.com                                                                     
    debug: importing '/etc/puppet/manifests/classes/users.pp' in environment production                                          
    warning: Deprecation notice:  Resource references should now be capitalized on line 29 in file /etc/puppet/manifests/classes/
    users.pp                                                                                                                     
    warning: Deprecation notice:  Resource references should now be capitalized on line 38 in file /etc/puppet/manifests/classes/
    users.pp                                                                                                                     
    warning: Deprecation notice:  Resource references should now be capitalized on line 49 in file /etc/puppet/manifests/classes/
    users.pp                                                                                                                     
    err: Invalid parameter sandipb on node darkguard-dr.eglbp.corp.company.com
    Invalid parameter sandipb on node darkguard-dr.eglbp.corp.company.com

What am i doing wrong?

share|improve this question

2 Answers 2

Dude, your 'require => resource' is wrong.

require resources are called with first letter CAPS, like File, User .. not file, user.

share|improve this answer
    
I have updated that, Thanks. I also asked this question in #puppet-users this solved it! Thank you! groups.google.com/forum/?fromgroups#!topic/puppet-users/… –  zer0c00l Jul 19 '12 at 15:21

I'd imagine variable $user contains incorrect hash do

  file {'/tmp/users.yaml':
         content => inline_template("<%= dbq %><%= YAML::dump(users) %>"),
    }

and examine output. It should look like:

jeckman:
  comment: Jack
  gid: 100
  home: /home/jeckman
  name: jeckman
  password: $1$hash
  shell: /bin/bash
  uid: 10146
saga:
  comment: Arun
  gid: 100
  home: /home/saga
  name: saga
  password: $1$hash
  shell: /bin/bash
  uid: 70960    

if it doesn't, you are passing bad hash

you might want to try:

create_resources(users::add_user, $users['users'])
share|improve this answer

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.