Manage users with the useradd command
salt.modules.useradd.
add
(name, uid=None, gid=None, groups=None, home=None, shell=None, unique=True, system=False, fullname='', roomnumber='', workphone='', homephone='', createhome=True, loginclass=None, root=None)¶Add a user to the minion
CLI 范例:
salt '*' user.add name <uid> <gid> <groups> <home> <shell>
salt.modules.useradd.
chfullname
(name, fullname)¶Change the user's Full Name
CLI 范例:
salt '*' user.chfullname foo "Foo Bar"
salt.modules.useradd.
chgid
(name, gid, root=None)¶Change the default group of the user
CLI 范例:
salt '*' user.chgid foo 4376
salt.modules.useradd.
chgroups
(name, groups, append=False, root=None)¶Change the groups to which this user belongs
True
, append the specified group(s). Otherwise, this function
will replace the user's groups with the specified group(s).CLI Examples:
salt '*' user.chgroups foo wheel,root
salt '*' user.chgroups foo wheel,root append=True
salt.modules.useradd.
chhome
(name, home, persist=False, root=None)¶Change the home directory of the user, pass True for persist to move files to the new home directory if the old home directory exist.
CLI 范例:
salt '*' user.chhome foo /home/users/foo True
salt.modules.useradd.
chhomephone
(name, homephone)¶Change the user's Home Phone
CLI 范例:
salt '*' user.chhomephone foo 7735551234
salt.modules.useradd.
chloginclass
(name, loginclass, root=None)¶Change the default login class of the user
注解
This function only applies to OpenBSD systems.
CLI 范例:
salt '*' user.chloginclass foo staff
salt.modules.useradd.
chroomnumber
(name, roomnumber)¶Change the user's Room Number
CLI 范例:
salt '*' user.chroomnumber foo 123
salt.modules.useradd.
chshell
(name, shell, root=None)¶Change the default shell of the user
CLI 范例:
salt '*' user.chshell foo /bin/zsh
salt.modules.useradd.
chuid
(name, uid)¶Change the uid for a named user
CLI 范例:
salt '*' user.chuid foo 4376
salt.modules.useradd.
chworkphone
(name, workphone)¶Change the user's Work Phone
CLI 范例:
salt '*' user.chworkphone foo 7735550123
salt.modules.useradd.
delete
(name, remove=False, force=False, root=None)¶Remove a user from the minion
CLI 范例:
salt '*' user.delete name remove=True force=True
salt.modules.useradd.
get_loginclass
(name)¶Get the login class of the user
注解
This function only applies to OpenBSD systems.
CLI 范例:
salt '*' user.get_loginclass foo
salt.modules.useradd.
getent
(refresh=False)¶Return the list of all info for all users
CLI 范例:
salt '*' user.getent
salt.modules.useradd.
info
(name)¶Return user information
CLI 范例:
salt '*' user.info root
salt.modules.useradd.
list_groups
(name)¶Return a list of groups the named user belongs to
CLI 范例:
salt '*' user.list_groups foo
salt.modules.useradd.
list_users
()¶Return a list of all users
CLI 范例:
salt '*' user.list_users
salt.modules.useradd.
rename
(name, new_name, root=None)¶Change the username for a named user
CLI 范例:
salt '*' user.rename name new_name