Add build state, rename present->running

This commit is contained in:
Tobias Manske 2023-05-05 23:52:24 +02:00
parent 6ff153b716
commit f216347cae
Signed by: tobias
GPG Key ID: 9164B527694A0709
5 changed files with 36 additions and 13 deletions

View File

@ -2,5 +2,5 @@
# defaults file for roles/compose_project
service: dummy
compose_dir: /home/core/compose
state: present # or absent
restart: smart # or always or never
state: present # or running, build, absent
execute: smart # or always or never

13
tasks/build.yml Normal file
View File

@ -0,0 +1,13 @@
---
- include_tasks: present.yml
- name: Build Service
community.docker.docker_compose:
project_src: "{{ service_dir | mandatory }}"
state: present
restarted: true
recreate: smart
build: true
remove_orphans: true
when: (compose_files.changed and execute == "smart") or execute == "always"

View File

@ -9,7 +9,13 @@
msg: "Working on {{ service }}{% if service_name is defined %}-{{ service_name }}{% endif %}"
verbosity: 0
- include_tasks: create.yml
- include_tasks: running.yml
when: state == "running"
- include_tasks: build.yml
when: state == "build"
- include_tasks: present.yml
when: state == "present"
- include_tasks: remove.yml

View File

@ -56,13 +56,3 @@
path: "{{ temp_file.path }}"
state: absent
changed_when: false
- name: Restart Service
community.docker.docker_compose:
project_src: "{{ service_dir | mandatory }}"
state: present
restarted: true
recreate: smart
build: true
remove_orphans: true
when: (compose_files.changed and restart == "smart") or restart == "always"

14
tasks/running.yml Normal file
View File

@ -0,0 +1,14 @@
---
- include_tasks: present.yml
- name: Restart Service
community.docker.docker_compose:
project_src: "{{ service_dir | mandatory }}"
pull: true
state: present
restarted: true
recreate: smart
build: false
remove_orphans: true
when: (compose_files.changed and execute == "smart") or execute == "always"