1

I'm trying to use puppet to add all my users to a system and add all of them to a single group. However, I keep getting

 Error 400 on SERVER: Duplicate declaration: Group[users] is already declared 
 in file *filename*:17 cannot redeclare at *filename* on node *server*

If I change user to a variable name, like $title, it works fine. How can I do this with a static group name like 'user'? I'm using the below configuration:

NOTE: I might have typos below. I had to retype all this as the system I'm on doesn't have Internet access.

 define users::virtual ($uid, $realname, $password) {
   user { $title:
     ensure => 'present',
     uid => $uid,
     gid => $'users',
     shell => '/bin/bash',
     home => "/home/${title}",
     comment => $realname,
     password => $password,
     managehome => true,
     require => Group ['users'],
 }

   group { 'users':
     ensure => 'present',
     gid => 100,
   }

   file { "/home/${title}":
     ensure => directory,
     owner => $title,
     group => 'users',
     mode => 0700,
     require => [ User[$title], Group['users'] ],
   }
 }

 class users {
   @users::virtual { 'user1':
     uid => 510,
     realname = 'John Doe',
     password = cyphertext
   }

   @users::virtual { 'user2':
     uid => 511,
     realname = 'Jane Doe',
     password = cyphertext
   }
 }

 node 'server' {
   realize (Users::Virtual['user1']
   realize (Users::Virtual['user2']
 }

1 Answer 1

3

The Group['users'] resource shouldn't be within the defined resource users::virtual. You can only create the group once.Move that out to a separate class.

   group { 'users':
     ensure => 'present',
     gid => 100,
   }
3
  • But if I do that, the Group['users'] dependency requirements aren't met anymore.
    – chizou
    May 22, 2014 at 0:54
  • What? I suggested you move it, not remove it. If you move it to another class and include it, then it should work fine.
    – Zoredache
    May 22, 2014 at 0:57
  • Ah, thanks. That worked. I moved it, as you initially suggested, but I didn't include it.
    – chizou
    May 22, 2014 at 1:08

You must log in to answer this question.

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