mirror of
https://github.com/kevinveenbirkenbach/computer-playbook.git
synced 2026-11-06 19:01:54 +00:00
The akaunting service is built from the akaunting/docker repository (ref master), whose Dockerfile downloads the latest Akaunting release into /var/www/html, the shared data volume. Since 2026-10-26 that Dockerfile builds on php:8.2, and Akaunting 3.3.0 (released 2026-10-27) requires PHP >= 8.2. The swarm setup job instead ran the upstream tag akaunting/akaunting:3.1.21 (PHP 8.1.34) against the same volume. It executed the 3.3.0 code there and failed with "Ask your hosting provider to use PHP 8.2.0 or higher" (main run 40507642995, Akaunting#0). Compose mode was unaffected because its setup uses `compose run akaunting`, i.e. the built image. Read the image from the service spec and start the setup job with it, so code and runtime always come from the same build. Drop the now unused AKAUNTING_IMAGE/AKAUNTING_VERSION vars. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
80 lines
3.3 KiB
YAML
80 lines
3.3 KiB
YAML
---
|
|
- name: "📏 Akaunting setup | Scale akaunting service to 0 replicas"
|
|
ansible.builtin.shell: >
|
|
container service update --detach --replicas 0
|
|
{{ AKAUNTING_SERVICE | quote }}
|
|
changed_when: true
|
|
|
|
- name: "⏳ Akaunting setup | Wait until no running task remains"
|
|
ansible.builtin.shell: |
|
|
container service ps {{ AKAUNTING_SERVICE | quote }} \
|
|
--filter desired-state=running \
|
|
--format '{{ "{{.CurrentState}}" }}' | wc -l | grep -qE '^\s*0\s*$'
|
|
register: akaunting_swarm_drained
|
|
changed_when: false
|
|
retries: 60
|
|
delay: 5
|
|
until: akaunting_swarm_drained.rc == 0
|
|
|
|
# Exception: the service runs the image built from the akaunting/docker repository, whose code lands in the shared volume; the upstream tag carries an older PHP that cannot run that code.
|
|
- name: "🔍 Akaunting setup | Read the image the akaunting service runs"
|
|
ansible.builtin.command: >-
|
|
container service inspect {{ AKAUNTING_SERVICE }}
|
|
--format {{ '{{.Spec.TaskTemplate.ContainerSpec.Image}}' }}
|
|
register: akaunting_service_image
|
|
changed_when: false
|
|
failed_when: akaunting_service_image.rc != 0 or (akaunting_service_image.stdout | trim | length == 0)
|
|
|
|
- name: "▶️ Akaunting setup | Run one-shot install"
|
|
ansible.builtin.shell: |
|
|
set -euo pipefail
|
|
JOB={{ AKAUNTING_SETUP_JOB | quote }}
|
|
container service rm "$JOB" 2>/dev/null || true
|
|
container service create --detach --restart-condition on-failure --restart-max-attempts 3 --name "$JOB" \
|
|
--constraint node.role==manager \
|
|
--env-file {{ lookup('container', application_id, 'files.env') | quote }} \
|
|
--env AKAUNTING_SETUP=true \
|
|
--mount type=volume,source={{ AKAUNTING_VOLUME | quote }},target={{ lookup('volume', 'web-app-akaunting', 'data').target }} \
|
|
--network {{ application_id | get_entity_name | quote }} \
|
|
{% if lookup('database', application_id, 'shared') | bool %}--network {{ lookup('database', application_id, 'network') | quote }} {% endif %}\
|
|
{{ akaunting_service_image.stdout | trim | quote }} \
|
|
{{ AKAUNTING_ENTRYPOINT }}
|
|
changed_when: true
|
|
|
|
- name: "⏳ Akaunting setup | Wait for install job to complete"
|
|
ansible.builtin.script: "{{ lookup('path_absolute', 'roles/sys-svc-compose/files/shell/swarm/job_state.sh') }}"
|
|
environment:
|
|
JOB: "{{ AKAUNTING_SETUP_JOB }}"
|
|
register: akaunting_setup_done
|
|
changed_when: false
|
|
retries: 60
|
|
delay: 5
|
|
until: akaunting_setup_done.rc != 1
|
|
failed_when: akaunting_setup_done.rc != 0
|
|
|
|
- name: "🗑️ Akaunting setup | Remove one-shot install service"
|
|
ansible.builtin.shell: >
|
|
container service rm
|
|
{{ AKAUNTING_SETUP_JOB }}
|
|
changed_when: true
|
|
failed_when: false
|
|
|
|
- name: "📏 Akaunting setup | Scale akaunting back to nominal replicas"
|
|
ansible.builtin.shell: >
|
|
container service update --detach --replicas {{ AKAUNTING_REPLICAS }}
|
|
{{ AKAUNTING_SERVICE | quote }}
|
|
changed_when: true
|
|
|
|
- name: "⏳ Akaunting setup | Wait until replicas converge X/X"
|
|
ansible.builtin.shell: |
|
|
set -euo pipefail
|
|
SVC={{ AKAUNTING_SERVICE | quote }}
|
|
WANT={{ AKAUNTING_REPLICAS }}/{{ AKAUNTING_REPLICAS }}
|
|
got="$(container service ls --filter name="$SVC" --format '{{ "{{.Replicas}}" }}' | head -1)"
|
|
test "$got" = "$WANT"
|
|
register: akaunting_replicas_converged
|
|
changed_when: false
|
|
retries: 60
|
|
delay: 5
|
|
until: akaunting_replicas_converged.rc == 0
|