Parameter |
Choices/Defaults |
Comments |
append
bool |
|
If yes , add the user to the groups specified in groups .
If no , user will only be added to the groups specified in groups , removing them from all other groups.
|
comment
|
|
Optionally sets the description (aka GECOS) of user account.
|
create_home
bool |
|
Unless set to no , a home directory will be made for the user when the account is created or if the home directory does not exist.
Changed from createhome to create_home in version 2.5.
aliases: createhome
|
expires
(added in 1.9) |
|
An expiry time for the user in epoch, it will be ignored on platforms that do not support this. Currently supported on GNU/Linux, FreeBSD, and DragonFlyBSD.
Since version 2.6 you can remove the expiry time specify a negative value. Currently supported on GNU/Linux and FreeBSD.
|
force
bool |
|
This only affects state=absent , it forces removal of the user and associated directories on supported platforms. The behavior is the same as userdel --force , check the man page for userdel on your system for details and support.
|
generate_ssh_key
bool |
|
Whether to generate a SSH key for the user in question. This will not overwrite an existing SSH key.
|
group
|
|
Optionally sets the user's primary group (takes a group name).
|
groups
|
|
List of groups user will be added to. When set to an empty string '' , null , or ~ , the user is removed from all groups except the primary group. (~ means null in YAML)
Before version 2.3, the only input format allowed was a comma separated string. Now this parameter accepts a list as well as a comma separated string.
|
hidden
bool
(added in 2.6) |
|
macOS only, optionally hide the user from the login window and system preferences.
The default will be 'True' if the system option is used.
|
home
|
|
Optionally set the user's home directory.
|
local
bool
(added in 2.4) |
|
Forces the use of "local" command alternatives on platforms that implement it. This is useful in environments that use centralized authentification when you want to manipulate the local users. I.E. it uses `luseradd` instead of `useradd`.
This requires that these commands exist on the targeted host, otherwise it will be a fatal error.
|
login_class
|
|
Optionally sets the user's login class, a feature of most BSD OSs.
|
move_home
bool |
|
If set to yes when used with home= , attempt to move the user's old home directory to the specified directory if it isn't there already and the old home exists.
|
name
required |
|
Name of the user to create, remove or modify.
aliases: user
|
non_unique
bool |
|
Optionally when used with the -u option, this option allows to change the user ID to a non-unique value.
|
password
|
|
Optionally set the user's password to this crypted value.
On macOS systems, this value has to be cleartext. Beware of security issues.
|
password_lock
bool
(added in 2.6) |
|
Lock the password (usermod -L, pw lock, usermod -C). BUT implementation differs on different platforms, this option does not always mean the user cannot login via other methods. This option does not disable the user, only lock the password. Do not change the password in the same task. Currently supported on Linux, FreeBSD, DragonFlyBSD, NetBSD, OpenBSD.
|
remove
bool |
|
This only affects state=absent , it attempts to remove directories associated with the user. The behavior is the same as userdel --remove , check the man page for details and support.
|
seuser
(added in 2.1) |
|
Optionally sets the seuser type (user_u) on selinux enabled systems.
|
shell
|
|
Optionally set the user's shell.
On macOS, before version 2.5, the default shell for non-system users was /usr/bin/false. Since 2.5, the default shell for non-system users on macOS is /bin/bash.
On other operating systems, the default shell is determined by the underlying tool being used. See Notes for details.
|
skeleton
(added in 2.0) |
|
Optionally set a home skeleton directory. Requires create_home option!
|
ssh_key_bits
|
Default:
"default set by ssh-keygen"
|
Optionally specify number of bits in SSH key to create.
|
ssh_key_comment
|
Default:
"ansible-generated on $HOSTNAME"
|
Optionally define the comment for the SSH key.
|
ssh_key_file
|
Default:
".ssh/id_rsa"
|
Optionally specify the SSH key filename. If this is a relative filename then it will be relative to the user's home directory.
|
ssh_key_passphrase
|
|
Set a passphrase for the SSH key. If no passphrase is provided, the SSH key will default to having no passphrase.
|
ssh_key_type
|
Default:
"rsa"
|
Optionally specify the type of SSH key to generate. Available SSH key types will depend on implementation present on target host.
|
state
|
Choices:
- absent
present ←
|
Whether the account should exist or not, taking action if the state is different from what is stated.
|
system
bool |
|
When creating an account state=present , setting this to yes makes the user a system account. This setting cannot be changed on existing users.
|
uid
|
|
Optionally sets the UID of the user.
|
update_password
(added in 1.3) |
Choices:
always ←
- on_create
|
always will update passwords if they differ. on_create will only set the password for newly created users.
|