Adding users to groups

592 views
Skip to first unread message

Oliver Beattie

unread,
Jul 22, 2011, 8:31:19 AM7/22/11
to puppet...@googlegroups.com
I have a definition like this in one of my manifests:

group { 'foo':
    ensure => present,
}

user { 'bar':
    ensure => present,
    groups => ['foo'],
    managehome => true,
    home => '/home/bar',
    shell => '/usr/sbin/nologin',
    require => Group['deploy'],
}

When I run it, however, I get this error:

err: /Stage[main]/App-server/User[deploy]/ensure: change from absent to present failed: Could not create user deploy: Execution of '/usr/sbin/useradd -d /home/deploy -G deploy -s /usr/sbin/nologin -m deploy' returned 9: useradd: group deploy exists - if you want to add this user to that group, use -g.

What can I do to fix this? I don't always want to assign the user to that group as its primary?

—Oliver 

Oliver Beattie

unread,
Jul 22, 2011, 8:33:06 AM7/22/11
to puppet...@googlegroups.com
(I should point out, the user was called deploy in the actual manifest :-)

Martin Alfke

unread,
Jul 22, 2011, 10:04:41 AM7/22/11
to puppet...@googlegroups.com
Hi,
Is this a Debian system?
On Debian the user add command automatically adds a primary group with the same name as the username.

What happens when you run the useradd command directly?

Kind regards,

Martin



Oliver Beattie

unread,
Jul 22, 2011, 10:23:57 AM7/22/11
to puppet...@googlegroups.com
Hi,

Yes, this is Debian (Ubuntu). If I specify groups (not gid) surely the groups the user gets added to should be secondary, not primary?

If I run the command directly I get the same error (although not if I lowercase the g of course).

—Oliver

Martin Alfke

unread,
Jul 22, 2011, 11:21:50 AM7/22/11
to puppet...@googlegroups.com
OK.

I assume you need to give the gid parameter for primary group to your manifest.



—Oliver

--
You received this message because you are subscribed to the Google Groups "Puppet Users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/puppet-users/-/M_HplM5p9loJ.
To post to this group, send email to puppet...@googlegroups.com.
To unsubscribe from this group, send email to puppet-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/puppet-users?hl=en.

Reply all
Reply to author
Forward
0 new messages