blumeops/ansible/roles/jellyfin_metrics/tasks/main.yml
Erich Blume 7f41621c7f Migrate Ansible op calls to op read URI syntax (#125)
## Summary
- Convert all 12 `op item get ... --fields ... --reveal` calls in Ansible to the newer `op read "op://vault/item/field"` syntax
- Remove the `regex_replace` workaround on the Fly deploy token (no longer needed since `op read` returns clean unquoted values)
- Covers `ansible/playbooks/indri.yml`, `ansible/roles/caddy/tasks/main.yml`, `ansible/roles/jellyfin_metrics/tasks/main.yml`, and `ansible/roles/alloy/tasks/main.yml`

## Test plan
- [x] `mise run provision-indri -- --check --diff` dry run passes (ok=67, failed=0)
- [x] No `op item get` calls remain in `ansible/` directory
- [x] All pre-commit hooks pass (yaml, ansible-lint, TruffleHog, etc.)
- [ ] Full provision run after merge to confirm secrets resolve correctly

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Reviewed-on: https://forge.ops.eblu.me/eblume/blumeops/pulls/125
2026-02-08 10:52:43 -08:00

55 lines
1.8 KiB
YAML

---
- name: Fetch Jellyfin API key (when running with --tags jellyfin_metrics)
ansible.builtin.command:
cmd: op read "op://vg6xf6vvfmoh5hqjjhlhbeoaie/ceywxkcd3z7najsy2nmmbs2vke/credential"
delegate_to: localhost
register: jellyfin_metrics_api_key_fallback
changed_when: false
no_log: true
check_mode: false
when: jellyfin_metrics_api_key is not defined
- name: Set Jellyfin API key fact (fallback)
ansible.builtin.set_fact:
jellyfin_metrics_api_key: "{{ jellyfin_metrics_api_key_fallback.stdout }}"
no_log: true
when: jellyfin_metrics_api_key is not defined
- name: Write Jellyfin API key file
ansible.builtin.copy:
content: "{{ jellyfin_metrics_api_key }}"
dest: "{{ jellyfin_metrics_api_key_file }}"
mode: '0600'
no_log: true
- name: Ensure bin directory exists
ansible.builtin.file:
path: "{{ jellyfin_metrics_script | dirname }}"
state: directory
mode: '0755'
- name: Deploy jellyfin metrics collection script
ansible.builtin.template:
src: jellyfin-metrics.sh.j2
dest: "{{ jellyfin_metrics_script }}"
mode: '0755'
notify: Reload jellyfin-metrics
- name: Deploy jellyfin-metrics LaunchAgent plist
ansible.builtin.template:
src: jellyfin-metrics.plist.j2
dest: ~/Library/LaunchAgents/mcquack.eblume.jellyfin-metrics.plist
mode: '0644'
notify: Reload jellyfin-metrics
- name: Check if jellyfin-metrics LaunchAgent is loaded
ansible.builtin.command: launchctl list mcquack.eblume.jellyfin-metrics
register: jellyfin_metrics_launchctl_check
changed_when: false
failed_when: false
- name: Load jellyfin-metrics LaunchAgent if not loaded
ansible.builtin.command: launchctl load ~/Library/LaunchAgents/mcquack.eblume.jellyfin-metrics.plist
when: jellyfin_metrics_launchctl_check.rc != 0
changed_when: true
failed_when: false