On Tuesday, October 8, 2013 8:21:43 AM UTC-5, Andreas Dvorak wrote:
>
> Hi,
>
> there is a problem
>
> If I want to add a second user with the same group to the same server I
> get this error:
>
> Error: Could not retrieve catalog from remote server: Error 400 on SERVER:
> Duplicate declaration: Group[baader] is already declared in file
> /etc/puppet/git/modules/accounts/manifests/virtual.pp at line 7; cannot
> redeclare on node vm6741.muc.baag
> Warning: Not using cache on failed catalog
> Error: Could not retrieve catalog; skipping run
>
> How can I solve this?
>
>
Puppet does not allow two declared resources having the same type and the
same name or title. In your case, you get multiple declarations when two
users are assigned to the same group because you (re)declare the group for
each user assigned to it. Thus, the solution is to move the group
declarations outside your accounts::virtual definition. If you wish, you
can use virtual resources here, too, to avoid assigning unneeded groups to
the target node. Example:
class accounts::groups {
Group { ensure => present }
@group {
'group1': gid => 1234;
'group2': gid => 2345;
#...
'groupN': gid => 6789;
}
}
define accounts::virtual($group,
#...
) {
include 'accounts::groups'
user { ${title}:
ensure => present,
gid => $group,
require => Group[$group],
# ...
}
realize Group[$group]
# ...
}
If you have many distinct groups, however, then you will likely find that
it is easier and safer to record them in an external file instead of
modifying your manifests every time you want to manage groups. This is
what hiera() is for. It can be used directly or via Puppet's automatic
data binding mechanism to feed data to Puppet, such as all your (group
name, gid) pairs.
John
--
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.