Skip to content

user

The user module creates, modifies, or deletes system users.

user "appuser" {
uid 1001
groups "docker" "www-data"
shell "/bin/bash"
state "present"
}
user "olduser" {
state "absent"
}
ParameterTypeDescription
(positional)stringUsername
uidintegerNumeric user ID
groupsstring(s)Supplementary groups
shellstringLogin shell
statestring"present" or "absent"

The module queries user properties (id, getent) and compares them against the desired state. Only mismatched properties are modified. If the user already exists with the correct uid, shell, and groups, no action is taken.

step "Create deploy users" {
user "deploy" {
uid 1000
groups "docker" "sudo"
shell "/bin/bash"
state "present"
}
user "monitoring" {
uid 1001
groups "docker"
shell "/bin/bash"
state "present"
}
}