Files
ansible-role-docker-compose…/tasks/update.yaml
2026-01-26 23:24:37 -05:00

31 lines
888 B
YAML

---
- name: "{{ app_name }} - Update application"
block:
- name: Stop application for update
community.docker.docker_compose_v2:
project_src: "{{ app_dir }}"
state: stopped
- name: Pull latest container images
community.docker.docker_compose_v2:
project_src: "{{ app_dir }}"
pull: always
- name: Start application with new images
community.docker.docker_compose_v2:
project_src: "{{ app_dir }}"
state: present
recreate: always
register: update_restart
- name: Verify application health after update
ansible.builtin.include_tasks: health_check.yaml
when: app_health_check | default(true)
rescue:
- name: Update failed, attempt to restart application
community.docker.docker_compose_v2:
project_src: "{{ app_dir }}"
state: present
tags: [update]