puppetlabs / puppet

Server automation framework and application
https://puppet.com/open-source/#osp
Apache License 2.0
7.42k stars 2.19k forks source link

group resource fails when `provider => 'groupadd'` not explicitly set #9350

Open mojibake-umd opened 5 months ago

mojibake-umd commented 5 months ago

Describe the Bug

When a group resource which has not been created(new), and is add/managing member to the group on creation "fails" to purge the group if provider is not explicitly set to 'groupadd'. It seems that "groupmod" is selected for the localmodify command when defining the purge_members and results in error as groupmod does not have a "-m" option.

Expected Behavior

A new group resource should be created without need to explicitly set provider.

Steps to Reproduce

Steps to reproduce the behavior:

Make sure this is a new group that does not exist on system. Behavior will not appear if group exists.

$members = [ 'larry', 'moe', 'curly' ]

  group { 'sftponly':
    ensure          => 'present',
    auth_membership => true,
    members         => $members,
    forcelocal      => true,
  } 

results in

Debug: Executing: '/usr/sbin/groupadd sftponly'
Debug: Success: /usr/sbin/groupadd sftponly
Debug: Executing: '/usr/bin/gpasswd -a larry sftponly'
Debug: Success: /usr/bin/gpasswd -a larry sftponly
...
Debug: Executing: '/usr/sbin/groupmod -m larry moe curly sftponly'
Error: Could not set members on group[sftponly]: Execution of '/usr/sbin/groupmod -m larry moe curly sftponly' returned 2: /usr/sbin/groupmod: invalid option -- 'm' 

Environment

Additional Context

A work around is to explicitly set provider => 'groupdadd'

$members = [ 'larry', 'moe', 'curly' ]

  group { 'sftponly':
    ensure          => 'present',
    auth_membership => true,
    members         => $members,
    forcelocal      => true,
    provider        => 'groupadd',
  } 

results in

Debug: Executing: '/usr/sbin/lgroupadd sftponly'
Debug: Executing: '/usr/sbin/lgroupmod -M larry moe curly sftponly'
github-actions[bot] commented 4 months ago

Migrated issue to PUP-12045