Initial Ansible scenarios
This commit is contained in:
@@ -0,0 +1,46 @@
|
||||
---
|
||||
- name: List running Docker Compose projects
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- compose
|
||||
- ls
|
||||
- --format
|
||||
- json
|
||||
register: docker_compose_projects
|
||||
changed_when: false
|
||||
|
||||
- name: Select running Docker Compose projects
|
||||
ansible.builtin.set_fact:
|
||||
running_compose_projects: "{{ docker_compose_projects.stdout | from_json }}"
|
||||
|
||||
- name: Pull images for each running Docker Compose project
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- compose
|
||||
- -p
|
||||
- "{{ item.Name }}"
|
||||
- pull
|
||||
environment:
|
||||
COMPOSE_FILE: "{{ item.ConfigFiles | replace(',', ':') }}"
|
||||
loop: "{{ running_compose_projects }}"
|
||||
loop_control:
|
||||
label: "{{ item.Name }}"
|
||||
changed_when: true
|
||||
|
||||
- name: Recreate Docker Compose containers with updated images
|
||||
ansible.builtin.command:
|
||||
argv:
|
||||
- docker
|
||||
- compose
|
||||
- -p
|
||||
- "{{ item.Name }}"
|
||||
- up
|
||||
- -d
|
||||
environment:
|
||||
COMPOSE_FILE: "{{ item.ConfigFiles | replace(',', ':') }}"
|
||||
loop: "{{ running_compose_projects }}"
|
||||
loop_control:
|
||||
label: "{{ item.Name }}"
|
||||
changed_when: true
|
||||
Reference in New Issue
Block a user