mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 02:54:26 +00:00
In the async pass the role runs kcadm jobs side by side. Every kcadm call in the Keycloak container shares one config file. kcadm rewrites that file when it refreshes the access token, about every 55 seconds, takes the file lock with tryLock() and gives up at once when another kcadm process holds it. One of two overlapping declared-client jobs then failed with "Failed to get lock on /opt/keycloak/.keycloak/kcadm.config", and the deploy with it. keycloak_kcadm_update now repeats a call that lost the lock, up to ten times one second apart. The call fails while it refreshes its token, before it sends its own request, so repeating it is safe. Every other error still ends the call at once. That covers the module only, so the async jobs are reduced to the ones that go through it: - The default-scope assignment was an async shell task. It ran beside the shell tasks that follow it, and neither side repeats a lost lock. It runs in line now. - The two mail-settings jobs were async without a register, so nothing reaped them and a failure was never seen. They run in line now. The client job and the declared-client jobs stay async. A test fails when an async kcadm task does not use the module or is not registered for the reap. A config file of its own per call was the other option. It does not work by itself, because the admin session lives only in the shared file. Closes #805 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Custom Modules (library/)
This directory contains project-specific Ansible modules used by Infinito.Nexus.
What Belongs Here
Use library/ for idempotent module logic that represents concrete automation actions.
Typical cases:
- managing resources that have no suitable built-in/community module,
- wrapping internal APIs or internal infrastructure semantics,
- implementing reusable module interfaces for role/playbook consumption.
What Does Not Belong Here
- Shared helper code used by multiple modules/plugins goes to
utils/. - Jinja transformations belong to
plugins/filter/. - Runtime value retrieval belongs to
plugins/lookup/. - Task execution wrappers belong to
plugins/action/.
Usage
Ansible searches library/ for custom modules. In playbooks, call them like built-in modules.
- name: Run a custom Infinito module
infinito_custom_module:
option_one: value
option_two: value
Implementation Notes
- Keep modules idempotent and predictable.
- Validate input early and return structured failure messages.
- Move duplicated helpers into
utils/.
Shebang Requirement for Custom Modules
Files in library/ should use:
#!/usr/bin/python
Ansible rewrites this interpreter path to the configured host interpreter for module execution.
References
- Developing modules: https://docs.ansible.com/ansible/latest/dev_guide/developing_modules.html
- Module utilities: https://docs.ansible.com/ansible/latest/dev_guide/developing_module_utilities.html