Files
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

60 lines
2.0 KiB
YAML

---
# State the role must correct: a stale user with a home (state absent removes
# it), and an existing user holding an extra key (authoritative mode drops it).
- name: Prepare
hosts: all
gather_facts: false
tasks:
- name: Create the user the role will remove
ansible.builtin.user:
name: um-olduser
shell: /bin/bash
create_home: true
- name: Create the additional user with an extra key already planted
ansible.builtin.user:
name: um-alice
shell: /bin/sh
create_home: true
- name: Create alice's .ssh directory
ansible.builtin.file:
path: /home/um-alice/.ssh
state: directory
owner: um-alice
group: um-alice
mode: "0700"
- name: Plant an extra key that authoritative mode must remove
ansible.builtin.copy:
content: "{{ user_management_test_admin_key | regex_replace('molecule-test$', 'rogue-extra') }}\n"
dest: /home/um-alice/.ssh/authorized_keys
owner: um-alice
group: um-alice
mode: "0600"
# user_management_lock_root_password: root starts with an unlocked password field (the image
# ships "*", which already counts as unusable but does not start with "!") and a key the lock
# must leave alone. The value is a placeholder, not a hash: nothing can log in with it.
- name: Give root an unlocked password field
ansible.builtin.user:
name: root
password: molecule-unlocked-placeholder
update_password: always
- name: Create root's .ssh directory
ansible.builtin.file:
path: /root/.ssh
state: directory
owner: root
group: root
mode: "0700"
- name: Plant a key in root's authorized_keys that the lock must not touch
ansible.builtin.copy:
content: "{{ user_management_test_admin_key | regex_replace('molecule-test$', 'root-key') }}\n"
dest: /root/.ssh/authorized_keys
owner: root
group: root
mode: "0600"