Files
Kamino/roles/user_management/tasks/bootstrap.yml
T
Defame1297andClaude Opus 5.5 2713753039 feat(user_management): add the user_management role
Copied from the environment repository's local role. The files are
identical except: galaxy namespace mortis; comments and the README
scrubbed of environment references (issue numbers, playbooks, inventory
groups and group_vars paths, the provisioning roles by name, the history
of the variable rename), with the technical explanation kept; the README
asks for the role by its FQCN, names the run order generically (after the
step that creates the guest, before mortis.kamino.sshd) and its example
play uses mortis.kamino.user_management; the molecule scenario calls the
role by its FQCN, follows the Kamino scenario conventions (kamino-molecule
header, scenario.test_sequence) and no longer sets ANSIBLE_COLLECTIONS_PATH
or ANSIBLE_ROLES_PATH. No variable, default, argument_specs entry or task
logic changed: the key-only root fallback, the handback and
user_management_lock_root_password (default false) are as in the source,
and prepare/verify are unchanged. The role uses ansible.posix
(authorized_key), already a galaxy.yml dependency, so galaxy.yml is
unchanged.

The README Roadmap no longer lists wave 1; CLAUDE.md names the role for
the next release.

Not verified locally: the molecule scenario (it runs on the
kamino-molecule runner in CI) and ansible-test sanity (runs on push).

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

29 lines
1.5 KiB
YAML

---
- name: Test connection as configured user
ansible.builtin.wait_for_connection:
timeout: 5
register: user_management_connection
# Failure is the signal to fall back to root below; the "Verify root access" ping
# fails the play if root is unreachable too.
ignore_errors: true
# Key only, never a password: the root fallback uses the same deploy key as every other
# connection (ansible_ssh_private_key_file). It is for a new LXC: the provisioning step gives root
# that key and stock Ubuntu sshd (PermitRootLogin prohibit-password) admits root by key on first
# boot. A new VM never needs it (cloud-init creates the configured user with the key; root does not
# get it), and a fresh Proxmox node gets the key from the operator. Once mortis.kamino.sshd has run
# (PermitRootLogin no on ubuntu_lxc/ubuntu_vm), root is refused: a host whose configured user broke
# later is recovered from its Proxmox node (pct enter, qm terminal or the console), not here.
# tasks/handback.yml switches the connection back to the configured user after it is created.
- name: Fallback to root if user connection failed
when: user_management_connection is failed
block:
- name: Switch to root with the deploy key
# Connection var on purpose: as a fact it overrides the connection for the rest of the run,
# until tasks/handback.yml switches it back.
ansible.builtin.set_fact: # noqa: var-naming[no-role-prefix]
ansible_ssh_user: root
- name: Verify root access
ansible.builtin.ping: