[PUP-4491] Adding user to group fails Created: 2015/04/29  Updated: 2015/06/03  Resolved: 2015/05/20

Status: Closed
Project: Puppet
Component/s: Types and Providers
Affects Version/s: PUP 4.0.0
Fix Version/s: PUP 4.1.0

Type: Bug Priority: Normal
Reporter: Hugo Assignee: Unassigned
Resolution: Done Votes: 3
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Linux 2.6.32-504.3.3.el6.x86_64 x86_64 GNU/Linux


Issue Links:
Relates
relates to PUP-4550 Audit acceptance tests for user type Resolved
relates to PUP-4693 The pw provider for users and groups ... Closed
Template:
Story Points: 1
Sprint: Client 2015-05-13
Release Notes: Bug Fix

 Description   

When adding a user to a group, the command usermod fails:

user.pp

user {'root':
  groups => ['root', 'wheel'],
}

Console output

Error: Could not set groups on user[root]: Execution of '/usr/sbin/usermod -S root,wheel root' returned 2: /usr/sbin/usermod: invalid option -- 'S'



 Comments   
Comment by Louis Coilliot [ 2015/05/05 ]

This is the same with only one group added :

Error: Could not set groups on user[lofic]: Execution of '/usr/sbin/usermod -S wheel lofic' returned 2: /usr/sbin/usermod: invalid option – 'S'

Tested on Centos 6.6.

-S should be -G

Comment by Justin Lambert [ 2015/05/05 ]

Same result on CentOS 7.1

Comment by Frank [ 2015/05/07 ]

Same on Debian 7.8 with package "puppet-agent 1.0.1-1wheezy".
Can't go on with Puppet 4 migration as long as this bug persists.

Comment by Kylo Ginsberg [ 2015/05/08 ]

I wonder if the new openbsd user provider is bleeding through to other platforms and should be confined to just openbsd instead of just the defaultfor openbsd:

https://github.com/puppetlabs/puppet/blob/088cdba9976914ebe2857ba2bdf2bac50fda339f/lib/puppet/provider/user/openbsd.rb#L13

This could be quickly tested by adding:

confine :operatingsystem => :openbsd

to lib/puppet/provider/user/openbsd.rb just above that defaultfor line.

Comment by Kylo Ginsberg [ 2015/05/08 ]

I verified the above fixes the problem.

Comment by Kurt Wall [ 2015/05/11 ]

Verified in stable at SHA=bda87b248e6034041e2328658072cfa2446d8006. Can now add users to groups:

# bundle exec puppet resource user root groups='wheel'
Notice: /User[root]/groups: groups changed '' to 'wheel'
user { 'root':
  ensure => 'present',
  groups => ['wheel'],
}
# x.pp
user { 'root':
  groups => ['root','wheel'],
}
# bundle exec puppet apply x.pp
Notice: Compiled catalog for nivsiflmmo4r7z2.delivery.puppetlabs.net in environment production in 0.55 seconds
Notice: /Stage[main]/Main/User[root]/groups: groups changed 'wheel' to 'root,wheel'
Notice: Applied catalog in 0.05 seconds
 
# puppet apply -e "user { 'jenny': ensure => present, groups => ['sys','utempter'] }"
Notice: Compiled catalog for nivsiflmmo4r7z2.delivery.puppetlabs.net in environment production in 0.54 seconds
Notice: /Stage[main]/Main/User[jenny]/ensure: created
Notice: Applied catalog in 0.05 seconds
# bundle exec puppet resource user jenny
user { 'jenny':
  ensure => 'present',
  gid    => '1001',
  groups => ['sys', 'utempter'],
  home   => '/home/jenny',
  shell  => '/bin/bash',
  uid    => '1001',
}

Generated at Tue Mar 26 03:29:16 PDT 2019 using JIRA 7.7.1#77002-sha1:e75ca93d5574d9409c0630b81c894d9065296414.