Files
Defame1297andClaude Opus 5.5 da87a7e141 docs(user_management): state gather_facts, key exclusivity and known limits
From review of the extraction. Documentation only; behaviour is unchanged.
- The play needs gather_facts: false, or a fresh guest is unreachable before
  the root fallback runs (README requirement and example, argument spec).
- user_management_authoritative skips a user whose merged key list is empty,
  so emptying the list keeps that user's existing keys.
- user_management_become_password_hashed is required unless
  user_management_ansible_user is overridden.
- Known limits: molecule does not exercise the fallback or the handback, the
  handback reconnects as ansible_user, a partial tag run on a fresh host
  fails at the handback, and the primary user can be set absent.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01MmzvM9skAvYcph2c9EiPcm
2026-11-16 17:21:38 +00:00

138 lines
5.6 KiB
YAML

---
argument_specs:
main:
short_description: Manage the ansible user, other users and their SSH keys
description:
- >-
Builds the list of managed users, optionally falls back to root with the deploy key when the configured user cannot connect (and hands the
connection back to that user once it exists), installs sudo,
creates or removes users, writes C(authorized_keys), optionally locks root's password and disables cloud-init.
- Run it in a play with C(gather_facts) set to false. On a fresh guest the configured user cannot log in until the fallback has created it.
- Sets the facts C(user_management_all_users) and C(user_management_managed_usernames).
options:
user_management_bootstrap:
type: bool
default: true
description:
- Test the connection as the configured user and fall back to root with the deploy key (never a password) when it fails.
user_management_install_sudo:
type: bool
default: true
description:
- Install the sudo package before creating users.
user_management_disable_cloud_init:
type: bool
default: true
description:
- Create C(/etc/cloud/cloud-init.disabled) when C(/etc/cloud) exists.
user_management_authoritative:
type: bool
default: true
description:
- Make C(authorized_keys) exclusive, so keys that are not configured are removed.
- >-
Applies only to users with at least one configured key (the defaults plus their own). A user whose merged key list
is empty is skipped, so emptying the list does not remove that user's existing keys.
user_management_lock_root_password:
type: bool
default: false
description:
- >-
Lock root's password by replacing the shadow field with C(!): no password logs root in and the old hash is removed (C(usermod -L) would keep it).
Root's shell, home and C(authorized_keys) are left alone, so key login (where sshd allows it) and C(pct enter) still work.
- Fails when the primary user is root. Leave it false where root's password is a real login, such as a Proxmox node.
user_management_ansible_user:
type: dict
description:
- >-
The primary ansible user, always managed. The role default sets C(name) to C(ansible_user), C(password_hash) to
C(user_management_become_password_hashed) (mandatory), C(groups) to C([sudo]), C(shell) to C(/bin/bash), C(create_home) to true
and C(state) to C(present).
- Overriding it replaces the whole dict, so every required key must be given.
options:
name:
type: str
required: true
description: Account name.
password_hash:
type: raw
required: true
no_log: true
description: Password hash passed to C(ansible.builtin.user).
groups:
type: list
elements: str
description: Supplementary groups, appended to the existing ones.
shell:
type: str
required: true
description: Login shell.
create_home:
type: bool
required: true
description: Create the home directory.
state:
type: str
required: true
description: C(present) or C(absent).
authorized_keys:
type: list
elements: str
description: Keys added to C(user_management_default_authorized_keys) for this user.
user_management_default_authorized_keys:
type: list
elements: str
default: []
description:
- Keys written for every managed user.
user_management_other_users:
type: list
elements: dict
default: []
description:
- Additional users. A user with C(state=absent) is removed.
options:
name:
type: str
required: true
description: Account name.
shell:
type: str
description: Login shell. Defaults to C(/bin/bash) in the tasks.
groups:
type: raw
description: Supplementary groups, as a list or a comma separated string.
append:
type: bool
description: Append to the groups instead of replacing them. Defaults to true in the tasks.
create_home:
type: bool
description: Create the home directory. Defaults to true in the tasks.
password_hash:
type: raw
no_log: true
description: Password hash. Omitted when not set.
comment:
type: str
description: GECOS comment.
system:
type: bool
description: Create a system account. Defaults to false in the tasks.
state:
type: str
description: C(present) or C(absent). Defaults to C(present) in the tasks.
authorized_keys:
type: list
elements: str
description: Keys added to C(user_management_default_authorized_keys) for this user.
user_management_remove_home:
type: bool
default: true
description:
- Remove the home directory of users whose state is absent.
user_management_become_password_hashed:
type: raw
no_log: true
description:
- Password hash of the primary user, read by the C(user_management_ansible_user) default with C(mandatory). Normally vaulted in host_vars.