3
0
forked from jakub/ansible
This commit is contained in:
martin.fencl
2025-12-10 12:11:05 +01:00
parent bf35a6c253
commit 0fd5ef9e41

View File

@@ -39,7 +39,7 @@
# Docker command prefix (consistent behavior and quiet hints) # Docker command prefix (consistent behavior and quiet hints)
docker_prefix: "unalias docker 2>/dev/null || true; DOCKER_CLI_HINTS=0; command docker" docker_prefix: "unalias docker 2>/dev/null || true; DOCKER_CLI_HINTS=0; command docker"
# Commands to run on the target VM (quiet outputs) # Commands to run on the target VM (quiet outputs)
# 1) Check directory exists (we do NOT create anything, to stay safe) # 1) Check directory exists (we do NOT create anything, to stay safe)
# 2) Safely download latest docker-compose.yml from GitHub (with backup) # 2) Safely download latest docker-compose.yml from GitHub (with backup)
@@ -47,27 +47,33 @@
# 4) Start / update stack # 4) Start / update stack
immich_commands: immich_commands:
- >- - >-
if [ ! -d '{{ immich_compose_dir }}' ]; then [ -d "{{ immich_compose_dir }}" ] || {
echo 'ERROR: Directory {{ immich_compose_dir }} does not exist on VM; not touching anything.' >&2; echo "ERROR: Directory {{ immich_compose_dir }} does not exist on VM; not touching anything." >&2;
exit 1; exit 1;
fi }
- >- - >-
cd '{{ immich_compose_dir }}' && cd "{{ immich_compose_dir }}" &&
wget -qO docker-compose.yml.new "{{ immich_compose_url }}" || true; wget -qO docker-compose.yml.new "{{ immich_compose_url }}" || {
echo "ERROR: Failed to download docker-compose.yml from GitHub; keeping existing one." >&2;
rm -f docker-compose.yml.new 2>/dev/null || true;
exit 1;
};
if [ -s docker-compose.yml.new ]; then if [ -s docker-compose.yml.new ]; then
echo 'Downloaded new docker-compose.yml from GitHub (Immich latest).'; echo "Downloaded new docker-compose.yml from GitHub (Immich latest).";
if [ -f docker-compose.yml ]; then if [ -f docker-compose.yml ]; then
cp docker-compose.yml "docker-compose.yml.bak-$(date +%F_%H-%M-%S)"; cp docker-compose.yml "docker-compose.yml.bak-$(date +%F_%H-%M-%S)";
echo 'Existing docker-compose.yml backed up.'; echo "Existing docker-compose.yml backed up.";
fi; fi;
mv docker-compose.yml.new docker-compose.yml; mv docker-compose.yml.new docker-compose.yml;
else else
echo 'WARNING: Failed to download a valid docker-compose.yml, keeping existing one.' >&2; echo "WARNING: Downloaded docker-compose.yml.new is empty; keeping existing one." >&2;
rm -f docker-compose.yml.new 2>/dev/null || true; rm -f docker-compose.yml.new 2>/dev/null || true;
exit 1;
fi fi
- "{{ docker_prefix }} compose -p {{ immich_project }} -f {{ immich_compose_file }} pull >/dev/null" - "{{ docker_prefix }} compose -p {{ immich_project }} -f {{ immich_compose_file }} pull >/dev/null"
- "{{ docker_prefix }} compose -p {{ immich_project }} -f {{ immich_compose_file }} up -d --remove-orphans >/dev/null" - "{{ docker_prefix }} compose -p {{ immich_project }} -f {{ immich_compose_file }} up -d --remove-orphans >/dev/null"
tasks: tasks:
- name: Ensure sshpass is installed (for password-based SSH) # English comments - name: Ensure sshpass is installed (for password-based SSH) # English comments
ansible.builtin.apt: ansible.builtin.apt: