modules/system/user.py: Change createhome to create_home (#30179)

pull/30668/head
Reid Wahl 7 years ago committed by Toshio Kuratomi
parent f5dded59c2
commit 5f90169d73

@ -86,7 +86,7 @@ options:
skeleton: skeleton:
required: false required: false
description: description:
- Optionally set a home skeleton directory. Requires createhome option! - Optionally set a home skeleton directory. Requires create_home option!
version_added: "2.0" version_added: "2.0"
password: password:
required: false required: false
@ -103,14 +103,15 @@ options:
choices: [ present, absent ] choices: [ present, absent ]
description: description:
- Whether the account should exist or not, taking action if the state is different from what is stated. - Whether the account should exist or not, taking action if the state is different from what is stated.
createhome: create_home:
required: false
default: "yes"
choices: [ "yes", "no" ]
description: description:
- Unless set to C(no), a home directory will be made for the user - Unless set to C(no), a home directory will be made for the user
when the account is created or if the home directory does not when the account is created or if the home directory does not
exist. exist.
- Changed from C(createhome) to C(create_home) in version 2.5.
default: yes
type: bool
aliases: ['createhome']
move_home: move_home:
required: false required: false
default: "no" default: "no"
@ -301,7 +302,7 @@ class User(object):
self.password = module.params['password'] self.password = module.params['password']
self.force = module.params['force'] self.force = module.params['force']
self.remove = module.params['remove'] self.remove = module.params['remove']
self.createhome = module.params['createhome'] self.create_home = module.params['create_home']
self.move_home = module.params['move_home'] self.move_home = module.params['move_home']
self.skeleton = module.params['skeleton'] self.skeleton = module.params['skeleton']
self.system = module.params['system'] self.system = module.params['system']
@ -422,7 +423,7 @@ class User(object):
cmd.append('-p') cmd.append('-p')
cmd.append(self.password) cmd.append(self.password)
if self.createhome: if self.create_home:
cmd.append('-m') cmd.append('-m')
if self.skeleton is not None: if self.skeleton is not None:
@ -818,7 +819,7 @@ class FreeBsdUser(User):
cmd.append('-G') cmd.append('-G')
cmd.append(','.join(groups)) cmd.append(','.join(groups))
if self.createhome: if self.create_home:
cmd.append('-m') cmd.append('-m')
if self.skeleton is not None: if self.skeleton is not None:
@ -1016,7 +1017,7 @@ class OpenBSDUser(User):
cmd.append('-p') cmd.append('-p')
cmd.append(self.password) cmd.append(self.password)
if self.createhome: if self.create_home:
cmd.append('-m') cmd.append('-m')
if self.skeleton is not None: if self.skeleton is not None:
@ -1186,7 +1187,7 @@ class NetBSDUser(User):
cmd.append('-p') cmd.append('-p')
cmd.append(self.password) cmd.append(self.password)
if self.createhome: if self.create_home:
cmd.append('-m') cmd.append('-m')
if self.skeleton is not None: if self.skeleton is not None:
@ -1363,7 +1364,7 @@ class SunOS(User):
cmd.append('-s') cmd.append('-s')
cmd.append(self.shell) cmd.append(self.shell)
if self.createhome: if self.create_home:
cmd.append('-m') cmd.append('-m')
if self.skeleton is not None: if self.skeleton is not None:
@ -1758,7 +1759,7 @@ class DarwinUser(User):
self.uid = str(self._get_next_uid(self.system)) self.uid = str(self._get_next_uid(self.system))
# Homedir is not created by default # Homedir is not created by default
if self.createhome: if self.create_home:
if self.home is None: if self.home is None:
self.home = '/Users/%s' % self.name self.home = '/Users/%s' % self.name
if not self.module.check_mode: if not self.module.check_mode:
@ -1896,7 +1897,7 @@ class AIX(User):
cmd.append('-s') cmd.append('-s')
cmd.append(self.shell) cmd.append(self.shell)
if self.createhome: if self.create_home:
cmd.append('-m') cmd.append('-m')
if self.skeleton is not None: if self.skeleton is not None:
@ -2046,7 +2047,7 @@ class HPUX(User):
cmd.append('-p') cmd.append('-p')
cmd.append(self.password) cmd.append(self.password)
if self.createhome: if self.create_home:
cmd.append('-m') cmd.append('-m')
else: else:
cmd.append('-M') cmd.append('-M')
@ -2168,7 +2169,7 @@ def main():
force=dict(default='no', type='bool'), force=dict(default='no', type='bool'),
remove=dict(default='no', type='bool'), remove=dict(default='no', type='bool'),
# following options are specific to useradd # following options are specific to useradd
createhome=dict(default='yes', type='bool'), create_home=dict(default='yes', aliases=['createhome'], type='bool'),
skeleton=dict(default=None, type='str'), skeleton=dict(default=None, type='str'),
system=dict(default='no', type='bool'), system=dict(default='no', type='bool'),
# following options are specific to usermod # following options are specific to usermod
@ -2218,7 +2219,7 @@ def main():
result['system'] = user.name result['system'] = user.name
else: else:
result['system'] = user.system result['system'] = user.system
result['createhome'] = user.createhome result['create_home'] = user.create_home
else: else:
# modify user (note: this function is check mode aware) # modify user (note: this function is check mode aware)
(rc, out, err) = user.modify_user() (rc, out, err) = user.modify_user()
@ -2256,7 +2257,7 @@ def main():
info = user.user_info() info = user.user_info()
if user.home is None: if user.home is None:
user.home = info[5] user.home = info[5]
if not os.path.exists(user.home) and user.createhome: if not os.path.exists(user.home) and user.create_home:
if not module.check_mode: if not module.check_mode:
user.create_homedir(user.home) user.create_homedir(user.home)
user.chown_homedir(info[2], info[3], user.home) user.chown_homedir(info[2], info[3], user.home)

@ -58,7 +58,7 @@
user: user:
name: "{{ user_names.stdout_lines|random }}" name: "{{ user_names.stdout_lines|random }}"
state: present state: present
createhome: no create_home: no
with_sequence: start=1 end=5 with_sequence: start=1 end=5
register: user_test1 register: user_test1
- debug: var=user_test1 - debug: var=user_test1

Loading…
Cancel
Save