Keep your minions happy with tips from Into The Salt Mine

Introduction to SaltStacks user module

The user module allows you to query and manipulate users on any of your minions using the remote execution system. The examples below demonstrate adding users, updating user information, querying user information and removing users. This is a powerful tool to quickly and easily manage system users on any number of minions.

Currently this module is supported on Linux and OpenBSD, with partial support on OS X.

user.add

Add a user to the minion.

salt '*' user.add username <uid> <gid> <groups> <home> <shell>

user.chfullname

Change the user's full name.

salt '*' user.chfullname username "Foo Bar"

user.chgid

Change the default group of the user.

salt '*' user.chgid username 4376

user.chgroups

Change the groups this user belongs to, add append to append the specified groups.

salt '*' user.chgroups username wheel,root True

user.chhome

Change the home directory of the user, pass true for persist to copy files to the new home dir.

salt '*' user.chhome username /home/users/foo True

user.chhomephone

Change the user's home phone.

salt '*' user.chhomephone username "7735551234"

user.chroomnumber

Change the user's room number.

salt '*' user.chroomnumber username 123

user.chshell

Change the default shell of the user.

salt '*' user.chshell username /bin/zsh

user.chuid

Change the uid for a named user.

salt '*' user.chuid username 4376

user.chworkphone

Change the user's work phone.

salt '*' user.chworkphone username "7735550123"

user.delete

Remove a user from the minion.

salt '*' user.delete username remove=True force=True

user.getent

Return the list of all info for all users.

salt '*' user.getent

user.info

Return user information.

salt '*' user.info username

user.list_groups

Return a list of groups the named user belongs to.

salt '*' user.list_groups username

user.list_users

Return a list of all users.

salt '*' user.list_users
 
comments powered by Disqus