Salt useradd failing

1,659 views
Skip to first unread message

Duane Crouch

unread,
Apr 11, 2012, 12:24:09 PM4/11/12
to salt-...@googlegroups.com
Perhaps I'm overlooking something.  - Likely

initial.sls
test:
    user:
        - present
        - shell: /bin/bash
        - home: /home/test
        - groups:
            - test


[INFO    ] Executing command useradd -s /bin/bash -G test -m -d /home/test test in directory /root
[ERROR   ] No changes made for test
[ERROR   ] No changes made for test


local:
----------
    State: - user
    Name:      test
    Function:  present
        Result:    False
        Comment:   Failed to create new user test
        Changes:   

Trying the command I get the following.
useradd: group test exists - if you want to add this user to that group, use -g.

I'm looking to require the group exists, not sure what's typical to do here.  

I've been testing creating a group, and using absent to remove the group, but still received the error.  The state file will continually grow and the account will have useful utilities, but if I can't get the user/group setup properly requirements transferring files to the directory will not function correctly.

Thomas S Hatch

unread,
Apr 11, 2012, 12:32:47 PM4/11/12
to salt-...@googlegroups.com
I just made a lot of changes to useradd in git and it still needs some work, are you running from git?

Duane Crouch

unread,
Apr 11, 2012, 12:35:16 PM4/11/12
to salt-...@googlegroups.com
After so many snapshots and failures on my own part.  

I'll try and grab from git, any specific branch?

Duane Crouch

unread,
Apr 11, 2012, 12:36:37 PM4/11/12
to salt-...@googlegroups.com
Oh, I believe it was yum on centos 6, and git on Ubuntu.

Thomas S Hatch

unread,
Apr 11, 2012, 12:49:43 PM4/11/12
to salt-...@googlegroups.com
Oh, are you declaring and then requiring the group? you need to make sure the group exists before assigning a user to it

Duane Crouch

unread,
Apr 11, 2012, 1:07:23 PM4/11/12
to salt-...@googlegroups.com
Here's the data I'm working with salt state and output.

I've been trying to create user/group.  I've tested using the command output, before I was, not, though I realized groups was the cause.  The trouble I'm having is even ensuring group is created it seems to be a flag with the useradd state.

Thomas S Hatch

unread,
Apr 11, 2012, 1:13:35 PM4/11/12
to salt-...@googlegroups.com
could you add a:

require:
  - group: dcrouch

to your user state dec?

Duane Crouch

unread,
Apr 11, 2012, 1:29:56 PM4/11/12
to salt-...@googlegroups.com
Using that, still same issue.  I think the issue that I'm having comes from salt attempting the following command.

[root@salt-minion ~]# useradd -s /bin/bash -m -d /home/dcrouch dcrouch
useradd: group dcrouch exists - if you want to add this user to that group, use -g.

Thomas S Hatch

unread,
Apr 11, 2012, 1:44:44 PM4/11/12
to salt-...@googlegroups.com
Oh, useradd is attempting to add the default user group, remove the group and the group dec from your sls and then do it again. I will have to have something to handle this

Duane Crouch

unread,
Apr 11, 2012, 2:00:32 PM4/11/12
to salt-...@googlegroups.com
Thank you.

Duane Crouch

unread,
Apr 12, 2012, 11:51:45 AM4/12/12
to salt-...@googlegroups.com
Shall I create an issue for this?

Thomas S Hatch

unread,
Apr 12, 2012, 11:58:58 AM4/12/12
to salt-...@googlegroups.com
That would be nice, yes :)

Don Babb

unread,
Apr 18, 2012, 2:09:39 PM4/18/12
to Salt-users
Not sure if this will help, I was running into the same issue and
found that this will work.

test:
group:
- present
- gid: 50173
user:
- present
- fullname: Test User
- shell: /bin/bash
- home: /home/test
- uid: 50173
- gid: 50173
- groups:
- test
- require:
- group: test


On Apr 11, 2:00 pm, Duane Crouch <duane.cro...@mnxsolutions.com>
wrote:
> Thank you.
>
> On Wed, Apr 11, 2012 at 1:44 PM, Thomas S Hatch <thatc...@gmail.com> wrote:
>
>
>
> > Oh, useradd is attempting to add the default user group, remove the group
> > and the group dec from your sls and then do it again. I will have to have
> > something to handle this
>
> > On Wed, Apr 11, 2012 at 11:29 AM, Duane Crouch <
> > duane.cro...@mnxsolutions.com> wrote:
>
> >> Using that, still same issue.  I think the issue that I'm having comes
> >> from salt attempting the following command.
>
> >> [root@salt-minion ~]# useradd -s /bin/bash -m -d /home/dcrouch dcrouch
> >> useradd: group dcrouch exists - if you want to add this user to that
> >> group, use -g.
>
> >> On Wed, Apr 11, 2012 at 1:13 PM, Thomas S Hatch <thatc...@gmail.com>wrote:
>
> >>> could you add a:
>
> >>> require:
> >>>   - group: dcrouch
>
> >>> to your user state dec?
>
> >>> On Wed, Apr 11, 2012 at 11:07 AM, Duane Crouch <
> >>> duane.cro...@mnxsolutions.com> wrote:
>
> >>>> Here's the data I'm working with salt state and output.
>
> >>>> I've been trying to create user/group.  I've tested using the command
> >>>> output, before I was, not, though I realized groups was the cause.  The
> >>>> trouble I'm having is even ensuring group is created it seems to be a flag
> >>>> with the useradd state.
>
> >>>>http://thunked.org/p/view/pri/3tzi4e6qb
>
> >>>> On Wed, Apr 11, 2012 at 12:49 PM, Thomas S Hatch <thatc...@gmail.com>wrote:
>
> >>>>> Oh, are you declaring and then requiring the group? you need to make
> >>>>> sure the group exists before assigning a user to it
>
> >>>>> On Wed, Apr 11, 2012 at 10:36 AM, Duane Crouch <
> >>>>> duane.cro...@mnxsolutions.com> wrote:
>
> >>>>>> Oh, I believe it was yum on centos 6, and git on Ubuntu.
>
> >>>>>> On Wed, Apr 11, 2012 at 12:35 PM, Duane Crouch <
> >>>>>> duane.cro...@mnxsolutions.com> wrote:
>
> >>>>>>> After so many snapshots and failures on my own part.
>
> >>>>>>> I'll try and grab from git, any specific branch?
>
> >>>>>>> On Wed, Apr 11, 2012 at 12:32 PM, Thomas S Hatch <thatc...@gmail.com
> >>>>>>>>> will not function correctly.- Hide quoted text -
>
> - Show quoted text -
Reply all
Reply to author
Forward
0 new messages