fix(roles): detect new image on podman pull and restart services

Same bug as immich (556fae8): 'Writing manifest' goes to stderr, so
changed_when never matched and the restart handlers never fired after
image upgrades. Compare local image IDs before/after pull instead, and
notify the restart handler only on a genuinely new image.

Applies to fdroid, gitea, metabase, ntfy, unifi, uptime-kuma.
This commit is contained in:
Clément Désiles
2026-07-04 00:06:13 +02:00
parent 556fae86d9
commit 95a743ddeb
6 changed files with 78 additions and 24 deletions
+13 -4
View File
@@ -25,13 +25,22 @@
group: "{{ ansible_user }}"
mode: "0755"
- name: Pull UniFi container image
ansible.builtin.command: "podman pull {{ unifi_image }}:{{ unifi_version }}"
changed_when: pull_result.stdout is search('Writing manifest')
register: pull_result
- name: Get current unifi image ID
ansible.builtin.command: "podman image inspect --format {% raw %}{{.Id}}{% endraw %} {{ unifi_image }}:{{ unifi_version }}"
register: unifi_image_id_before
failed_when: false # image may not exist yet on first deploy
changed_when: false
become: false
become_user: "{{ ansible_user }}"
- name: Pull UniFi container image
ansible.builtin.command: "podman pull --quiet {{ unifi_image }}:{{ unifi_version }}"
register: pull_result
changed_when: pull_result.stdout != unifi_image_id_before.stdout
become: false
become_user: "{{ ansible_user }}"
notify: Restart unifi
- name: Deploy Kubernetes YAML for unifi
ansible.builtin.template:
src: unifi.yaml.j2