1

/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?

2 Answers 2

1

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

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

1
0

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'])

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .