summaryrefslogtreecommitdiff
path: root/lib/ansible/modules/group.py
diff options
context:
space:
mode:
Diffstat (limited to 'lib/ansible/modules/group.py')
-rw-r--r--lib/ansible/modules/group.py54
1 files changed, 12 insertions, 42 deletions
diff --git a/lib/ansible/modules/group.py b/lib/ansible/modules/group.py
index 45590d1d..109a161a 100644
--- a/lib/ansible/modules/group.py
+++ b/lib/ansible/modules/group.py
@@ -35,16 +35,9 @@ options:
type: str
choices: [ absent, present ]
default: present
- force:
- description:
- - Whether to delete a group even if it is the primary group of a user.
- - Only applicable on platforms which implement a --force flag on the group deletion command.
- type: bool
- default: false
- version_added: "2.15"
system:
description:
- - If V(yes), indicates that the group created is a system group.
+ - If I(yes), indicates that the group created is a system group.
type: bool
default: no
local:
@@ -58,7 +51,7 @@ options:
version_added: "2.6"
non_unique:
description:
- - This option allows to change the group ID to a non-unique value. Requires O(gid).
+ - This option allows to change the group ID to a non-unique value. Requires C(gid).
- Not supported on macOS or BusyBox distributions.
type: bool
default: no
@@ -94,7 +87,7 @@ EXAMPLES = '''
RETURN = r'''
gid:
description: Group ID of the group.
- returned: When O(state) is C(present)
+ returned: When C(state) is 'present'
type: int
sample: 1001
name:
@@ -109,7 +102,7 @@ state:
sample: 'absent'
system:
description: Whether the group is a system group or not.
- returned: When O(state) is C(present)
+ returned: When C(state) is 'present'
type: bool
sample: False
'''
@@ -117,7 +110,7 @@ system:
import grp
import os
-from ansible.module_utils.common.text.converters import to_bytes
+from ansible.module_utils._text import to_bytes
from ansible.module_utils.basic import AnsibleModule
from ansible.module_utils.common.sys_info import get_platform_subclass
@@ -147,7 +140,6 @@ class Group(object):
self.module = module
self.state = module.params['state']
self.name = module.params['name']
- self.force = module.params['force']
self.gid = module.params['gid']
self.system = module.params['system']
self.local = module.params['local']
@@ -227,7 +219,14 @@ class Group(object):
if line.startswith(to_bytes(name_test)):
exists = True
break
+
+ if not exists:
+ self.module.warn(
+ "'local: true' specified and group was not found in {file}. "
+ "The local group may already exist if the local group database exists somewhere other than {file}.".format(file=self.GROUPFILE))
+
return exists
+
else:
try:
if grp.getgrnam(self.name):
@@ -247,31 +246,6 @@ class Group(object):
# ===========================================
-class Linux(Group):
- """
- This is a Linux Group manipulation class. This is to apply the '-f' parameter to the groupdel command
-
- This overrides the following methods from the generic class:-
- - group_del()
- """
-
- platform = 'Linux'
- distribution = None
-
- def group_del(self):
- if self.local:
- command_name = 'lgroupdel'
- else:
- command_name = 'groupdel'
- cmd = [self.module.get_bin_path(command_name, True)]
- if self.force:
- cmd.append('-f')
- cmd.append(self.name)
- return self.execute_command(cmd)
-
-
-# ===========================================
-
class SunOS(Group):
"""
This is a SunOS Group manipulation class. Solaris doesn't have
@@ -622,7 +596,6 @@ def main():
argument_spec=dict(
state=dict(type='str', default='present', choices=['absent', 'present']),
name=dict(type='str', required=True),
- force=dict(type='bool', default=False),
gid=dict(type='int'),
system=dict(type='bool', default=False),
local=dict(type='bool', default=False),
@@ -634,9 +607,6 @@ def main():
],
)
- if module.params['force'] and module.params['local']:
- module.fail_json(msg='force is not a valid option for local, force=True and local=True are mutually exclusive')
-
group = Group(module)
module.debug('Group instantiated - platform %s' % group.platform)