Review requests

Signed-off-by: Abhijeet Kasurde <Akasurde@redhat.com>
pull/85610/head
Abhijeet Kasurde 4 months ago
parent 371b7f2b6a
commit 315e58b4b9

@ -1,3 +1,3 @@
--- ---
bugfixes: bugfixes:
- user - raise an error if force=true is used while deleting the group on Alpine and BusyBox (https://github.com/ansible/ansible/issues/85565). - user - raise an error if force=true is used while deleting the group on BusyBox based distros (https://github.com/ansible/ansible/issues/85565).

@ -38,7 +38,7 @@ options:
description: description:
- Whether to delete a group even if it is the primary group of a user. - Whether to delete a group even if it is the primary group of a user.
- Only applicable on platforms which implement a C(--force) flag on the group deletion command. - Only applicable on platforms which implement a C(--force) flag on the group deletion command.
- Not applicable on BusyBox and Alpine Linux. - Not applicable on macOS, *BSD and BusyBox based distros.
type: bool type: bool
default: false default: false
version_added: "2.15" version_added: "2.15"
@ -401,6 +401,8 @@ class FreeBsdGroup(Group):
GROUPFILE = '/etc/group' GROUPFILE = '/etc/group'
def group_del(self): def group_del(self):
if self.module.params['force']:
self.module.fail_json(msg='The force option is not supported for group deletion on this platform.')
cmd = [self.module.get_bin_path('pw', True), 'groupdel', self.name] cmd = [self.module.get_bin_path('pw', True), 'groupdel', self.name]
return self.execute_command(cmd) return self.execute_command(cmd)
@ -477,6 +479,8 @@ class DarwinGroup(Group):
return (rc, out, err) return (rc, out, err)
def group_del(self): def group_del(self):
if self.module.params['force']:
self.module.fail_json(msg='The force option is not supported for group deletion on this platform.')
cmd = [self.module.get_bin_path('dseditgroup', True)] cmd = [self.module.get_bin_path('dseditgroup', True)]
cmd += ['-o', 'delete'] cmd += ['-o', 'delete']
cmd += ['-L', self.name] cmd += ['-L', self.name]
@ -531,6 +535,8 @@ class OpenBsdGroup(Group):
GROUPFILE = '/etc/group' GROUPFILE = '/etc/group'
def group_del(self): def group_del(self):
if self.module.params['force']:
self.module.fail_json(msg='The force option is not supported for group deletion on this platform.')
cmd = [self.module.get_bin_path('groupdel', True), self.name] cmd = [self.module.get_bin_path('groupdel', True), self.name]
return self.execute_command(cmd) return self.execute_command(cmd)
@ -583,6 +589,8 @@ class NetBsdGroup(Group):
GROUPFILE = '/etc/group' GROUPFILE = '/etc/group'
def group_del(self): def group_del(self):
if self.module.params['force']:
self.module.fail_json(msg='The force option is not supported for group deletion on this platform.')
cmd = [self.module.get_bin_path('groupdel', True), self.name] cmd = [self.module.get_bin_path('groupdel', True), self.name]
return self.execute_command(cmd) return self.execute_command(cmd)
@ -653,7 +661,7 @@ class BusyBoxGroup(Group):
def group_del(self): def group_del(self):
if self.module.params['force']: if self.module.params['force']:
self.module.fail_json(msg='force is not a valid option for this platform.') self.module.fail_json(msg='The force option is not supported for group deletion on this platform.')
cmd = [self.module.get_bin_path('delgroup', True), self.name] cmd = [self.module.get_bin_path('delgroup', True), self.name]
return self.execute_command(cmd) return self.execute_command(cmd)

@ -407,7 +407,7 @@
assert: assert:
that: that:
- force_delete is failed - force_delete is failed
- "'force is not a valid option' in force_delete.msg" - "'The force option is not supported' in force_delete.msg"
always: always:
- name: Cleanup group - name: Cleanup group
@ -415,7 +415,7 @@
name: groupdeltest name: groupdeltest
state: absent state: absent
when: ansible_distribution in ["Alpine"] when: ansible_distribution in ["MacOSX", "Alpine", "FreeBSD"]
# create system group # create system group

Loading…
Cancel
Save