docker_host_info - Allow filters which are passed as lists (#160)

* Initial Commit

* Adding integration tests

* Adding example in docs

* Adding changelog fragment

* Applying initial review suggestions
This commit is contained in:
Ajpantuso
2021-06-22 16:27:38 -04:00
committed by GitHub
parent af2b3b0493
commit 49c8fd0aa5
4 changed files with 77 additions and 10 deletions
@@ -31,6 +31,9 @@
image: "{{ docker_test_image_alpine }}"
command: '/bin/sh -c "sleep 10m"'
name: "{{ cname }}"
labels:
key1: value1
key2: value2
state: started
register: container_output
@@ -63,6 +66,44 @@
- 'output.containers[0].Image is string'
- 'output.containers[0].ImageID is not defined'
- name: Get info on Docker host and list containers matching filters (single label)
docker_host_info:
containers: yes
containers_filters:
label: key1=value1
register: output
- name: assert container is returned when filters are matched (single label)
assert:
that: "{{ output.containers | length }} == 1"
- name: Get info on Docker host and list containers matching filters (multiple labels)
docker_host_info:
containers: yes
containers_filters:
label:
- key1=value1
- key2=value2
register: output
- name: assert container is returned when filters are matched (multiple labels)
assert:
that: "{{ output.containers | length }} == 1"
- name: Get info on Docker host and do not list containers which do not match filters
docker_host_info:
containers: yes
containers_filters:
label:
- key1=value1
- key2=value2
- key3=value3
register: output
- name: assert no container is returned when filters are not matched
assert:
that: "{{ output.containers | length }} == 0"
- name: Get info on Docker host and list containers with verbose output
docker_host_info:
containers: yes