mirror of
https://github.com/ansible-collections/community.docker.git
synced 2026-07-29 11:55:04 +00:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user