Files
Kamino/roles/user_management/tasks/ssh_keys.yml
T
Defame1297 9ce0fbd433
Build / build (pull_request) Successful in 22s
Lint / lint (pull_request) Successful in 2m1s
Molecule / molecule (pull_request) Successful in 44m6s
fix(roles): refresh apt in the docker and traefik scenarios and apply review round 2
The molecule images ship without apt lists, and --check does not
refresh them, so the fresh-host check of docker and traefik could not
find curl and wget. Their prepare now refreshes the cache, as pihole's
and system_baseline's already do by installing fixtures.

The sequence test gets its own class after the platform tests, the
check-mode rule is split into guards and README, and the
user_management comment sits on the task it explains.

Assisted-by: Claude Code
2026-11-26 12:18:48 +00:00

36 lines
1.2 KiB
YAML

---
- name: Ensure .ssh directory exists
become: true
ansible.builtin.file:
path: "/home/{{ item.name }}/.ssh"
state: directory
owner: "{{ item.name }}"
group: "{{ item.name }}"
mode: "0700"
loop: "{{ user_management_all_users }}"
loop_control:
label: "{{ item.name }}"
when:
- item.state | default('present') == 'present'
- not item.system | default(false)
- name: Read the existing users for the check-mode preview
ansible.builtin.getent:
database: passwd
# Under --check a user the role would create does not exist yet, and authorized_key fails on a missing user.
- name: Enforce authorized_keys authoritatively
become: true
ansible.posix.authorized_key:
user: "{{ item.name }}"
key: "{{ (user_management_default_authorized_keys + (item.authorized_keys | default([]))) | join('\n') }}"
state: present
exclusive: "{{ user_management_authoritative }}"
loop: "{{ user_management_all_users }}"
when:
- item.state | default('present') == 'present'
- ( user_management_default_authorized_keys + (item.authorized_keys | default([])) ) | length > 0
- not ansible_check_mode or item.name in ansible_facts.getent_passwd
loop_control:
label: "{{ item.name }}"