## Summary - Simplify kiwix role from 213 lines to 151 lines (-30%) - Replace per-archive torrent status loops with single shell command - Decouple kiwix startup from declared inventory - now serves whatever completed ZIM files exist - Fix tailscale_serve role to handle empty JSON in check mode ## Performance improvement - **Before**: ~132 operations (44 archives × 3 loops for status check, recheck, symlink) - **After**: ~5 operations (1 shell script + 1 find + conditional symlinks) - Expected reduction: ~3 minutes per ansible run ## Test plan - [x] Ran `mise run provision-indri -- --check --diff` to preview changes - [x] Ran `mise run provision-indri` to apply changes - [x] Ran `mise run indri-services-check` - all services healthy 🤖 Generated with [Claude Code](https://claude.com/claude-code) Reviewed-on: https://forge.tail8d86e.ts.net/eblume/blumeops/pulls/18
36 lines
1.3 KiB
YAML
36 lines
1.3 KiB
YAML
---
|
|
- name: Get current tailscale serve status
|
|
ansible.builtin.command: tailscale serve status --json
|
|
register: serve_status
|
|
changed_when: false
|
|
|
|
- name: Parse serve status
|
|
ansible.builtin.set_fact:
|
|
serve_config: "{{ ((serve_status.stdout | default('{}', true)) | from_json).Services | default({}) }}"
|
|
|
|
# Configure HTTPS if service doesn't have Web config yet
|
|
- name: Configure HTTPS services
|
|
ansible.builtin.command: >
|
|
tailscale serve --service="{{ item.name }}"
|
|
--https={{ item.https.port }} {{ item.https.upstream }}
|
|
loop: "{{ tailscale_services }}"
|
|
when:
|
|
- item.https is defined
|
|
- serve_config[item.name] is not defined or serve_config[item.name].Web is not defined
|
|
register: https_result
|
|
failed_when: false
|
|
|
|
# Configure TCP if service doesn't have the specific port configured yet
|
|
- name: Configure TCP services
|
|
ansible.builtin.command: >
|
|
tailscale serve --service="{{ item.name }}"
|
|
--tcp={{ item.tcp.port }} {{ item.tcp.upstream }}
|
|
loop: "{{ tailscale_services }}"
|
|
when:
|
|
- item.tcp is defined
|
|
- serve_config[item.name] is not defined or
|
|
serve_config[item.name].TCP is not defined or
|
|
serve_config[item.name].TCP[item.tcp.port | string] is not defined or
|
|
serve_config[item.name].TCP[item.tcp.port | string].TCPForward is not defined
|
|
register: tcp_result
|
|
failed_when: false
|