d2e8cc6e70
- ansible.cfg: enable host_key_checking (closes #1) - update_upgrade.yml: fix reboot crash on non-Debian hosts, exclude AnsibleHost from targets (closes #2, #7) - deploy.yml: replace silent ignore_errors with real container health assertion (closes #3) - redeploy.yml: same assertion fix + restic --overwrite always + RESTIC_RESTORE_PATH variable (closes #3, #4, #5) - disaster.yml: same fixes as redeploy.yml (closes #3, #4, #5) - docker_update_containers.yml: create missing playbook (closes #6) - fresh_install.yml: add safety guard to abort if containers already running (closes #8) - docker_status.yml: add become: true (closes #9) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
38 lines
1.2 KiB
YAML
38 lines
1.2 KiB
YAML
---
|
|
- name: Pull latest images and recreate updated containers
|
|
hosts: Docker
|
|
tasks:
|
|
- name: Pull latest images
|
|
ansible.builtin.command:
|
|
cmd: docker compose pull
|
|
chdir: ~/docker
|
|
register: pull_result
|
|
changed_when: "'Downloaded newer image' in pull_result.stdout or 'Pulled' in pull_result.stdout"
|
|
|
|
- name: Recreate containers with updated images
|
|
ansible.builtin.command:
|
|
cmd: docker compose up -d --remove-orphans
|
|
chdir: ~/docker
|
|
|
|
- name: Pause for 30 seconds to allow containers to stabilize
|
|
ansible.builtin.pause:
|
|
seconds: 30
|
|
|
|
- name: Verify all containers are running
|
|
ansible.builtin.shell: |
|
|
expected=$(docker compose config --services | wc -l | tr -d ' ')
|
|
running=$(docker compose ps --status running -q | wc -l | tr -d ' ')
|
|
if [ "$expected" != "$running" ]; then
|
|
echo "FAIL: $running/$expected containers running"
|
|
docker compose ps
|
|
exit 1
|
|
fi
|
|
echo "OK: all $running containers running"
|
|
args:
|
|
chdir: ~/docker
|
|
changed_when: false
|
|
|
|
- name: Remove dangling images
|
|
ansible.builtin.command:
|
|
cmd: docker image prune -f
|