Hello,
 
I have written a module to add user and it does work with one user. But if 
I use two user puppet tells me:
Error: Could not retrieve catalog from remote server: Error 400 on SERVER: 
Duplicate declaration: Group[badm] is already declared in file 
/etc/puppet/git/modules/useradd/manifests/init.pp at line 9; cannot 
redeclare on node vm6740.muc.baag
 
How can I change the group creating part to get rid of this error?
 
 
Here is my module file
~/git/test.git/modules/useradd/manifests$ cat init.pp 
define useradd ( $name, $uid, $group, $gid, $password, $shell, $sshkeytype, 
$sshkey) {
   $homedir = $kernel ? {
      'SunOS' => '/export/home',
      default   => '/home'
   }
   group { $group:
      gid => "$gid",
   }
   $username = $title
   user { $username:
      ensure => present,
      comment => "$name",
      uid => "$uid",
      gid => "$gid",
      shell => "$shell",
      home => "$homedir/$username",
      managehome => true,
      password => "$password",
      require => group["$group"],
   }
   exec { $username:
      command => "/bin/cp -R /etc/skel $homedir/$username; /bin/chown -R 
$username:$group $homedir/$username ",
      creates => "$homedir/$username",
      require => user["$username"],
   }
   ssh_authorized_key { $username:
      user => "$username",
      type => "$sshkeytype",
      key => "$sshkey",
      require => exec["$username"],
   }
}
and here are the manifests files.
~/git/test.git/manifests$ cat nodes.pp 
node 'vm6739' {
   include git_puppet_update
}
node 'vm6740' {
   import "create_admin_user.pp"
}
 
~/git/test.git/manifests$ cat create_admin_user.pp
useradd { "test":
   name => "test",
   uid => "881",
   gid => "888",
   group => "badm",
   shell => "/bin/bash",
   password => 
'Yvrp7r/L.ah8AliUXLMM9LZN/hQOtaYXUXNFQ8kOaqzUp1/jkH61SaE7gz/',
   sshkeytype => "rsa",
   sshkey => 
"5j5llTO3cVcbPQYlII/5Arzwnj5gyzpm3xZL3o9vaAX1pA4F1Lq87ZBrZxrTS2F0G7hHJDffhqwlYoWfl1755hWeNeNZWQBcF2",
}
useradd { "testuser1":
   name => "test user1",
   uid => "2012",
   gid => "888",
   group => "badm",
   shell => "/bin/bash",
   password => 
'$6$0vY.Ob.b$uOClxSzliv.Jxt1XoWXjbLXtnf5JzqL5pP.caiF0JMxjptxEq9gj72KrU7CqB7ez0gCt6fAB1',
   sshkeytype => "rsa",
   sshkey => 
"AAAAB3NzaC1yc2EAAAADAQABAAABAQC8tCVus/i5CN8KpqsEy1L3KIa0xRS9/QqgNc39q877hHJDffhqwlYoWfl1755hWeNeNZWQBcF2",
}
 

-- 
You received this message because you are subscribed to the Google Groups 
"Puppet Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/puppet-users.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to