At Tue, 27 May 2014 12:07:30 -0700 (PDT),
Mike  wrote:
> Error 400 on SERVER: Duplicate declaration: Group[test] is already
> declared in file /etc/puppet/modules/users/manifests/add_user.pp:11;
> cannot redeclare at /etc/puppet/modules/users/manifests/add_user.pp:11
> on node master.example.com

any chance you have defined a second user that uses the same group?

your defined type is not going to work in that case for sure. Remember
you can only declare a resource once in any manifest that gets applied
to particular node.

with your code in users::add_user if you define a second user 'bar'
that uses the same secondary group 'test', you are going to define the
resource group { 'test': } a second time, which will fail with a
duplicate declaration error.

You could check if the group test is already defined:

if !defined(Group['test']) {
   group { 'test':}
}

but for this to work you have to move the creation of the secondary group
into a separate defined type (which i would recommend nevertheless):

define users::add_group {
  group,

  if !defined(Group[$group]) {
    group { $group:
      ensure => present,
    }
  }
}

this has the additional advantage that you could extend the defined
type users::add_group with more parameters (ensure, gid, you name it).

hth
toni
--
Don't forget, there is no security | toni at stderr dot at
-- Wulfgar                         | Toni Schmidbauer

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/puppet-users/877g56jubw.wl%25toni%2Bpuppet-users%40stderr.at.
For more options, visit https://groups.google.com/d/optout.

Reply via email to