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
47 lines
1.8 KiB
YAML
47 lines
1.8 KiB
YAML
---
|
|
- name: Ensure sudo is installed
|
|
when: user_management_install_sudo
|
|
become: true
|
|
ansible.builtin.apt:
|
|
name: sudo
|
|
state: present
|
|
update_cache: true
|
|
cache_valid_time: 3600
|
|
|
|
# -------------------------
|
|
# PRIMARY ANSIBLE USER
|
|
# -------------------------
|
|
- name: Ensure ansible user is managed
|
|
become: true
|
|
ansible.builtin.user:
|
|
name: "{{ user_management_ansible_user.name }}"
|
|
shell: "{{ user_management_ansible_user.shell }}"
|
|
groups: "{{ user_management_ansible_user.groups | default(omit) }}"
|
|
# ansible-core 2.21 rejects append without groups, so append only goes with groups
|
|
append: "{{ true if user_management_ansible_user.groups is defined else omit }}"
|
|
create_home: "{{ user_management_ansible_user.create_home }}"
|
|
password: "{{ user_management_ansible_user.password_hash }}"
|
|
state: "{{ user_management_ansible_user.state }}"
|
|
remove: "{{ user_management_remove_home }}"
|
|
|
|
# -------------------------
|
|
# OTHER MANAGED USERS
|
|
# -------------------------
|
|
- name: Manage additional users
|
|
become: true
|
|
ansible.builtin.user:
|
|
name: "{{ item.name }}"
|
|
shell: "{{ item.shell | default('/bin/bash') }}"
|
|
groups: "{{ item.groups | default(omit) }}"
|
|
# ansible-core 2.21 rejects append without groups (also for state absent): pass it only with groups
|
|
append: "{{ (item.append | default(true)) if item.groups is defined else omit }}"
|
|
create_home: "{{ item.create_home | default(true) }}"
|
|
password: "{{ item.password_hash | default(omit) }}"
|
|
comment: "{{ item.comment | default(omit) }}"
|
|
system: "{{ item.system | default(false) }}"
|
|
state: "{{ item.state | default('present') }}"
|
|
remove: "{{ user_management_remove_home }}"
|
|
loop: "{{ user_management_other_users }}"
|
|
loop_control:
|
|
label: "{{ item.name }}"
|