create dir && restart service on change

This commit is contained in:
Gabriel Augendre 2024-10-11 00:30:49 +02:00
parent d3f116052c
commit 031c804d97
2 changed files with 14 additions and 0 deletions

View file

@ -6,3 +6,5 @@ services:
- ./:/app - ./:/app
ports: ports:
- "9008:8080" - "9008:8080"
init: true
tty: true

View file

@ -3,6 +3,11 @@
hosts: servers hosts: servers
gather_facts: false gather_facts: false
tasks: tasks:
- name: Create dir
ansible.builtin.file:
path: "{{ dir }}"
state: directory
mode: "0775"
- name: Write app.py - name: Write app.py
ansible.builtin.copy: ansible.builtin.copy:
src: files/test_headers/app.py src: files/test_headers/app.py
@ -10,6 +15,8 @@
mode: "0644" mode: "0644"
owner: gaugendre owner: gaugendre
group: gaugendre group: gaugendre
notify:
- Restart service
- name: Write docker-compose.yaml - name: Write docker-compose.yaml
ansible.builtin.copy: ansible.builtin.copy:
src: files/test_headers/docker-compose.yaml src: files/test_headers/docker-compose.yaml
@ -21,5 +28,10 @@
community.docker.docker_compose_v2: community.docker.docker_compose_v2:
project_src: "{{ dir }}" project_src: "{{ dir }}"
state: present state: present
handlers:
- name: Restart service
community.docker.docker_compose_v2:
project_src: "{{ dir }}"
state: restarted
vars: vars:
dir: /mnt/data/test_headers dir: /mnt/data/test_headers