docker_compose_v2: add ignore_build_events option; ignore build events by default (#1011)

* Add ignore_build_events option.

* Adjust docs and tests.

* Switch default to true.

* Remove unnecessary parts from tests.
This commit is contained in:
Felix Fontein
2024-12-14 19:54:40 +01:00
committed by GitHub
parent 80770ed972
commit 2e7b4e4605
4 changed files with 88 additions and 176 deletions
@@ -13,6 +13,7 @@
{{ cname }}:
build: ./build
image: "{{ iname }}"
pull_policy: never
stop_grace_period: 1s
block:
@@ -30,10 +31,6 @@
- '{{ project_src }}'
- '{{ project_src }}/build'
####################################################################
## Present #########################################################
####################################################################
- name: Template default project file
copy:
dest: '{{ project_src }}/docker-compose.yml'
@@ -72,6 +69,40 @@
state: present
register: present_2
- name: Present (idempotent check, build=always, ignore_build_events=false)
docker_compose_v2:
project_src: '{{ project_src }}'
state: present
build: always
ignore_build_events: false
check_mode: true
register: present_3_check
- name: Present (idempotent, build=always, ignore_build_events=false)
docker_compose_v2:
project_src: '{{ project_src }}'
state: present
build: always
ignore_build_events: false
register: present_3
- name: Present (idempotent check, build=always, ignore_build_events=true)
docker_compose_v2:
project_src: '{{ project_src }}'
state: present
build: always
ignore_build_events: true
check_mode: true
register: present_4_check
- name: Present (idempotent, build=always, ignore_build_events=true)
docker_compose_v2:
project_src: '{{ project_src }}'
state: present
build: always
ignore_build_events: true
register: present_4
- assert:
that:
- present_1_check is changed
@@ -88,175 +119,17 @@
- present_2_check.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_2 is not changed
- present_2.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_3_check is changed
- present_3_check.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- ((present_3 is changed) if docker_compose_version is version('2.31.0', '>=') else (present_3 is not changed))
- present_3.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_4_check is changed
- present_4_check.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_4 is not changed
- present_4.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
####################################################################
## Absent ##########################################################
####################################################################
- name: Absent (check)
docker_compose_v2:
project_src: '{{ project_src }}'
state: absent
check_mode: true
register: absent_1_check
- name: Absent
docker_compose_v2:
project_src: '{{ project_src }}'
state: absent
register: absent_1
- name: Absent (idempotent check)
docker_compose_v2:
project_src: '{{ project_src }}'
state: absent
check_mode: true
register: absent_2_check
- name: Absent (idempotent)
docker_compose_v2:
project_src: '{{ project_src }}'
state: absent
register: absent_2
- assert:
that:
- absent_1_check is changed
- absent_1_check.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- absent_1 is changed
- absent_1.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- absent_2_check is not changed
- absent_2_check.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- absent_2 is not changed
- absent_2.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
####################################################################
## Stopping and starting ###########################################
####################################################################
- name: Present stopped (check)
docker_compose_v2:
project_src: '{{ project_src }}'
state: stopped
check_mode: true
register: present_1_check
- name: Present stopped
docker_compose_v2:
project_src: '{{ project_src }}'
state: stopped
register: present_1
- name: Present stopped (idempotent check)
docker_compose_v2:
project_src: '{{ project_src }}'
state: stopped
check_mode: true
register: present_2_check
- name: Present stopped (idempotent)
docker_compose_v2:
project_src: '{{ project_src }}'
state: stopped
register: present_2
- name: Started (check)
docker_compose_v2:
project_src: '{{ project_src }}'
state: present
check_mode: true
register: present_3_check
- name: Started
docker_compose_v2:
project_src: '{{ project_src }}'
state: present
register: present_3
- name: Started (idempotent check)
docker_compose_v2:
project_src: '{{ project_src }}'
state: present
check_mode: true
register: present_4_check
- name: Started (idempotent)
docker_compose_v2:
project_src: '{{ project_src }}'
state: present
register: present_4
- name: Restarted (check)
docker_compose_v2:
project_src: '{{ project_src }}'
state: restarted
check_mode: true
register: present_5_check
- name: Restarted
docker_compose_v2:
project_src: '{{ project_src }}'
state: restarted
register: present_5
- name: Stopped (check)
docker_compose_v2:
project_src: '{{ project_src }}'
state: stopped
check_mode: true
register: present_6_check
- name: Stopped
docker_compose_v2:
project_src: '{{ project_src }}'
state: stopped
register: present_6
- name: Restarted (check)
docker_compose_v2:
project_src: '{{ project_src }}'
state: restarted
check_mode: true
register: present_7_check
- name: Restarted
docker_compose_v2:
project_src: '{{ project_src }}'
state: restarted
register: present_7
always:
- name: Cleanup
docker_compose_v2:
project_src: '{{ project_src }}'
state: absent
- assert:
that:
- present_1_check is changed
- present_1_check.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_1 is changed
- present_1.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_2_check is not changed
- present_2_check.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_2 is not changed
- present_2.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_3_check is changed
- present_3_check.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_3 is changed
- present_3.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_4_check is not changed
- present_4_check.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_4 is not changed
- present_4.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_5_check is changed
- present_5_check.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_5 is changed
- present_5.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_6_check is changed
- present_6_check.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_6 is changed
- present_6.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_7_check is changed
- present_7_check.warnings | default([]) | select('regex', ' Please report this at ') | length == 0
- present_7 is changed
- present_7.warnings | default([]) | select('regex', ' Please report this at ') | length == 0