Added: Update docker compose projects playbook
This commit is contained in:
@ -8,3 +8,9 @@
|
||||
name: bash,vim,htop,neofetch
|
||||
state: latest
|
||||
|
||||
- name: install docker
|
||||
become: true
|
||||
apk:
|
||||
name: docker
|
||||
state: present
|
||||
|
||||
|
23
playbooks/update-docker-project.yaml
Normal file
23
playbooks/update-docker-project.yaml
Normal 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
|
||||
|
33
playbooks/update-dockers.yaml
Normal file
33
playbooks/update-dockers.yaml
Normal 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
|
||||
|
Reference in New Issue
Block a user