Added: Update docker compose projects playbook

This commit is contained in:
2025-03-27 16:39:57 +01:00
parent 4c7e68c276
commit 7ee0bdba59
8 changed files with 95 additions and 22 deletions

View File

@ -8,3 +8,9 @@
name: bash,vim,htop,neofetch
state: latest
- name: install docker
become: true
apk:
name: docker
state: present

View File

@ -0,0 +1,23 @@
---
- name: Pull updated images for project at {{ project.path }}
community.docker.docker_compose_v2_pull:
project_src: "{{ project.path }}"
register: pull_result
- name: Debug pull result for {{ project.path }}
debug:
msg: "Pull changed: {{ pull_result.changed }} for project at {{ project.path }}"
- name: Restart project at {{ project.path }} if images updated
block:
- name: Bring project down at {{ project.path }}
community.docker.docker_compose_v2:
project_src: "{{ project.path }}"
state: absent
- name: Bring project up (detached) at {{ project.path }}
community.docker.docker_compose_v2:
project_src: "{{ project.path }}"
state: present
when: pull_result.changed

View File

@ -0,0 +1,33 @@
---
- name: Update docker-compose projects on filiprojek-media
hosts: filiprojek-media
become: false # user fr is in the docker group
vars:
docker_projects:
- path: /srv/docker/immich/
- path: /srv/docker/jellyfin/
- path: /srv/docker/radarr/
- path: /srv/docker/syncthing/
tasks:
- name: Process each docker-compose project
ansible.builtin.include_tasks: update-docker-project.yaml
loop: "{{ docker_projects }}"
loop_control:
loop_var: project
- name: Update docker-compose projects fofrweb-s3
hosts: fofrweb-s3
become: false # user filiprojek is in the docker group
vars:
docker_projects:
- path: /srv/www/cz/filiprojek/git
- path: /srv/www/com/fofrweb/status
tasks:
- name: Process each docker-compose project
ansible.builtin.include_tasks: update-docker-project.yaml
loop: "{{ docker_projects }}"
loop_control:
loop_var: project