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"
}
Parameter Type Description
(positional) string Username
uid integer Numeric user ID
groups string or list Supplementary groups: groups "docker" "sudo", a - list block, or groups="docker,sudo"
shell string Login shell
state string "present" (default) 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.

Every module’s rules side by side: Idempotency & Drift.

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"
}
}