3
0
forked from jakub/ansible

Refactor Semaphore self-update task to use nohup for background execution and simplify Docker command handling

This commit is contained in:
martin.fencl
2025-11-25 00:11:20 +01:00
parent 97dc09e45c
commit 4a462417a9

View File

@@ -22,9 +22,6 @@
semaphore_compose_file: "/data/compose/semaphore/docker-compose.yml"
semaphore_service: "semaphore"
# Docker command prefix (consistent behavior and quiet hints)
docker_prefix: "unalias docker 2>/dev/null || true; DOCKER_CLI_HINTS=0; command docker"
tasks:
- name: Ensure sshpass is installed (for password-based SSH) # English comments
ansible.builtin.apt:
@@ -32,11 +29,11 @@
state: present
update_cache: yes
- name: Run Semaphore self-update on VM (single compose command) # last thing this job does
- name: Run Semaphore self-update on VM in background (nohup)
ansible.builtin.command:
argv:
- sshpass
- -e # read password from SSHPASS environment
- -e
- ssh
- -o
- StrictHostKeyChecking=no
@@ -45,14 +42,16 @@
- "{{ vm_user }}@{{ vm_ip }}"
- bash
- -lc
- >
{{ ('sudo ' if use_sudo else '') }}
{{ docker_prefix }}
compose -p {{ semaphore_project }}
-f {{ semaphore_compose_file }}
up -d --no-deps --force-recreate --pull always {{ semaphore_service }} >/dev/null
- |
nohup bash -c '
unalias docker 2>/dev/null || true
DOCKER_CLI_HINTS=0 docker compose \
-p {{ semaphore_project }} \
-f {{ semaphore_compose_file }} \
up -d --no-deps --force-recreate --pull always {{ semaphore_service }}
' >/dev/null 2>&1 &
environment:
SSHPASS: "{{ vm_pass }}" # supply password via environment
SSHPASS: "{{ vm_pass }}"
register: semaphore_update
changed_when: false
no_log: "{{ DEBUG == 0 }}"