Optimized docker compose ensure logic

This commit is contained in:
Kevin Veen-Birkenbach 2025-08-11 01:26:10 +02:00
parent 766ef8619f
commit a9d77de2a4
No known key found for this signature in database
GPG Key ID: 44D8F11FD62F878E
2 changed files with 8 additions and 4 deletions

View File

@ -3,12 +3,16 @@
args: args:
chdir: "{{ docker_compose.directories.instance }}" chdir: "{{ docker_compose.directories.instance }}"
register: docker_ps register: docker_ps
changed_when: (docker_ps.stdout | trim) == "" changed_when: >
(docker_ps.stdout | trim) == ""
# The failed when catches the condition when an docker compose file will be dynamicly build after the file routine # The failed when catches the condition when an docker compose file will be dynamicly build after the file routine
# Also if an .env file isn't present
failed_when: > failed_when: >
docker_ps.rc != 0 docker_ps.rc != 0
and and (
'no configuration file provided: not found' not in (docker_ps.stderr | default('')) (docker_ps.stderr | default(''))
| regex_search('(no configuration file provided|no such file or directory|env file .* not found)') is none
)
when: > when: >
not ( not (
docker_compose_template.changed | default(false) docker_compose_template.changed | default(false)

View File

@ -1 +1 @@
docker_compose_variable_file: "{{ role_path }}/vars/docker-compose.yml" docker_compose_variable_file: "{{ role_path }}/vars/docker-compose.yml"