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:
@@ -22,9 +22,6 @@
|
|||||||
semaphore_compose_file: "/data/compose/semaphore/docker-compose.yml"
|
semaphore_compose_file: "/data/compose/semaphore/docker-compose.yml"
|
||||||
semaphore_service: "semaphore"
|
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:
|
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:
|
||||||
@@ -32,11 +29,11 @@
|
|||||||
state: present
|
state: present
|
||||||
update_cache: yes
|
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:
|
ansible.builtin.command:
|
||||||
argv:
|
argv:
|
||||||
- sshpass
|
- sshpass
|
||||||
- -e # read password from SSHPASS environment
|
- -e
|
||||||
- ssh
|
- ssh
|
||||||
- -o
|
- -o
|
||||||
- StrictHostKeyChecking=no
|
- StrictHostKeyChecking=no
|
||||||
@@ -45,14 +42,16 @@
|
|||||||
- "{{ vm_user }}@{{ vm_ip }}"
|
- "{{ vm_user }}@{{ vm_ip }}"
|
||||||
- bash
|
- bash
|
||||||
- -lc
|
- -lc
|
||||||
- >
|
- |
|
||||||
{{ ('sudo ' if use_sudo else '') }}
|
nohup bash -c '
|
||||||
{{ docker_prefix }}
|
unalias docker 2>/dev/null || true
|
||||||
compose -p {{ semaphore_project }}
|
DOCKER_CLI_HINTS=0 docker compose \
|
||||||
-f {{ semaphore_compose_file }}
|
-p {{ semaphore_project }} \
|
||||||
up -d --no-deps --force-recreate --pull always {{ semaphore_service }} >/dev/null
|
-f {{ semaphore_compose_file }} \
|
||||||
|
up -d --no-deps --force-recreate --pull always {{ semaphore_service }}
|
||||||
|
' >/dev/null 2>&1 &
|
||||||
environment:
|
environment:
|
||||||
SSHPASS: "{{ vm_pass }}" # supply password via environment
|
SSHPASS: "{{ vm_pass }}"
|
||||||
register: semaphore_update
|
register: semaphore_update
|
||||||
changed_when: false
|
changed_when: false
|
||||||
no_log: "{{ DEBUG == 0 }}"
|
no_log: "{{ DEBUG == 0 }}"
|
||||||
|
|||||||
Reference in New Issue
Block a user