summaryrefslogtreecommitdiffstats
path: root/test/integration/targets/docker_container
diff options
context:
space:
mode:
Diffstat (limited to 'test/integration/targets/docker_container')
-rw-r--r--test/integration/targets/docker_container/aliases5
-rw-r--r--test/integration/targets/docker_container/files/env-file2
-rw-r--r--test/integration/targets/docker_container/meta/main.yml3
-rw-r--r--test/integration/targets/docker_container/tasks/main.yml43
-rw-r--r--test/integration/targets/docker_container/tasks/run-test.yml3
-rw-r--r--test/integration/targets/docker_container/tasks/tests/comparisons.yml463
-rw-r--r--test/integration/targets/docker_container/tasks/tests/compatibility.yml118
-rw-r--r--test/integration/targets/docker_container/tasks/tests/image-ids.yml146
-rw-r--r--test/integration/targets/docker_container/tasks/tests/mounts-volumes.yml445
-rw-r--r--test/integration/targets/docker_container/tasks/tests/network.yml736
-rw-r--r--test/integration/targets/docker_container/tasks/tests/options.yml3745
-rw-r--r--test/integration/targets/docker_container/tasks/tests/ports.yml286
-rw-r--r--test/integration/targets/docker_container/tasks/tests/regression-45700-dont-parse-on-absent.yml34
-rw-r--r--test/integration/targets/docker_container/tasks/tests/start-stop.yml455
14 files changed, 0 insertions, 6484 deletions
diff --git a/test/integration/targets/docker_container/aliases b/test/integration/targets/docker_container/aliases
deleted file mode 100644
index f5bf9f1010..0000000000
--- a/test/integration/targets/docker_container/aliases
+++ /dev/null
@@ -1,5 +0,0 @@
-shippable/posix/group5
-skip/osx
-skip/freebsd
-skip/aix
-destructive
diff --git a/test/integration/targets/docker_container/files/env-file b/test/integration/targets/docker_container/files/env-file
deleted file mode 100644
index b15f1b64cf..0000000000
--- a/test/integration/targets/docker_container/files/env-file
+++ /dev/null
@@ -1,2 +0,0 @@
-TEST3=val3
-TEST4=val4
diff --git a/test/integration/targets/docker_container/meta/main.yml b/test/integration/targets/docker_container/meta/main.yml
deleted file mode 100644
index 07da8c6dda..0000000000
--- a/test/integration/targets/docker_container/meta/main.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-dependencies:
- - setup_docker
diff --git a/test/integration/targets/docker_container/tasks/main.yml b/test/integration/targets/docker_container/tasks/main.yml
deleted file mode 100644
index 16aaea684f..0000000000
--- a/test/integration/targets/docker_container/tasks/main.yml
+++ /dev/null
@@ -1,43 +0,0 @@
----
-# Create random name prefix (for containers, networks, ...)
-- name: Create random container name prefix
- set_fact:
- cname_prefix: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
- cnames: []
- dnetworks: []
-
-- debug:
- msg: "Using container name prefix {{ cname_prefix }}"
-
-# Install netaddr
-- name: Install netaddr for ipaddr filter
- pip:
- name: netaddr
-
-# Run the tests
-- block:
- - include_tasks: run-test.yml
- with_fileglob:
- - "tests/*.yml"
-
- always:
- - name: "Make sure all containers are removed"
- docker_container:
- name: "{{ item }}"
- state: absent
- force_kill: yes
- with_items: "{{ cnames }}"
- diff: no
- - name: "Make sure all networks are removed"
- docker_network:
- name: "{{ item }}"
- state: absent
- force: yes
- with_items: "{{ dnetworks }}"
- when: docker_py_version is version('1.10.0', '>=')
- diff: no
-
- when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')
-
-- fail: msg="Too old docker / docker-py version to run all docker_container tests!"
- when: not(docker_py_version is version('3.5.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/test/integration/targets/docker_container/tasks/run-test.yml b/test/integration/targets/docker_container/tasks/run-test.yml
deleted file mode 100644
index a299937014..0000000000
--- a/test/integration/targets/docker_container/tasks/run-test.yml
+++ /dev/null
@@ -1,3 +0,0 @@
----
-- name: "Loading tasks from {{ item }}"
- include_tasks: "{{ item }}"
diff --git a/test/integration/targets/docker_container/tasks/tests/comparisons.yml b/test/integration/targets/docker_container/tasks/tests/comparisons.yml
deleted file mode 100644
index 8b7ae16bc6..0000000000
--- a/test/integration/targets/docker_container/tasks/tests/comparisons.yml
+++ /dev/null
@@ -1,463 +0,0 @@
----
-- name: Registering container name
- set_fact:
- cname: "{{ cname_prefix ~ '-comparisons' }}"
-- name: Registering container name
- set_fact:
- cnames: "{{ cnames + [cname] }}"
-
-####################################################################
-## value ###########################################################
-####################################################################
-
-- name: value
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- hostname: example.com
- register: value_1
-
-- name: value (change, ignore)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- hostname: example.org
- force_kill: yes
- comparisons:
- hostname: ignore
- register: value_2
-
-- name: value (change, strict)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- hostname: example.org
- force_kill: yes
- comparisons:
- hostname: strict
- register: value_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - value_1 is changed
- - value_2 is not changed
- - value_3 is changed
-
-####################################################################
-## list ############################################################
-####################################################################
-
-- name: list
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_servers:
- - 1.1.1.1
- - 8.8.8.8
- register: list_1
-
-- name: list (change, ignore)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_servers:
- - 9.9.9.9
- force_kill: yes
- comparisons:
- dns_servers: ignore
- register: list_2
-
-- name: list (change, strict)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_servers:
- - 9.9.9.9
- force_kill: yes
- comparisons:
- dns_servers: strict
- register: list_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - list_1 is changed
- - list_2 is not changed
- - list_3 is changed
-
-####################################################################
-## set #############################################################
-####################################################################
-
-- name: set
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- groups:
- - "1010"
- - "1011"
- register: set_1
-
-- name: set (change, ignore)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- groups:
- - "1010"
- - "1011"
- - "1012"
- force_kill: yes
- comparisons:
- groups: ignore
- register: set_2
-
-- name: set (change, allow_more_present)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- groups:
- - "1010"
- - "1011"
- - "1012"
- force_kill: yes
- comparisons:
- groups: allow_more_present
- register: set_3
-
-- name: set (change, allow_more_present)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- groups:
- - "1010"
- - "1012"
- force_kill: yes
- comparisons:
- groups: allow_more_present
- register: set_4
-
-- name: set (change, strict)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- groups:
- - "1010"
- - "1012"
- force_kill: yes
- comparisons:
- groups: strict
- register: set_5
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - set_1 is changed
- - set_2 is not changed
- - set_3 is changed
- - set_4 is not changed
- - set_5 is changed
-
-####################################################################
-## set(dict) #######################################################
-####################################################################
-
-- name: set(dict)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- devices:
- - "/dev/random:/dev/virt-random:rwm"
- - "/dev/urandom:/dev/virt-urandom:rwm"
- register: set_dict_1
-
-- name: set(dict) (change, ignore)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- devices:
- - "/dev/random:/dev/virt-random:rwm"
- - "/dev/urandom:/dev/virt-urandom:rwm"
- - "/dev/null:/dev/virt-null:rwm"
- force_kill: yes
- comparisons:
- devices: ignore
- register: set_dict_2
-
-- name: set(dict) (change, allow_more_present)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- devices:
- - "/dev/random:/dev/virt-random:rwm"
- - "/dev/urandom:/dev/virt-urandom:rwm"
- - "/dev/null:/dev/virt-null:rwm"
- force_kill: yes
- comparisons:
- devices: allow_more_present
- register: set_dict_3
-
-- name: set(dict) (change, allow_more_present)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- devices:
- - "/dev/random:/dev/virt-random:rwm"
- - "/dev/null:/dev/virt-null:rwm"
- force_kill: yes
- comparisons:
- devices: allow_more_present
- register: set_dict_4
-
-- name: set(dict) (change, strict)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- devices:
- - "/dev/random:/dev/virt-random:rwm"
- - "/dev/null:/dev/virt-null:rwm"
- force_kill: yes
- comparisons:
- devices: strict
- register: set_dict_5
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - set_dict_1 is changed
- - set_dict_2 is not changed
- - set_dict_3 is changed
- - set_dict_4 is not changed
- - set_dict_5 is changed
-
-####################################################################
-## dict ############################################################
-####################################################################
-
-- name: dict
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- labels:
- ansible.test.1: hello
- ansible.test.2: world
- register: dict_1
-
-- name: dict (change, ignore)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- labels:
- ansible.test.1: hello
- ansible.test.2: world
- ansible.test.3: ansible
- force_kill: yes
- comparisons:
- labels: ignore
- register: dict_2
-
-- name: dict (change, allow_more_present)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- labels:
- ansible.test.1: hello
- ansible.test.2: world
- ansible.test.3: ansible
- force_kill: yes
- comparisons:
- labels: allow_more_present
- register: dict_3
-
-- name: dict (change, allow_more_present)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- labels:
- ansible.test.1: hello
- ansible.test.3: ansible
- force_kill: yes
- comparisons:
- labels: allow_more_present
- register: dict_4
-
-- name: dict (change, strict)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- labels:
- ansible.test.1: hello
- ansible.test.3: ansible
- force_kill: yes
- comparisons:
- labels: strict
- register: dict_5
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - dict_1 is changed
- - dict_2 is not changed
- - dict_3 is changed
- - dict_4 is not changed
- - dict_5 is changed
-
-####################################################################
-## wildcard ########################################################
-####################################################################
-
-- name: Pull hello-world image to make sure wildcard_2 test succeeds
- # If the image isn't there, it will pull it and return 'changed'.
- docker_image:
- name: hello-world
- pull: true
-
-- name: wildcard
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- hostname: example.com
- stop_timeout: 1
- labels:
- ansible.test.1: hello
- ansible.test.2: world
- ansible.test.3: ansible
- register: wildcard_1
-
-- name: wildcard (change, ignore)
- docker_container:
- image: hello-world
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- hostname: example.org
- stop_timeout: 2
- labels:
- ansible.test.1: hello
- ansible.test.4: ignore
- force_kill: yes
- comparisons:
- '*': ignore
- register: wildcard_2
-
-- name: wildcard (change, strict)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- hostname: example.org
- stop_timeout: 1
- labels:
- ansible.test.1: hello
- ansible.test.2: world
- ansible.test.3: ansible
- force_kill: yes
- comparisons:
- '*': strict
- register: wildcard_3
-
-- name: wildcard (no change, strict)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- hostname: example.org
- stop_timeout: 1
- labels:
- ansible.test.1: hello
- ansible.test.2: world
- ansible.test.3: ansible
- force_kill: yes
- comparisons:
- '*': strict
- register: wildcard_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - wildcard_1 is changed
- - wildcard_2 is not changed
- - wildcard_3 is changed
- - wildcard_4 is not changed
diff --git a/test/integration/targets/docker_container/tasks/tests/compatibility.yml b/test/integration/targets/docker_container/tasks/tests/compatibility.yml
deleted file mode 100644
index fb537f42b3..0000000000
--- a/test/integration/targets/docker_container/tasks/tests/compatibility.yml
+++ /dev/null
@@ -1,118 +0,0 @@
----
-- name: Registering container name
- set_fact:
- cname: "{{ cname_prefix ~ '-hi' }}"
-- name: Registering container name
- set_fact:
- cnames: "{{ cnames + [cname] }}"
-
-####################################################################
-## container_default_behavior: compatibility #######################
-####################################################################
-
-- name: Start container (check)
- docker_container:
- name: "{{ cname }}"
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- state: started
- container_default_behavior: compatibility
- check_mode: yes
- register: start_1
-
-- name: Start container
- docker_container:
- name: "{{ cname }}"
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- state: started
- container_default_behavior: compatibility
- register: start_2
-
-- name: Start container (idempotent)
- docker_container:
- name: "{{ cname }}"
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- state: started
- container_default_behavior: compatibility
- register: start_3
-
-- name: Start container (idempotent check)
- docker_container:
- name: "{{ cname }}"
- image: alpine:3.8
- state: started
- container_default_behavior: compatibility
- check_mode: yes
- register: start_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - start_1 is changed
- - start_2 is changed
- - start_3 is not changed
- - start_4 is not changed
-
-####################################################################
-## container_default_behavior: no_defaults #########################
-####################################################################
-
-- name: Start container (check)
- docker_container:
- name: "{{ cname }}"
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- state: started
- container_default_behavior: no_defaults
- check_mode: yes
- register: start_1
-
-- name: Start container
- docker_container:
- name: "{{ cname }}"
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- state: started
- container_default_behavior: no_defaults
- register: start_2
-
-- name: Start container (idempotent)
- docker_container:
- name: "{{ cname }}"
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- state: started
- container_default_behavior: no_defaults
- register: start_3
-
-- name: Start container (idempotent check)
- docker_container:
- name: "{{ cname }}"
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- state: started
- container_default_behavior: no_defaults
- check_mode: yes
- register: start_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - start_1 is changed
- - start_2 is changed
- - start_3 is not changed
- - start_4 is not changed
diff --git a/test/integration/targets/docker_container/tasks/tests/image-ids.yml b/test/integration/targets/docker_container/tasks/tests/image-ids.yml
deleted file mode 100644
index f20f2998a3..0000000000
--- a/test/integration/targets/docker_container/tasks/tests/image-ids.yml
+++ /dev/null
@@ -1,146 +0,0 @@
----
-- name: Registering container name
- set_fact:
- cname: "{{ cname_prefix ~ '-iid' }}"
-- name: Registering container name
- set_fact:
- cnames: "{{ cnames + [cname] }}"
-
-- name: Pull images
- docker_image:
- name: "{{ image }}"
- source: pull
- loop:
- - "hello-world:latest"
- - "alpine:3.8"
- loop_control:
- loop_var: image
-
-- name: Get image ID of hello-world and alpine images
- docker_image_info:
- name:
- - "hello-world:latest"
- - "alpine:3.8"
- register: image_info
-
-- assert:
- that:
- - image_info.images | length == 2
-
-- name: Print image IDs
- debug:
- msg: "hello-world: {{ image_info.images[0].Id }}; alpine: {{ image_info.images[1].Id }}"
-
-- name: Create container with hello-world image via ID
- docker_container:
- image: "{{ image_info.images[0].Id }}"
- name: "{{ cname }}"
- state: present
- force_kill: yes
- register: create_1
-
-- name: Create container with hello-world image via ID (idempotent)
- docker_container:
- image: "{{ image_info.images[0].Id }}"
- name: "{{ cname }}"
- state: present
- force_kill: yes
- register: create_2
-
-- name: Create container with alpine image via ID
- docker_container:
- image: "{{ image_info.images[1].Id }}"
- name: "{{ cname }}"
- state: present
- force_kill: yes
- register: create_3
-
-- name: Create container with alpine image via ID (idempotent)
- docker_container:
- image: "{{ image_info.images[1].Id }}"
- name: "{{ cname }}"
- state: present
- force_kill: yes
- register: create_4
-
-- name: Untag image
- # Image will not be deleted since the container still uses it
- docker_image:
- name: alpine:3.8
- force_absent: yes
- state: absent
-
-- name: Create container with alpine image via name (check mode, will pull, same image)
- docker_container:
- image: alpine:3.8
- name: "{{ cname }}"
- state: present
- register: create_5
- check_mode: yes
-
-- name: Create container with alpine image via name (will pull, same image)
- docker_container:
- image: alpine:3.8
- name: "{{ cname }}"
- state: present
- register: create_6
-
-- name: Cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - create_1 is changed
- - create_2 is not changed
- - create_3 is changed
- - create_4 is not changed
- - create_5 is changed
- - create_6 is changed
- - create_6.container.Image == image_info.images[1].Id
- - create_6.container.Id == create_4.container.Id # make sure container wasn't recreated
-
-- name: set Digests
- set_fact:
- digest_hello_world_2016: 0256e8a36e2070f7bf2d0b0763dbabdd67798512411de4cdcf9431a1feb60fd9
- digest_hello_world_2019: 2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
-
-- name: Create container with hello-world image via old digest
- docker_container:
- image: "hello-world@sha256:{{ digest_hello_world_2016 }}"
- name: "{{ cname }}"
- state: present
- force_kill: yes
- register: digest_1
-
-- name: Create container with hello-world image via old digest (idempotent)
- docker_container:
- image: "hello-world@sha256:{{ digest_hello_world_2016 }}"
- name: "{{ cname }}"
- state: present
- force_kill: yes
- register: digest_2
-
-- name: Update container with hello-world image via new digest
- docker_container:
- image: "hello-world@sha256:{{ digest_hello_world_2019 }}"
- name: "{{ cname }}"
- state: present
- force_kill: yes
- register: digest_3
-
-- name: Cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - digest_1 is changed
- - digest_2 is not changed
- - digest_3 is changed
diff --git a/test/integration/targets/docker_container/tasks/tests/mounts-volumes.yml b/test/integration/targets/docker_container/tasks/tests/mounts-volumes.yml
deleted file mode 100644
index b744fcbe0b..0000000000
--- a/test/integration/targets/docker_container/tasks/tests/mounts-volumes.yml
+++ /dev/null
@@ -1,445 +0,0 @@
----
-- name: Registering container name
- set_fact:
- cname: "{{ cname_prefix ~ '-mounts' }}"
- cname_h1: "{{ cname_prefix ~ '-mounts-h1' }}"
- cname_h2: "{{ cname_prefix ~ '-mounts-h2' }}"
-- name: Registering container name
- set_fact:
- cnames: "{{ cnames + [cname, cname_h1, cname_h2] }}"
-
-####################################################################
-## keep_volumes ####################################################
-####################################################################
-
-# TODO: - keep_volumes
-
-####################################################################
-## mounts ##########################################################
-####################################################################
-
-- name: mounts
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- mounts:
- - source: /tmp
- target: /tmp
- type: bind
- - source: /
- target: /whatever
- type: bind
- read_only: no
- register: mounts_1
- ignore_errors: yes
-
-- name: mounts (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- mounts:
- - source: /
- target: /whatever
- type: bind
- read_only: no
- - source: /tmp
- target: /tmp
- type: bind
- register: mounts_2
- ignore_errors: yes
-
-- name: mounts (less mounts)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- mounts:
- - source: /tmp
- target: /tmp
- type: bind
- register: mounts_3
- ignore_errors: yes
-
-- name: mounts (more mounts)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- mounts:
- - source: /tmp
- target: /tmp
- type: bind
- - source: /tmp
- target: /somewhereelse
- type: bind
- read_only: yes
- force_kill: yes
- register: mounts_4
- ignore_errors: yes
-
-- name: mounts (different modes)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- mounts:
- - source: /tmp
- target: /tmp
- type: bind
- - source: /tmp
- target: /somewhereelse
- type: bind
- read_only: no
- force_kill: yes
- register: mounts_5
- ignore_errors: yes
-
-- name: mounts (endpoint collision)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- mounts:
- - source: /home
- target: /x
- type: bind
- - source: /etc
- target: /x
- type: bind
- read_only: no
- force_kill: yes
- register: mounts_6
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - mounts_1 is changed
- - mounts_2 is not changed
- - mounts_3 is not changed
- - mounts_4 is changed
- - mounts_5 is changed
- - mounts_6 is failed
- - "'The mount point \"/x\" appears twice in the mounts option' == mounts_6.msg"
- when: docker_py_version is version('2.6.0', '>=')
-- assert:
- that:
- - mounts_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in mounts_1.msg"
- - "'Minimum version required is 2.6.0 ' in mounts_1.msg"
- when: docker_py_version is version('2.6.0', '<')
-
-####################################################################
-## mounts + volumes ################################################
-####################################################################
-
-- name: mounts + volumes
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- mounts:
- - source: /
- target: /whatever
- type: bind
- read_only: yes
- volumes:
- - /tmp:/tmp
- register: mounts_volumes_1
- ignore_errors: yes
-
-- name: mounts + volumes (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- mounts:
- - source: /
- target: /whatever
- type: bind
- read_only: yes
- volumes:
- - /tmp:/tmp
- register: mounts_volumes_2
- ignore_errors: yes
-
-- name: mounts + volumes (switching)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- mounts:
- - source: /tmp
- target: /tmp
- type: bind
- read_only: no
- volumes:
- - /:/whatever:ro
- force_kill: yes
- register: mounts_volumes_3
- ignore_errors: yes
-
-- name: mounts + volumes (collision, should fail)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- mounts:
- - source: /tmp
- target: /tmp
- type: bind
- read_only: no
- volumes:
- - /tmp:/tmp
- force_kill: yes
- register: mounts_volumes_4
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - mounts_volumes_1 is changed
- - mounts_volumes_2 is not changed
- - mounts_volumes_3 is changed
- - mounts_volumes_4 is failed
- - "'The mount point \"/tmp\" appears both in the volumes and mounts option' in mounts_volumes_4.msg"
- when: docker_py_version is version('2.6.0', '>=')
-- assert:
- that:
- - mounts_volumes_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in mounts_1.msg"
- - "'Minimum version required is 2.6.0 ' in mounts_1.msg"
- when: docker_py_version is version('2.6.0', '<')
-
-####################################################################
-## volume_driver ###################################################
-####################################################################
-
-- name: volume_driver
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- volume_driver: local
- state: started
- register: volume_driver_1
-
-- name: volume_driver (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- volume_driver: local
- state: started
- register: volume_driver_2
-
-- name: volume_driver (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- volume_driver: /
- state: started
- force_kill: yes
- register: volume_driver_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - volume_driver_1 is changed
- - volume_driver_2 is not changed
- - volume_driver_3 is changed
-
-####################################################################
-## volumes #########################################################
-####################################################################
-
-- name: volumes
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- volumes:
- - "/tmp:/tmp"
- - "/:/whatever:rw,z"
- - "/anon:rw"
- register: volumes_1
-
-- name: volumes (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- volumes:
- - "/:/whatever:rw,z"
- - "/tmp:/tmp"
- - "/anon:rw"
- register: volumes_2
-
-- name: volumes (less volumes)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- volumes:
- - "/tmp:/tmp"
- register: volumes_3
-
-- name: volumes (more volumes)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- volumes:
- - "/tmp:/tmp"
- - "/tmp:/somewhereelse:ro,Z"
- force_kill: yes
- register: volumes_4
-
-- name: volumes (different modes)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- volumes:
- - "/tmp:/tmp"
- - "/tmp:/somewhereelse:ro"
- force_kill: yes
- register: volumes_5
-
-- name: volumes (collision)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- volumes:
- - "/etc:/tmp"
- - "/home:/tmp:ro"
- force_kill: yes
- register: volumes_6
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - volumes_1 is changed
- - volumes_1.container.Config.Volumes | length == 1
- - volumes_1.container.Config.Volumes['/anon:rw'] | length == 0
- - volumes_2 is not changed
- - volumes_3 is not changed
- - volumes_4 is changed
- - not volumes_4.container.Config.Volumes
- - volumes_5 is changed
- - volumes_6 is failed
- - "'The mount point \"/tmp\" appears twice in the volumes option' in volumes_6.msg"
-
-####################################################################
-## volumes_from ####################################################
-####################################################################
-
-- name: start helpers
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ container_name }}"
- state: started
- volumes:
- - "{{ '/tmp:/tmp' if container_name == cname_h1 else '/:/whatever:ro' }}"
- loop:
- - "{{ cname_h1 }}"
- - "{{ cname_h2 }}"
- loop_control:
- loop_var: container_name
-
-- name: volumes_from
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- volumes_from: "{{ cname_h1 }}"
- register: volumes_from_1
-
-- name: volumes_from (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- volumes_from: "{{ cname_h1 }}"
- register: volumes_from_2
-
-- name: volumes_from (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- volumes_from: "{{ cname_h2 }}"
- force_kill: yes
- register: volumes_from_3
-
-- name: cleanup
- docker_container:
- name: "{{ container_name }}"
- state: absent
- force_kill: yes
- loop:
- - "{{ cname }}"
- - "{{ cname_h1 }}"
- - "{{ cname_h2 }}"
- loop_control:
- loop_var: container_name
- diff: no
-
-- assert:
- that:
- - volumes_from_1 is changed
- - volumes_from_2 is not changed
- - volumes_from_3 is changed
-
-####################################################################
-####################################################################
-####################################################################
diff --git a/test/integration/targets/docker_container/tasks/tests/network.yml b/test/integration/targets/docker_container/tasks/tests/network.yml
deleted file mode 100644
index 80c05ba5e9..0000000000
--- a/test/integration/targets/docker_container/tasks/tests/network.yml
+++ /dev/null
@@ -1,736 +0,0 @@
----
-- name: Registering container name
- set_fact:
- cname: "{{ cname_prefix ~ '-network' }}"
- cname_h1: "{{ cname_prefix ~ '-network-h1' }}"
- nname_1: "{{ cname_prefix ~ '-network-1' }}"
- nname_2: "{{ cname_prefix ~ '-network-2' }}"
- nname_3: "{{ cname_prefix ~ '-network-3' }}"
-- name: Registering container name
- set_fact:
- cnames: "{{ cnames + [cname, cname_h1] }}"
- dnetworks: "{{ dnetworks + [nname_1, nname_2, nname_3] }}"
-
-- name: Create networks
- docker_network:
- name: "{{ network_name }}"
- state: present
- loop:
- - "{{ nname_1 }}"
- - "{{ nname_2 }}"
- loop_control:
- loop_var: network_name
- when: docker_py_version is version('1.10.0', '>=')
-
-- set_fact:
- subnet_ipv4: "192.168.{{ 64 + (192 | random) }}.0/24"
- subnet_ipv6: "fdb6:feea:{{ '%0.4x:%0.4x' | format(65536 | random, 65536 | random) }}::/64"
-
-- set_fact:
- # If netaddr would be installed on the controller, one could do:
- nname_3_ipv4_2: "{{ subnet_ipv4 | next_nth_usable(2) }}"
- nname_3_ipv4_3: "{{ subnet_ipv4 | next_nth_usable(3) }}"
- nname_3_ipv4_4: "{{ subnet_ipv4 | next_nth_usable(4) }}"
- nname_3_ipv6_2: "{{ subnet_ipv6 | next_nth_usable(2) }}"
- nname_3_ipv6_3: "{{ subnet_ipv6 | next_nth_usable(3) }}"
- nname_3_ipv6_4: "{{ subnet_ipv6 | next_nth_usable(4) }}"
-
-- debug:
- msg: "Chose random IPv4 subnet {{ subnet_ipv4 }} and random IPv6 subnet {{ subnet_ipv6 }}"
-
-- name: Create network with fixed IPv4 and IPv6 subnets
- docker_network:
- name: "{{ nname_3 }}"
- enable_ipv6: yes
- ipam_config:
- - subnet: "{{ subnet_ipv4 }}"
- - subnet: "{{ subnet_ipv6 }}"
- state: present
- when: docker_py_version is version('1.10.0', '>=')
-
-####################################################################
-## network_mode ####################################################
-####################################################################
-
-- name: network_mode
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- network_mode: host
- register: network_mode_1
-
-- name: network_mode (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- network_mode: host
- register: network_mode_2
-
-- name: network_mode (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- network_mode: none
- force_kill: yes
- register: network_mode_3
-
-- name: network_mode (container mode setup)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname_h1 }}"
- state: started
- register: cname_h1_id
-
-- name: network_mode (container mode)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- network_mode: "container:{{ cname_h1_id.container.Id }}"
- force_kill: yes
- register: network_mode_4
-
-- name: network_mode (container mode idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- network_mode: "container:{{ cname_h1 }}"
- register: network_mode_5
-
-- name: cleanup
- docker_container:
- name: "{{ container_name }}"
- state: absent
- force_kill: yes
- loop:
- - "{{ cname }}"
- - "{{ cname_h1 }}"
- loop_control:
- loop_var: container_name
- diff: no
-
-- assert:
- that:
- - network_mode_1 is changed
- - network_mode_1.container.HostConfig.NetworkMode == 'host'
- - network_mode_2 is not changed
- - network_mode_2.container.HostConfig.NetworkMode == 'host'
- - network_mode_3 is changed
- - network_mode_3.container.HostConfig.NetworkMode == 'none'
- - network_mode_4 is changed
- - network_mode_4.container.HostConfig.NetworkMode == 'container:' ~ cname_h1_id.container.Id
- - network_mode_5 is not changed
- - network_mode_5.container.HostConfig.NetworkMode == 'container:' ~ cname_h1_id.container.Id
-
-####################################################################
-## networks, purge_networks for networks_cli_compatible=no #########
-####################################################################
-
-- block:
- - name: networks_cli_compatible=no, networks w/o purge_networks
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks:
- - name: "{{ nname_1 }}"
- - name: "{{ nname_2 }}"
- networks_cli_compatible: no
- register: networks_1
-
- - name: networks_cli_compatible=no, networks w/o purge_networks
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks:
- - name: "{{ nname_1 }}"
- - name: "{{ nname_2 }}"
- networks_cli_compatible: no
- register: networks_2
-
- - name: networks_cli_compatible=no, networks, purge_networks
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- purge_networks: yes
- networks:
- - name: bridge
- - name: "{{ nname_1 }}"
- networks_cli_compatible: no
- force_kill: yes
- register: networks_3
-
- - name: networks_cli_compatible=no, networks, purge_networks (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- purge_networks: yes
- networks:
- - name: "{{ nname_1 }}"
- - name: bridge
- networks_cli_compatible: no
- register: networks_4
-
- - name: networks_cli_compatible=no, networks (less networks)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks:
- - name: bridge
- networks_cli_compatible: no
- register: networks_5
-
- - name: networks_cli_compatible=no, networks, purge_networks (less networks)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- purge_networks: yes
- networks:
- - name: bridge
- networks_cli_compatible: no
- force_kill: yes
- register: networks_6
-
- - name: networks_cli_compatible=no, networks, purge_networks (more networks)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- purge_networks: yes
- networks:
- - name: bridge
- - name: "{{ nname_2 }}"
- networks_cli_compatible: no
- force_kill: yes
- register: networks_7
-
- - name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
- - assert:
- that:
- # networks_1 has networks default, 'bridge', nname_1
- - networks_1 is changed
- - networks_1.container.NetworkSettings.Networks | length == 3
- - nname_1 in networks_1.container.NetworkSettings.Networks
- - nname_2 in networks_1.container.NetworkSettings.Networks
- - "'default' in networks_1.container.NetworkSettings.Networks or 'bridge' in networks_1.container.NetworkSettings.Networks"
- # networks_2 has networks default, 'bridge', nname_1
- - networks_2 is not changed
- - networks_2.container.NetworkSettings.Networks | length == 3
- - nname_1 in networks_2.container.NetworkSettings.Networks
- - nname_2 in networks_1.container.NetworkSettings.Networks
- - "'default' in networks_1.container.NetworkSettings.Networks or 'bridge' in networks_1.container.NetworkSettings.Networks"
- # networks_3 has networks 'bridge', nname_1
- - networks_3 is changed
- - networks_3.container.NetworkSettings.Networks | length == 2
- - nname_1 in networks_3.container.NetworkSettings.Networks
- - "'default' in networks_3.container.NetworkSettings.Networks or 'bridge' in networks_3.container.NetworkSettings.Networks"
- # networks_4 has networks 'bridge', nname_1
- - networks_4 is not changed
- - networks_4.container.NetworkSettings.Networks | length == 2
- - nname_1 in networks_4.container.NetworkSettings.Networks
- - "'default' in networks_4.container.NetworkSettings.Networks or 'bridge' in networks_4.container.NetworkSettings.Networks"
- # networks_5 has networks 'bridge', nname_1
- - networks_5 is not changed
- - networks_5.container.NetworkSettings.Networks | length == 2
- - nname_1 in networks_5.container.NetworkSettings.Networks
- - "'default' in networks_5.container.NetworkSettings.Networks or 'bridge' in networks_5.container.NetworkSettings.Networks"
- # networks_6 has networks 'bridge'
- - networks_6 is changed
- - networks_6.container.NetworkSettings.Networks | length == 1
- - "'default' in networks_6.container.NetworkSettings.Networks or 'bridge' in networks_6.container.NetworkSettings.Networks"
- # networks_7 has networks 'bridge', nname_2
- - networks_7 is changed
- - networks_7.container.NetworkSettings.Networks | length == 2
- - nname_2 in networks_7.container.NetworkSettings.Networks
- - "'default' in networks_7.container.NetworkSettings.Networks or 'bridge' in networks_7.container.NetworkSettings.Networks"
-
- when: docker_py_version is version('1.10.0', '>=')
-
-####################################################################
-## networks for networks_cli_compatible=yes ########################
-####################################################################
-
-- block:
- - name: networks_cli_compatible=yes, networks specified
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks:
- - name: "{{ nname_1 }}"
- aliases:
- - alias1
- - alias2
- - name: "{{ nname_2 }}"
- networks_cli_compatible: yes
- register: networks_1
-
- - name: networks_cli_compatible=yes, networks specified
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks:
- - name: "{{ nname_1 }}"
- - name: "{{ nname_2 }}"
- networks_cli_compatible: yes
- register: networks_2
-
- - name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
- - name: networks_cli_compatible=yes, empty networks list specified
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks: []
- networks_cli_compatible: yes
- register: networks_3
-
- - name: networks_cli_compatible=yes, empty networks list specified
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks: []
- networks_cli_compatible: yes
- register: networks_4
-
- - name: networks_cli_compatible=yes, empty networks list specified, purge_networks
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks: []
- networks_cli_compatible: yes
- purge_networks: yes
- force_kill: yes
- register: networks_5
-
- - name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
- - name: networks_cli_compatible=yes, networks not specified
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks_cli_compatible: yes
- force_kill: yes
- register: networks_6
-
- - name: networks_cli_compatible=yes, networks not specified
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks_cli_compatible: yes
- register: networks_7
-
- - name: networks_cli_compatible=yes, networks not specified, purge_networks
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks_cli_compatible: yes
- purge_networks: yes
- force_kill: yes
- register: networks_8
-
- - name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
- - debug: var=networks_3
-
- - assert:
- that:
- # networks_1 has networks nname_1, nname_2
- - networks_1 is changed
- - networks_1.container.NetworkSettings.Networks | length == 2
- - nname_1 in networks_1.container.NetworkSettings.Networks
- - nname_2 in networks_1.container.NetworkSettings.Networks
- # networks_2 has networks nname_1, nname_2
- - networks_2 is not changed
- - networks_2.container.NetworkSettings.Networks | length == 2
- - nname_1 in networks_2.container.NetworkSettings.Networks
- - nname_2 in networks_1.container.NetworkSettings.Networks
- # networks_3 has networks 'bridge'
- - networks_3 is changed
- - networks_3.container.NetworkSettings.Networks | length == 1
- - "'default' in networks_3.container.NetworkSettings.Networks or 'bridge' in networks_3.container.NetworkSettings.Networks"
- # networks_4 has networks 'bridge'
- - networks_4 is not changed
- - networks_4.container.NetworkSettings.Networks | length == 1
- - "'default' in networks_4.container.NetworkSettings.Networks or 'bridge' in networks_4.container.NetworkSettings.Networks"
- # networks_5 has no networks
- - networks_5 is changed
- - networks_5.container.NetworkSettings.Networks | length == 0
- # networks_6 has networks 'bridge'
- - networks_6 is changed
- - networks_6.container.NetworkSettings.Networks | length == 1
- - "'default' in networks_6.container.NetworkSettings.Networks or 'bridge' in networks_6.container.NetworkSettings.Networks"
- # networks_7 has networks 'bridge'
- - networks_7 is not changed
- - networks_7.container.NetworkSettings.Networks | length == 1
- - "'default' in networks_7.container.NetworkSettings.Networks or 'bridge' in networks_7.container.NetworkSettings.Networks"
- # networks_8 has no networks
- - networks_8 is changed
- - networks_8.container.NetworkSettings.Networks | length == 0
-
- when: docker_py_version is version('1.10.0', '>=')
-
-####################################################################
-## networks with comparisons #######################################
-####################################################################
-
-- block:
- - name: create container with one network
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks:
- - name: "{{ nname_1 }}"
- networks_cli_compatible: yes
- register: networks_1
-
- - name: different networks, comparisons=ignore
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks:
- - name: "{{ nname_2 }}"
- networks_cli_compatible: yes
- comparisons:
- networks: ignore
- register: networks_2
-
- - name: less networks, comparisons=ignore
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks: []
- networks_cli_compatible: yes
- comparisons:
- networks: ignore
- register: networks_3
-
- - name: less networks, comparisons=allow_more_present
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks: []
- networks_cli_compatible: yes
- comparisons:
- networks: allow_more_present
- register: networks_4
-
- - name: different networks, comparisons=allow_more_present
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks:
- - name: "{{ nname_2 }}"
- networks_cli_compatible: yes
- comparisons:
- networks: allow_more_present
- force_kill: yes
- register: networks_5
-
- - name: different networks, comparisons=strict
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks:
- - name: "{{ nname_2 }}"
- networks_cli_compatible: yes
- comparisons:
- networks: strict
- force_kill: yes
- register: networks_6
-
- - name: less networks, comparisons=strict
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks: []
- networks_cli_compatible: yes
- comparisons:
- networks: strict
- force_kill: yes
- register: networks_7
-
- - name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
- - assert:
- that:
- # networks_1 has networks nname_1
- - networks_1 is changed
- - networks_1.container.NetworkSettings.Networks | length == 1
- - nname_1 in networks_1.container.NetworkSettings.Networks
- # networks_2 has networks nname_1
- - networks_2 is not changed
- - networks_2.container.NetworkSettings.Networks | length == 1
- - nname_1 in networks_2.container.NetworkSettings.Networks
- # networks_3 has networks nname_1
- - networks_3 is not changed
- - networks_3.container.NetworkSettings.Networks | length == 1
- - nname_1 in networks_3.container.NetworkSettings.Networks
- # networks_4 has networks nname_1
- - networks_4 is not changed
- - networks_4.container.NetworkSettings.Networks | length == 1
- - nname_1 in networks_4.container.NetworkSettings.Networks
- # networks_5 has networks nname_1, nname_2
- - networks_5 is changed
- - networks_5.container.NetworkSettings.Networks | length == 2
- - nname_1 in networks_5.container.NetworkSettings.Networks
- - nname_2 in networks_5.container.NetworkSettings.Networks
- # networks_6 has networks nname_2
- - networks_6 is changed
- - networks_6.container.NetworkSettings.Networks | length == 1
- - nname_2 in networks_6.container.NetworkSettings.Networks
- # networks_7 has no networks
- - networks_7 is changed
- - networks_7.container.NetworkSettings.Networks | length == 0
-
- when: docker_py_version is version('1.10.0', '>=')
-
-####################################################################
-## networks with IP address ########################################
-####################################################################
-
-- block:
- - name: create container (stopped) with one network and fixed IP
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: stopped
- networks:
- - name: "{{ nname_3 }}"
- ipv4_address: "{{ nname_3_ipv4_2 }}"
- ipv6_address: "{{ nname_3_ipv6_2 }}"
- networks_cli_compatible: yes
- register: networks_1
-
- - name: create container (stopped) with one network and fixed IP (idempotent)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: stopped
- networks:
- - name: "{{ nname_3 }}"
- ipv4_address: "{{ nname_3_ipv4_2 }}"
- ipv6_address: "{{ nname_3_ipv6_2 }}"
- networks_cli_compatible: yes
- register: networks_2
-
- - name: create container (stopped) with one network and fixed IP (different IPv4)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: stopped
- networks:
- - name: "{{ nname_3 }}"
- ipv4_address: "{{ nname_3_ipv4_3 }}"
- ipv6_address: "{{ nname_3_ipv6_2 }}"
- networks_cli_compatible: yes
- register: networks_3
-
- - name: create container (stopped) with one network and fixed IP (different IPv6)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: stopped
- networks:
- - name: "{{ nname_3 }}"
- ipv4_address: "{{ nname_3_ipv4_3 }}"
- ipv6_address: "{{ nname_3_ipv6_3 }}"
- networks_cli_compatible: yes
- register: networks_4
-
- - name: create container (started) with one network and fixed IP
- docker_container:
- name: "{{ cname }}"
- state: started
- register: networks_5
-
- - name: create container (started) with one network and fixed IP (different IPv4)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks:
- - name: "{{ nname_3 }}"
- ipv4_address: "{{ nname_3_ipv4_4 }}"
- ipv6_address: "{{ nname_3_ipv6_3 }}"
- networks_cli_compatible: yes
- force_kill: yes
- register: networks_6
-
- - name: create container (started) with one network and fixed IP (different IPv6)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks:
- - name: "{{ nname_3 }}"
- ipv4_address: "{{ nname_3_ipv4_4 }}"
- ipv6_address: "{{ nname_3_ipv6_4 }}"
- networks_cli_compatible: yes
- force_kill: yes
- register: networks_7
-
- - name: create container (started) with one network and fixed IP (idempotent)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- networks:
- - name: "{{ nname_3 }}"
- ipv4_address: "{{ nname_3_ipv4_4 }}"
- ipv6_address: "{{ nname_3_ipv6_4 }}"
- networks_cli_compatible: yes
- register: networks_8
-
- - name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
- - assert:
- that:
- - networks_1 is changed
- - networks_1.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_2
- - networks_1.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | ipaddr == nname_3_ipv6_2 | ipaddr
- - networks_1.container.NetworkSettings.Networks[nname_3].IPAddress == ""
- - networks_1.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address == ""
- - networks_2 is not changed
- - networks_2.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_2
- - networks_2.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | ipaddr == nname_3_ipv6_2 | ipaddr
- - networks_2.container.NetworkSettings.Networks[nname_3].IPAddress == ""
- - networks_2.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address == ""
- - networks_3 is changed
- - networks_3.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_3
- - networks_3.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | ipaddr == nname_3_ipv6_2 | ipaddr
- - networks_3.container.NetworkSettings.Networks[nname_3].IPAddress == ""
- - networks_3.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address == ""
- - networks_4 is changed
- - networks_4.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_3
- - networks_4.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | ipaddr == nname_3_ipv6_3 | ipaddr
- - networks_4.container.NetworkSettings.Networks[nname_3].IPAddress == ""
- - networks_4.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address == ""
- - networks_5 is changed
- - networks_5.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_3
- - networks_5.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | ipaddr == nname_3_ipv6_3 | ipaddr
- - networks_5.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_3
- - networks_5.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | ipaddr == nname_3_ipv6_3 | ipaddr
- - networks_6 is changed
- - networks_6.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_4
- - networks_6.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | ipaddr == nname_3_ipv6_3 | ipaddr
- - networks_6.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_4
- - networks_6.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | ipaddr == nname_3_ipv6_3 | ipaddr
- - networks_7 is changed
- - networks_7.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_4
- - networks_7.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | ipaddr == nname_3_ipv6_4 | ipaddr
- - networks_7.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_4
- - networks_7.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | ipaddr == nname_3_ipv6_4 | ipaddr
- - networks_8 is not changed
- - networks_8.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv4Address == nname_3_ipv4_4
- - networks_8.container.NetworkSettings.Networks[nname_3].IPAMConfig.IPv6Address | ipaddr == nname_3_ipv6_4 | ipaddr
- - networks_8.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_4
- - networks_8.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | ipaddr == nname_3_ipv6_4 | ipaddr
-
- when: docker_py_version is version('1.10.0', '>=')
-
-####################################################################
-####################################################################
-####################################################################
-
-- name: Delete networks
- docker_network:
- name: "{{ network_name }}"
- state: absent
- force: yes
- loop:
- - "{{ nname_1 }}"
- - "{{ nname_2 }}"
- - "{{ nname_3 }}"
- loop_control:
- loop_var: network_name
- when: docker_py_version is version('1.10.0', '>=')
diff --git a/test/integration/targets/docker_container/tasks/tests/options.yml b/test/integration/targets/docker_container/tasks/tests/options.yml
deleted file mode 100644
index 5cced99584..0000000000
--- a/test/integration/targets/docker_container/tasks/tests/options.yml
+++ /dev/null
@@ -1,3745 +0,0 @@
----
-- name: Registering container name
- set_fact:
- cname: "{{ cname_prefix ~ '-options' }}"
- cname_h1: "{{ cname_prefix ~ '-options-h1' }}"
- cname_h2: "{{ cname_prefix ~ '-options-h2' }}"
- cname_h3: "{{ cname_prefix ~ '-options-h3' }}"
-- name: Registering container name
- set_fact:
- cnames: "{{ cnames + [cname, cname_h1, cname_h2, cname_h3] }}"
-
-####################################################################
-## auto_remove #####################################################
-####################################################################
-
-- name: auto_remove
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "echo"'
- name: "{{ cname }}"
- state: started
- auto_remove: yes
- register: auto_remove_1
- ignore_errors: yes
-
-- name: Give container 1 second to be sure it terminated
- pause:
- seconds: 1
-
-- name: auto_remove (verify)
- docker_container:
- name: "{{ cname }}"
- state: absent
- register: auto_remove_2
- ignore_errors: yes
-
-- assert:
- that:
- - auto_remove_1 is changed
- - auto_remove_2 is not changed
- when: docker_py_version is version('2.1.0', '>=')
-- assert:
- that:
- - auto_remove_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in auto_remove_1.msg"
- - "'Minimum version required is 2.1.0 ' in auto_remove_1.msg"
- when: docker_py_version is version('2.1.0', '<')
-
-####################################################################
-## blkio_weight ####################################################
-####################################################################
-
-- name: blkio_weight
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- blkio_weight: 123
- register: blkio_weight_1
-
-- name: blkio_weight (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- blkio_weight: 123
- register: blkio_weight_2
-
-- name: blkio_weight (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- blkio_weight: 234
- force_kill: yes
- register: blkio_weight_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - blkio_weight_1 is changed
- - "blkio_weight_2 is not changed or 'Docker warning: Your kernel does not support Block I/O weight or the cgroup is not mounted. Weight discarded.' in blkio_weight_2.warnings"
- - blkio_weight_3 is changed
-
-####################################################################
-## cap_drop, capabilities ##########################################
-####################################################################
-
-- name: capabilities, cap_drop
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- capabilities:
- - sys_time
- cap_drop:
- - all
- register: capabilities_1
-
-- name: capabilities, cap_drop (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- capabilities:
- - sys_time
- cap_drop:
- - all
- register: capabilities_2
-
-- name: capabilities, cap_drop (less)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- capabilities: []
- cap_drop:
- - all
- register: capabilities_3
-
-- name: capabilities, cap_drop (changed)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- capabilities:
- - setgid
- cap_drop:
- - all
- force_kill: yes
- register: capabilities_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - capabilities_1 is changed
- - capabilities_2 is not changed
- - capabilities_3 is not changed
- - capabilities_4 is changed
-
-####################################################################
-## command #########################################################
-####################################################################
-
-- name: command
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -v -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- register: command_1
-
-- name: command (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -v -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- register: command_2
-
-- name: command (less parameters)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- force_kill: yes
- register: command_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - command_1 is changed
- - command_2 is not changed
- - command_3 is changed
-
-####################################################################
-## cpu_period ######################################################
-####################################################################
-
-- name: cpu_period
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpu_period: 90000
- state: started
- register: cpu_period_1
-
-- name: cpu_period (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpu_period: 90000
- state: started
- register: cpu_period_2
-
-- name: cpu_period (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpu_period: 50000
- state: started
- force_kill: yes
- register: cpu_period_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - cpu_period_1 is changed
- - cpu_period_2 is not changed
- - cpu_period_3 is changed
-
-####################################################################
-## cpu_quota #######################################################
-####################################################################
-
-- name: cpu_quota
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpu_quota: 150000
- state: started
- register: cpu_quota_1
-
-- name: cpu_quota (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpu_quota: 150000
- state: started
- register: cpu_quota_2
-
-- name: cpu_quota (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpu_quota: 50000
- state: started
- force_kill: yes
- register: cpu_quota_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - cpu_quota_1 is changed
- - cpu_quota_2 is not changed
- - cpu_quota_3 is changed
-
-####################################################################
-## cpu_shares ######################################################
-####################################################################
-
-- name: cpu_shares
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpu_shares: 900
- state: started
- register: cpu_shares_1
-
-- name: cpu_shares (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpu_shares: 900
- state: started
- register: cpu_shares_2
-
-- name: cpu_shares (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpu_shares: 1100
- state: started
- force_kill: yes
- register: cpu_shares_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - cpu_shares_1 is changed
- - cpu_shares_2 is not changed
- - cpu_shares_3 is changed
-
-####################################################################
-## cpuset_cpus #####################################################
-####################################################################
-
-- name: cpuset_cpus
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpuset_cpus: "0"
- state: started
- register: cpuset_cpus_1
-
-- name: cpuset_cpus (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpuset_cpus: "0"
- state: started
- register: cpuset_cpus_2
-
-- name: cpuset_cpus (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpuset_cpus: "1"
- state: started
- force_kill: yes
- # This will fail if the system the test is run on doesn't have
- # multiple CPUs/cores available.
- ignore_errors: yes
- register: cpuset_cpus_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - cpuset_cpus_1 is changed
- - cpuset_cpus_2 is not changed
- - cpuset_cpus_3 is failed or cpuset_cpus_3 is changed
-
-####################################################################
-## cpuset_mems #####################################################
-####################################################################
-
-- name: cpuset_mems
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpuset_mems: "0"
- state: started
- register: cpuset_mems_1
-
-- name: cpuset_mems (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpuset_mems: "0"
- state: started
- register: cpuset_mems_2
-
-- name: cpuset_mems (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpuset_mems: "1"
- state: started
- force_kill: yes
- # This will fail if the system the test is run on doesn't have
- # multiple MEMs available.
- ignore_errors: yes
- register: cpuset_mems_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - cpuset_mems_1 is changed
- - cpuset_mems_2 is not changed
- - cpuset_mems_3 is failed or cpuset_mems_3 is changed
-
-####################################################################
-## cpus ############################################################
-####################################################################
-
-- name: cpus
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpus: 1
- state: started
- ignore_errors: yes
- register: cpus_1
-
-- name: cpus (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpus: 1
- state: started
- ignore_errors: yes
- register: cpus_2
-
-- name: cpus (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- cpus: 1.5
- state: started
- force_kill: yes
- # This will fail if the system the test is run on doesn't have
- # multiple MEMs available.
- ignore_errors: yes
- register: cpus_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - cpus_1 is changed
- - cpus_2 is not changed and cpus_2 is not failed
- - cpus_3 is failed or cpus_3 is changed
- when: docker_py_version is version('2.3.0', '>=')
-- assert:
- that:
- - cpus_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in cpus_1.msg"
- - "'Minimum version required is 2.3.0 ' in cpus_1.msg"
- when: docker_py_version is version('2.3.0', '<')
-
-####################################################################
-## debug ###########################################################
-####################################################################
-
-- name: debug (create)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: present
- debug: yes
- register: debug_1
-
-- name: debug (start)
- docker_container:
- name: "{{ cname }}"
- state: started
- debug: yes
- register: debug_2
-
-- name: debug (stop)
- docker_container:
- image: alpine:3.8
- name: "{{ cname }}"
- state: stopped
- force_kill: yes
- debug: yes
- register: debug_3
-
-- name: debug (absent)
- docker_container:
- name: "{{ cname }}"
- state: absent
- debug: yes
- force_kill: yes
- register: debug_4
-
-- assert:
- that:
- - debug_1 is changed
- - debug_2 is changed
- - debug_3 is changed
- - debug_4 is changed
-
-####################################################################
-## detach, cleanup #################################################
-####################################################################
-
-- name: detach without cleanup
- docker_container:
- name: "{{ cname }}"
- image: hello-world
- detach: no
- register: detach_no_cleanup
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- register: detach_no_cleanup_cleanup
- diff: no
-
-- name: detach with cleanup
- docker_container:
- name: "{{ cname }}"
- image: hello-world
- detach: no
- cleanup: yes
- register: detach_cleanup
-
-- name: cleanup (unnecessary)
- docker_container:
- name: "{{ cname }}"
- state: absent
- register: detach_cleanup_cleanup
- diff: no
-
-- name: detach with auto_remove and cleanup
- docker_container:
- name: "{{ cname }}"
- image: hello-world
- detach: no
- auto_remove: yes
- cleanup: yes
- register: detach_auto_remove
- ignore_errors: yes
-
-- name: cleanup (unnecessary)
- docker_container:
- name: "{{ cname }}"
- state: absent
- register: detach_auto_remove_cleanup
- diff: no
-
-- assert:
- that:
- # NOTE that 'Output' sometimes fails to contain the correct output
- # of hello-world. We don't know why this happens, but it happens
- # often enough to be annoying. That's why we disable this for now,
- # and simply test that 'Output' is contained in the result.
- - "'Output' in detach_no_cleanup.container"
- # - "'Hello from Docker!' in detach_no_cleanup.container.Output"
- - detach_no_cleanup_cleanup is changed
- - "'Output' in detach_cleanup.container"
- # - "'Hello from Docker!' in detach_cleanup.container.Output"
- - detach_cleanup_cleanup is not changed
-- assert:
- that:
- - "'Cannot retrieve result as auto_remove is enabled' == detach_auto_remove.container.Output"
- - detach_auto_remove_cleanup is not changed
- when: docker_py_version is version('2.1.0', '>=')
-
-####################################################################
-## devices #########################################################
-####################################################################
-
-- name: devices
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- devices:
- - "/dev/random:/dev/virt-random:rwm"
- - "/dev/urandom:/dev/virt-urandom:rwm"
- register: devices_1
-
-- name: devices (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- devices:
- - "/dev/urandom:/dev/virt-urandom:rwm"
- - "/dev/random:/dev/virt-random:rwm"
- register: devices_2
-
-- name: devices (less)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- devices:
- - "/dev/random:/dev/virt-random:rwm"
- register: devices_3
-
-- name: devices (changed)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- devices:
- - "/dev/random:/dev/virt-random:rwm"
- - "/dev/null:/dev/virt-null:rwm"
- force_kill: yes
- register: devices_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - devices_1 is changed
- - devices_2 is not changed
- - devices_3 is not changed
- - devices_4 is changed
-
-####################################################################
-## device_read_bps #################################################
-####################################################################
-
-- name: device_read_bps
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- device_read_bps:
- - path: /dev/random
- rate: 20M
- - path: /dev/urandom
- rate: 10K
- register: device_read_bps_1
- ignore_errors: yes
-
-- name: device_read_bps (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- device_read_bps:
- - path: /dev/urandom
- rate: 10K
- - path: /dev/random
- rate: 20M
- register: device_read_bps_2
- ignore_errors: yes
-
-- name: device_read_bps (lesser entries)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- device_read_bps:
- - path: /dev/random
- rate: 20M
- register: device_read_bps_3
- ignore_errors: yes
-
-- name: device_read_bps (changed)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- device_read_bps:
- - path: /dev/random
- rate: 10M
- - path: /dev/urandom
- rate: 5K
- force_kill: yes
- register: device_read_bps_4
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - device_read_bps_1 is changed
- - device_read_bps_2 is not changed
- - device_read_bps_3 is not changed
- - device_read_bps_4 is changed
- when: docker_py_version is version('1.9.0', '>=')
-- assert:
- that:
- - device_read_bps_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in device_read_bps_1.msg"
- - "'Minimum version required is 1.9.0 ' in device_read_bps_1.msg"
- when: docker_py_version is version('1.9.0', '<')
-
-####################################################################
-## device_read_iops ################################################
-####################################################################
-
-- name: device_read_iops
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- device_read_iops:
- - path: /dev/random
- rate: 10
- - path: /dev/urandom
- rate: 20
- register: device_read_iops_1
- ignore_errors: yes
-
-- name: device_read_iops (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- device_read_iops:
- - path: /dev/urandom
- rate: "20"
- - path: /dev/random
- rate: 10
- register: device_read_iops_2
- ignore_errors: yes
-
-- name: device_read_iops (less)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- device_read_iops:
- - path: /dev/random
- rate: 10
- register: device_read_iops_3
- ignore_errors: yes
-
-- name: device_read_iops (changed)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- device_read_iops:
- - path: /dev/random
- rate: 30
- - path: /dev/urandom
- rate: 50
- force_kill: yes
- register: device_read_iops_4
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - device_read_iops_1 is changed
- - device_read_iops_2 is not changed
- - device_read_iops_3 is not changed
- - device_read_iops_4 is changed
- when: docker_py_version is version('1.9.0', '>=')
-- assert:
- that:
- - device_read_iops_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in device_read_iops_1.msg"
- - "'Minimum version required is 1.9.0 ' in device_read_iops_1.msg"
- when: docker_py_version is version('1.9.0', '<')
-
-####################################################################
-## device_write_bps and device_write_iops ##########################
-####################################################################
-
-- name: device_write_bps and device_write_iops
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- device_write_bps:
- - path: /dev/random
- rate: 10M
- device_write_iops:
- - path: /dev/urandom
- rate: 30
- register: device_write_limit_1
- ignore_errors: yes
-
-- name: device_write_bps and device_write_iops (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- device_write_bps:
- - path: /dev/random
- rate: 10M
- device_write_iops:
- - path: /dev/urandom
- rate: 30
- register: device_write_limit_2
- ignore_errors: yes
-
-- name: device_write_bps device_write_iops (changed)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- device_write_bps:
- - path: /dev/random
- rate: 20K
- device_write_iops:
- - path: /dev/urandom
- rate: 100
- force_kill: yes
- register: device_write_limit_3
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - device_write_limit_1 is changed
- - device_write_limit_2 is not changed
- - device_write_limit_3 is changed
- when: docker_py_version is version('1.9.0', '>=')
-- assert:
- that:
- - device_write_limit_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in device_write_limit_1.msg"
- - "'Minimum version required is 1.9.0 ' in device_write_limit_1.msg"
- when: docker_py_version is version('1.9.0', '<')
-
-####################################################################
-## dns_opts ########################################################
-####################################################################
-
-- name: dns_opts
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_opts:
- - "timeout:10"
- - rotate
- register: dns_opts_1
- ignore_errors: yes
-
-- name: dns_opts (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_opts:
- - rotate
- - "timeout:10"
- register: dns_opts_2
- ignore_errors: yes
-
-- name: dns_opts (less resolv.conf options)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_opts:
- - "timeout:10"
- register: dns_opts_3
- ignore_errors: yes
-
-- name: dns_opts (more resolv.conf options)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_opts:
- - "timeout:10"
- - no-check-names
- force_kill: yes
- register: dns_opts_4
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - dns_opts_1 is changed
- - dns_opts_2 is not changed
- - dns_opts_3 is not changed
- - dns_opts_4 is changed
- when: docker_py_version is version('1.10.0', '>=')
-- assert:
- that:
- - dns_opts_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in dns_opts_1.msg"
- - "'Minimum version required is 1.10.0 ' in dns_opts_1.msg"
- when: docker_py_version is version('1.10.0', '<')
-
-####################################################################
-## dns_search_domains ##############################################
-####################################################################
-
-- name: dns_search_domains
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_search_domains:
- - example.com
- - example.org
- register: dns_search_domains_1
-
-- name: dns_search_domains (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_search_domains:
- - example.com
- - example.org
- register: dns_search_domains_2
-
-- name: dns_search_domains (different order)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_search_domains:
- - example.org
- - example.com
- force_kill: yes
- register: dns_search_domains_3
-
-- name: dns_search_domains (changed elements)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_search_domains:
- - ansible.com
- - example.com
- force_kill: yes
- register: dns_search_domains_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - dns_search_domains_1 is changed
- - dns_search_domains_2 is not changed
- - dns_search_domains_3 is changed
- - dns_search_domains_4 is changed
-
-####################################################################
-## dns_servers #####################################################
-####################################################################
-
-- name: dns_servers
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_servers:
- - 1.1.1.1
- - 8.8.8.8
- register: dns_servers_1
-
-- name: dns_servers (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_servers:
- - 1.1.1.1
- - 8.8.8.8
- register: dns_servers_2
-
-- name: dns_servers (changed order)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_servers:
- - 8.8.8.8
- - 1.1.1.1
- force_kill: yes
- register: dns_servers_3
-
-- name: dns_servers (changed elements)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- dns_servers:
- - 8.8.8.8
- - 9.9.9.9
- force_kill: yes
- register: dns_servers_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - dns_servers_1 is changed
- - dns_servers_2 is not changed
- - dns_servers_3 is changed
- - dns_servers_4 is changed
-
-####################################################################
-## domainname ######################################################
-####################################################################
-
-- name: domainname
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- domainname: example.com
- state: started
- register: domainname_1
-
-- name: domainname (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- domainname: example.com
- state: started
- register: domainname_2
-
-- name: domainname (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- domainname: example.org
- state: started
- force_kill: yes
- register: domainname_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - domainname_1 is changed
- - domainname_2 is not changed
- - domainname_3 is changed
-
-####################################################################
-## entrypoint ######################################################
-####################################################################
-
-- name: entrypoint
- docker_container:
- image: alpine:3.8
- entrypoint:
- - /bin/sh
- - "-v"
- - "-c"
- - "'sleep 10m'"
- name: "{{ cname }}"
- state: started
- register: entrypoint_1
-
-- name: entrypoint (idempotency)
- docker_container:
- image: alpine:3.8
- entrypoint:
- - /bin/sh
- - "-v"
- - "-c"
- - "'sleep 10m'"
- name: "{{ cname }}"
- state: started
- register: entrypoint_2
-
-- name: entrypoint (change order, should not be idempotent)
- docker_container:
- image: alpine:3.8
- entrypoint:
- - /bin/sh
- - "-c"
- - "'sleep 10m'"
- - "-v"
- name: "{{ cname }}"
- state: started
- force_kill: yes
- register: entrypoint_3
-
-- name: entrypoint (less parameters)
- docker_container:
- image: alpine:3.8
- entrypoint:
- - /bin/sh
- - "-c"
- - "'sleep 10m'"
- name: "{{ cname }}"
- state: started
- force_kill: yes
- register: entrypoint_4
-
-- name: entrypoint (other parameters)
- docker_container:
- image: alpine:3.8
- entrypoint:
- - /bin/sh
- - "-c"
- - "'sleep 5m'"
- name: "{{ cname }}"
- state: started
- force_kill: yes
- register: entrypoint_5
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - entrypoint_1 is changed
- - entrypoint_2 is not changed
- - entrypoint_3 is changed
- - entrypoint_4 is changed
- - entrypoint_5 is changed
-
-####################################################################
-## env #############################################################
-####################################################################
-
-- name: env
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- env:
- TEST1: val1
- TEST2: val2
- TEST3: "False"
- TEST4: "true"
- TEST5: "yes"
- register: env_1
-
-- name: env (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- env:
- TEST2: val2
- TEST1: val1
- TEST5: "yes"
- TEST3: "False"
- TEST4: "true"
- register: env_2
-
-- name: env (less environment variables)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- env:
- TEST1: val1
- register: env_3
-
-- name: env (more environment variables)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- env:
- TEST1: val1
- TEST3: val3
- force_kill: yes
- register: env_4
-
-- name: env (fail unwrapped values)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- env:
- TEST1: true
- force_kill: yes
- register: env_5
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - env_1 is changed
- - env_2 is not changed
- - env_3 is not changed
- - env_4 is changed
- - env_5 is failed
- - "('Non-string value found for env option.') in env_5.msg"
-
-####################################################################
-## env_file #########################################################
-####################################################################
-
-- name: env_file
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- env_file: "{{ role_path }}/files/env-file"
- register: env_file_1
-
-- name: env_file (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- env_file: "{{ role_path }}/files/env-file"
- register: env_file_2
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - env_file_1 is changed
- - env_file_2 is not changed
-
-####################################################################
-## etc_hosts #######################################################
-####################################################################
-
-- name: etc_hosts
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- etc_hosts:
- example.com: 1.2.3.4
- example.org: 4.3.2.1
- register: etc_hosts_1
-
-- name: etc_hosts (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- etc_hosts:
- example.org: 4.3.2.1
- example.com: 1.2.3.4
- register: etc_hosts_2
-
-- name: etc_hosts (less hosts)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- etc_hosts:
- example.com: 1.2.3.4
- register: etc_hosts_3
-
-- name: etc_hosts (more hosts)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- etc_hosts:
- example.com: 1.2.3.4
- example.us: 1.2.3.5
- force_kill: yes
- register: etc_hosts_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - etc_hosts_1 is changed
- - etc_hosts_2 is not changed
- - etc_hosts_3 is not changed
- - etc_hosts_4 is changed
-
-####################################################################
-## exposed_ports ###################################################
-####################################################################
-
-- name: exposed_ports
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- exposed_ports:
- - "9001"
- - "9002"
- register: exposed_ports_1
-
-- name: exposed_ports (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- exposed_ports:
- - "9002"
- - "9001"
- register: exposed_ports_2
-
-- name: exposed_ports (less ports)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- exposed_ports:
- - "9002"
- register: exposed_ports_3
-
-- name: exposed_ports (more ports)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- exposed_ports:
- - "9002"
- - "9003"
- force_kill: yes
- register: exposed_ports_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - exposed_ports_1 is changed
- - exposed_ports_2 is not changed
- - exposed_ports_3 is not changed
- - exposed_ports_4 is changed
-
-####################################################################
-## force_kill ######################################################
-####################################################################
-
-# TODO: - force_kill
-
-####################################################################
-## groups ##########################################################
-####################################################################
-
-- name: groups
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- groups:
- - "1234"
- - "5678"
- register: groups_1
-
-- name: groups (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- groups:
- - "5678"
- - "1234"
- register: groups_2
-
-- name: groups (less groups)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- groups:
- - "1234"
- register: groups_3
-
-- name: groups (more groups)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- groups:
- - "1234"
- - "2345"
- force_kill: yes
- register: groups_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - groups_1 is changed
- - groups_2 is not changed
- - groups_3 is not changed
- - groups_4 is changed
-
-####################################################################
-## healthcheck #####################################################
-####################################################################
-
-- name: healthcheck
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- healthcheck:
- test:
- - CMD
- - sleep
- - 1
- timeout: 2s
- interval: 0h0m2s3ms4us
- retries: 2
- force_kill: yes
- register: healthcheck_1
- ignore_errors: yes
-
-- name: healthcheck (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- healthcheck:
- test:
- - CMD
- - sleep
- - 1
- timeout: 2s
- interval: 0h0m2s3ms4us
- retries: 2
- force_kill: yes
- register: healthcheck_2
- ignore_errors: yes
-
-- name: healthcheck (changed)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- healthcheck:
- test:
- - CMD
- - sleep
- - 1
- timeout: 3s
- interval: 0h1m2s3ms4us
- retries: 3
- force_kill: yes
- register: healthcheck_3
- ignore_errors: yes
-
-- name: healthcheck (no change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- force_kill: yes
- register: healthcheck_4
- ignore_errors: yes
-
-- name: healthcheck (disabled)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- healthcheck:
- test:
- - NONE
- force_kill: yes
- register: healthcheck_5
- ignore_errors: yes
-
-- name: healthcheck (disabled, idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- healthcheck:
- test:
- - NONE
- force_kill: yes
- register: healthcheck_6
- ignore_errors: yes
-
-- name: healthcheck (string in healthcheck test, changed)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- healthcheck:
- test: "sleep 1"
- force_kill: yes
- register: healthcheck_7
- ignore_errors: yes
-
-- name: healthcheck (string in healthcheck test, idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- healthcheck:
- test: "sleep 1"
- force_kill: yes
- register: healthcheck_8
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - healthcheck_1 is changed
- - healthcheck_2 is not changed
- - healthcheck_3 is changed
- - healthcheck_4 is not changed
- - healthcheck_5 is changed
- - healthcheck_6 is not changed
- - healthcheck_7 is changed
- - healthcheck_8 is not changed
- when: docker_py_version is version('2.0.0', '>=')
-- assert:
- that:
- - healthcheck_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in healthcheck_1.msg"
- - "'Minimum version required is 2.0.0 ' in healthcheck_1.msg"
- when: docker_py_version is version('2.0.0', '<')
-
-####################################################################
-## hostname ########################################################
-####################################################################
-
-- name: hostname
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- hostname: me.example.com
- state: started
- register: hostname_1
-
-- name: hostname (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- hostname: me.example.com
- state: started
- register: hostname_2
-
-- name: hostname (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- hostname: me.example.org
- state: started
- force_kill: yes
- register: hostname_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - hostname_1 is changed
- - hostname_2 is not changed
- - hostname_3 is changed
-
-####################################################################
-## init ############################################################
-####################################################################
-
-- name: init
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- init: yes
- state: started
- register: init_1
- ignore_errors: yes
-
-- name: init (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- init: yes
- state: started
- register: init_2
- ignore_errors: yes
-
-- name: init (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- init: no
- state: started
- force_kill: yes
- register: init_3
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - init_1 is changed
- - init_2 is not changed
- - init_3 is changed
- when: docker_py_version is version('2.2.0', '>=')
-- assert:
- that:
- - init_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in init_1.msg"
- - "'Minimum version required is 2.2.0 ' in init_1.msg"
- when: docker_py_version is version('2.2.0', '<')
-
-####################################################################
-## interactive #####################################################
-####################################################################
-
-- name: interactive
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- interactive: yes
- state: started
- register: interactive_1
-
-- name: interactive (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- interactive: yes
- state: started
- register: interactive_2
-
-- name: interactive (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- interactive: no
- state: started
- force_kill: yes
- register: interactive_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - interactive_1 is changed
- - interactive_2 is not changed
- - interactive_3 is changed
-
-####################################################################
-## image / ignore_image ############################################
-####################################################################
-
-- name: Pull hello-world image to make sure ignore_image test succeeds
- # If the image isn't there, it will pull it and return 'changed'.
- docker_image:
- name: hello-world
- pull: true
-
-- name: image
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- register: image_1
-
-- name: image (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- register: image_2
-
-- name: ignore_image
- docker_container:
- image: hello-world
- ignore_image: yes
- name: "{{ cname }}"
- state: started
- register: ignore_image
-
-- name: image change
- docker_container:
- image: hello-world
- name: "{{ cname }}"
- state: started
- force_kill: yes
- register: image_change
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - image_1 is changed
- - image_2 is not changed
- - ignore_image is not changed
- - image_change is changed
-
-####################################################################
-## ipc_mode ########################################################
-####################################################################
-
-- name: start helpers
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ container_name }}"
- state: started
- ipc_mode: shareable
- loop:
- - "{{ cname_h1 }}"
- loop_control:
- loop_var: container_name
-
-- name: ipc_mode
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- ipc_mode: "container:{{ cname_h1 }}"
- # ipc_mode: shareable
- register: ipc_mode_1
-
-- name: ipc_mode (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- ipc_mode: "container:{{ cname_h1 }}"
- # ipc_mode: shareable
- register: ipc_mode_2
-
-- name: ipc_mode (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- ipc_mode: private
- force_kill: yes
- register: ipc_mode_3
-
-- name: cleanup
- docker_container:
- name: "{{ container_name }}"
- state: absent
- force_kill: yes
- loop:
- - "{{ cname }}"
- - "{{ cname_h1 }}"
- loop_control:
- loop_var: container_name
- diff: no
-
-- assert:
- that:
- - ipc_mode_1 is changed
- - ipc_mode_2 is not changed
- - ipc_mode_3 is changed
-
-####################################################################
-## kernel_memory ###################################################
-####################################################################
-
-- name: kernel_memory
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- kernel_memory: 8M
- state: started
- register: kernel_memory_1
- ignore_errors: yes
-
-- name: kernel_memory (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- kernel_memory: 8M
- state: started
- register: kernel_memory_2
- ignore_errors: yes
-
-- name: kernel_memory (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- kernel_memory: 6M
- state: started
- force_kill: yes
- register: kernel_memory_3
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
- ignore_errors: yes
-
-- assert:
- that:
- - kernel_memory_1 is changed
- - kernel_memory_2 is not changed
- - kernel_memory_3 is changed
- when: kernel_memory_1 is not failed or 'kernel memory accounting disabled in this runc build' not in kernel_memory_1.msg
-
-####################################################################
-## kill_signal #####################################################
-####################################################################
-
-# TODO: - kill_signal
-
-####################################################################
-## labels ##########################################################
-####################################################################
-
-- name: labels
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- labels:
- ansible.test.1: hello
- ansible.test.2: world
- register: labels_1
-
-- name: labels (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- labels:
- ansible.test.2: world
- ansible.test.1: hello
- register: labels_2
-
-- name: labels (less labels)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- labels:
- ansible.test.1: hello
- register: labels_3
-
-- name: labels (more labels)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- labels:
- ansible.test.1: hello
- ansible.test.3: ansible
- force_kill: yes
- register: labels_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - labels_1 is changed
- - labels_2 is not changed
- - labels_3 is not changed
- - labels_4 is changed
-
-####################################################################
-## links ###########################################################
-####################################################################
-
-- name: start helpers
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ container_name }}"
- state: started
- loop:
- - "{{ cname_h1 }}"
- - "{{ cname_h2 }}"
- - "{{ cname_h3 }}"
- loop_control:
- loop_var: container_name
-
-- name: links
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- links:
- - "{{ cname_h1 }}:test1"
- - "{{ cname_h2 }}:test2"
- register: links_1
-
-- name: links (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- links:
- - "{{ cname_h2 }}:test2"
- - "{{ cname_h1 }}:test1"
- register: links_2
-
-- name: links (less links)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- links:
- - "{{ cname_h1 }}:test1"
- register: links_3
-
-- name: links (more links)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- links:
- - "{{ cname_h1 }}:test1"
- - "{{ cname_h3 }}:test3"
- force_kill: yes
- register: links_4
-
-- name: cleanup
- docker_container:
- name: "{{ container_name }}"
- state: absent
- force_kill: yes
- loop:
- - "{{ cname }}"
- - "{{ cname_h1 }}"
- - "{{ cname_h2 }}"
- - "{{ cname_h3 }}"
- loop_control:
- loop_var: container_name
- diff: no
-
-- assert:
- that:
- - links_1 is changed
- - links_2 is not changed
- - links_3 is not changed
- - links_4 is changed
-
-####################################################################
-## log_driver ######################################################
-####################################################################
-
-- name: log_driver
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- log_driver: json-file
- register: log_driver_1
-
-- name: log_driver (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- log_driver: json-file
- register: log_driver_2
-
-- name: log_driver (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- log_driver: syslog
- force_kill: yes
- register: log_driver_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - log_driver_1 is changed
- - log_driver_2 is not changed
- - log_driver_3 is changed
-
-####################################################################
-## log_options #####################################################
-####################################################################
-
-- name: log_options
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- log_driver: json-file
- log_options:
- labels: production_status
- env: os,customer
- max-file: 5
- register: log_options_1
-
-- name: log_options (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- log_driver: json-file
- log_options:
- env: os,customer
- labels: production_status
- max-file: 5
- register: log_options_2
-
-- name: log_options (less log options)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- log_driver: json-file
- log_options:
- labels: production_status
- register: log_options_3
-
-- name: log_options (more log options)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- log_driver: json-file
- log_options:
- labels: production_status
- max-size: 10m
- force_kill: yes
- register: log_options_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - log_options_1 is changed
- - log_options_2 is not changed
- - "'Non-string value found for log_options option \\'max-file\\'. The value is automatically converted to \\'5\\'. If this is not correct, or you want to
-avoid such warnings, please quote the value.' in log_options_2.warnings"
- - log_options_3 is not changed
- - log_options_4 is changed
-
-####################################################################
-## mac_address #####################################################
-####################################################################
-
-- name: mac_address
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- mac_address: 92:d0:c6:0a:29:33
- state: started
- register: mac_address_1
-
-- name: mac_address (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- mac_address: 92:d0:c6:0a:29:33
- state: started
- register: mac_address_2
-
-- name: mac_address (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- mac_address: 92:d0:c6:0a:29:44
- state: started
- force_kill: yes
- register: mac_address_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - mac_address_1 is changed
- - mac_address_2 is not changed
- - mac_address_3 is changed
-
-####################################################################
-## memory ##########################################################
-####################################################################
-
-- name: memory
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- memory: 64M
- state: started
- register: memory_1
-
-- name: memory (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- memory: 64M
- state: started
- register: memory_2
-
-- name: memory (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- memory: 48M
- state: started
- force_kill: yes
- register: memory_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - memory_1 is changed
- - memory_2 is not changed
- - memory_3 is changed
-
-####################################################################
-## memory_reservation ##############################################
-####################################################################
-
-- name: memory_reservation
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- memory_reservation: 64M
- state: started
- register: memory_reservation_1
-
-- name: memory_reservation (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- memory_reservation: 64M
- state: started
- register: memory_reservation_2
-
-- name: memory_reservation (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- memory_reservation: 48M
- state: started
- force_kill: yes
- register: memory_reservation_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - memory_reservation_1 is changed
- - memory_reservation_2 is not changed
- - memory_reservation_3 is changed
-
-####################################################################
-## memory_swap #####################################################
-####################################################################
-
-- name: memory_swap
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- # Docker daemon does not accept memory_swap if memory is not specified
- memory: 32M
- memory_swap: 64M
- state: started
- debug: yes
- register: memory_swap_1
-
-- name: memory_swap (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- # Docker daemon does not accept memory_swap if memory is not specified
- memory: 32M
- memory_swap: 64M
- state: started
- debug: yes
- register: memory_swap_2
-
-- name: memory_swap (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- # Docker daemon does not accept memory_swap if memory is not specified
- memory: 32M
- memory_swap: 48M
- state: started
- force_kill: yes
- debug: yes
- register: memory_swap_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - memory_swap_1 is changed
- # Sometimes (in particular during integration tests, maybe when not running
- # on a proper VM), memory_swap cannot be set and will be -1 afterwards.
- - memory_swap_2 is not changed or memory_swap_2.container.HostConfig.MemorySwap == -1
- - memory_swap_3 is changed
-
-- debug: var=memory_swap_1
- when: memory_swap_2 is changed
-- debug: var=memory_swap_2
- when: memory_swap_2 is changed
-- debug: var=memory_swap_3
- when: memory_swap_2 is changed
-
-####################################################################
-## memory_swappiness ###############################################
-####################################################################
-
-- name: memory_swappiness
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- memory_swappiness: 40
- state: started
- register: memory_swappiness_1
-
-- name: memory_swappiness (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- memory_swappiness: 40
- state: started
- register: memory_swappiness_2
-
-- name: memory_swappiness (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- memory_swappiness: 60
- state: started
- force_kill: yes
- register: memory_swappiness_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - memory_swappiness_1 is changed
- - memory_swappiness_2 is not changed
- - memory_swappiness_3 is changed
-
-####################################################################
-## oom_killer ######################################################
-####################################################################
-
-- name: oom_killer
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- oom_killer: yes
- state: started
- register: oom_killer_1
-
-- name: oom_killer (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- oom_killer: yes
- state: started
- register: oom_killer_2
-
-- name: oom_killer (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- oom_killer: no
- state: started
- force_kill: yes
- register: oom_killer_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - oom_killer_1 is changed
- - oom_killer_2 is not changed
- - oom_killer_3 is changed
-
-####################################################################
-## oom_score_adj ###################################################
-####################################################################
-
-- name: oom_score_adj
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- oom_score_adj: 5
- state: started
- register: oom_score_adj_1
-
-- name: oom_score_adj (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- oom_score_adj: 5
- state: started
- register: oom_score_adj_2
-
-- name: oom_score_adj (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- oom_score_adj: 7
- state: started
- force_kill: yes
- register: oom_score_adj_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - oom_score_adj_1 is changed
- - oom_score_adj_2 is not changed
- - oom_score_adj_3 is changed
-
-####################################################################
-## output_logs #####################################################
-####################################################################
-
-# TODO: - output_logs
-
-####################################################################
-## paused ##########################################################
-####################################################################
-
-- name: paused
- docker_container:
- image: alpine:3.8
- command: "/bin/sh -c 'sleep 10m'"
- name: "{{ cname }}"
- state: started
- paused: yes
- force_kill: yes
- register: paused_1
-
-- name: inspect paused
- command: "docker inspect -f {% raw %}'{{.State.Status}} {{.State.Paused}}'{% endraw %} {{ cname }}"
- register: paused_2
-
-- name: paused (idempotent)
- docker_container:
- image: alpine:3.8
- command: "/bin/sh -c 'sleep 10m'"
- name: "{{ cname }}"
- state: started
- paused: yes
- force_kill: yes
- register: paused_3
-
-- name: paused (continue)
- docker_container:
- image: alpine:3.8
- command: "/bin/sh -c 'sleep 10m'"
- name: "{{ cname }}"
- state: started
- paused: no
- force_kill: yes
- register: paused_4
-
-- name: inspect paused
- command: "docker inspect -f {% raw %}'{{.State.Status}} {{.State.Paused}}'{% endraw %} {{ cname }}"
- register: paused_5
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - paused_1 is changed
- - 'paused_2.stdout == "paused true"'
- - paused_3 is not changed
- - paused_4 is changed
- - 'paused_5.stdout == "running false"'
-
-####################################################################
-## pid_mode ########################################################
-####################################################################
-
-- name: start helpers
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname_h1 }}"
- state: started
- register: pid_mode_helper
-
-- name: pid_mode
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- pid_mode: "container:{{ pid_mode_helper.container.Id }}"
- register: pid_mode_1
- ignore_errors: yes
- # docker-py < 2.0 does not support "arbitrary" pid_mode values
-
-- name: pid_mode (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- pid_mode: "container:{{ cname_h1 }}"
- register: pid_mode_2
- ignore_errors: yes
- # docker-py < 2.0 does not support "arbitrary" pid_mode values
-
-- name: pid_mode (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- pid_mode: host
- force_kill: yes
- register: pid_mode_3
-
-- name: cleanup
- docker_container:
- name: "{{ container_name }}"
- state: absent
- force_kill: yes
- loop:
- - "{{ cname }}"
- - "{{ cname_h1 }}"
- loop_control:
- loop_var: container_name
- diff: no
-
-- assert:
- that:
- - pid_mode_1 is changed
- - pid_mode_2 is not changed
- - pid_mode_3 is changed
- when: docker_py_version is version('2.0.0', '>=')
-- assert:
- that:
- - pid_mode_1 is failed
- - pid_mode_2 is failed
- - pid_mode_3 is changed
- when: docker_py_version is version('2.0.0', '<')
-
-####################################################################
-## pids_limit ######################################################
-####################################################################
-
-- name: pids_limit
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- pids_limit: 10
- register: pids_limit_1
- ignore_errors: yes
-
-- name: pids_limit (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- pids_limit: 10
- register: pids_limit_2
- ignore_errors: yes
-
-- name: pids_limit (changed)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- pids_limit: 20
- force_kill: yes
- register: pids_limit_3
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - pids_limit_1 is changed
- - pids_limit_2 is not changed
- - pids_limit_3 is changed
- when: docker_py_version is version('1.10.0', '>=')
-- assert:
- that:
- - pids_limit_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in pids_limit_1.msg"
- - "'Minimum version required is 1.10.0 ' in pids_limit_1.msg"
- when: docker_py_version is version('1.10.0', '<')
-
-####################################################################
-## privileged ######################################################
-####################################################################
-
-- name: privileged
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- privileged: yes
- state: started
- register: privileged_1
-
-- name: privileged (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- privileged: yes
- state: started
- register: privileged_2
-
-- name: privileged (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- privileged: no
- state: started
- force_kill: yes
- register: privileged_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - privileged_1 is changed
- - privileged_2 is not changed
- - privileged_3 is changed
-
-####################################################################
-## published_ports #################################################
-####################################################################
-
-- name: published_ports
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- published_ports:
- - '9001'
- - '9002'
- register: published_ports_1
-
-- name: published_ports (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- published_ports:
- - '9002'
- - '9001'
- register: published_ports_2
-
-- name: published_ports (less published_ports)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- published_ports:
- - '9002'
- register: published_ports_3
-
-- name: published_ports (more published_ports)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- published_ports:
- - '9002'
- - '9003'
- force_kill: yes
- register: published_ports_4
-
-- name: published_ports (ports with IP addresses)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- published_ports:
- - '127.0.0.1:9002:9002/tcp'
- - '[::1]:9003:9003/tcp'
- force_kill: yes
- register: published_ports_5
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - published_ports_1 is changed
- - published_ports_2 is not changed
- - published_ports_3 is not changed
- - published_ports_4 is changed
- - published_ports_5 is changed
-
-####################################################################
-## pull ############################################################
-####################################################################
-
-# TODO: - pull
-
-####################################################################
-## read_only #######################################################
-####################################################################
-
-- name: read_only
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- read_only: yes
- state: started
- register: read_only_1
-
-- name: read_only (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- read_only: yes
- state: started
- register: read_only_2
-
-- name: read_only (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- read_only: no
- state: started
- force_kill: yes
- register: read_only_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - read_only_1 is changed
- - read_only_2 is not changed
- - read_only_3 is changed
-
-####################################################################
-## restart_policy ##################################################
-####################################################################
-
-- name: restart_policy
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- restart_policy: always
- state: started
- register: restart_policy_1
-
-- name: restart_policy (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- restart_policy: always
- state: started
- register: restart_policy_2
-
-- name: restart_policy (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- restart_policy: unless-stopped
- state: started
- force_kill: yes
- register: restart_policy_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - restart_policy_1 is changed
- - restart_policy_2 is not changed
- - restart_policy_3 is changed
-
-####################################################################
-## restart_retries #################################################
-####################################################################
-
-- name: restart_retries
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- restart_policy: on-failure
- restart_retries: 5
- state: started
- register: restart_retries_1
-
-- name: restart_retries (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- restart_policy: on-failure
- restart_retries: 5
- state: started
- register: restart_retries_2
-
-- name: restart_retries (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- restart_policy: on-failure
- restart_retries: 2
- state: started
- force_kill: yes
- register: restart_retries_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - restart_retries_1 is changed
- - restart_retries_2 is not changed
- - restart_retries_3 is changed
-
-####################################################################
-## runtime #########################################################
-####################################################################
-
-- name: runtime
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- runtime: runc
- state: started
- register: runtime_1
- ignore_errors: yes
-
-- name: runtime (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- runtime: runc
- state: started
- register: runtime_2
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - runtime_1 is changed
- - runtime_2 is not changed
- when: docker_py_version is version('2.4.0', '>=')
-- assert:
- that:
- - runtime_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in runtime_1.msg"
- - "'Minimum version required is 2.4.0 ' in runtime_1.msg"
- when: docker_py_version is version('2.4.0', '<')
-
-####################################################################
-## security_opts ###################################################
-####################################################################
-
-# In case some of the options stop working, here are some more
-# options which *currently* work with all integration test targets:
-# no-new-privileges
-# label:disable
-# label=disable
-# label:level:s0:c100,c200
-# label=level:s0:c100,c200
-# label:type:svirt_apache_t
-# label=type:svirt_apache_t
-# label:user:root
-# label=user:root
-# seccomp:unconfined
-# seccomp=unconfined
-# apparmor:docker-default
-# apparmor=docker-default
-
-- name: security_opts
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- security_opts:
- - "label:level:s0:c100,c200"
- - "no-new-privileges"
- register: security_opts_1
-
-- name: security_opts (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- security_opts:
- - "no-new-privileges"
- - "label:level:s0:c100,c200"
- register: security_opts_2
-
-- name: security_opts (less security options)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- security_opts:
- - "no-new-privileges"
- register: security_opts_3
-
-- name: security_opts (more security options)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- security_opts:
- - "label:disable"
- - "no-new-privileges"
- force_kill: yes
- register: security_opts_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - security_opts_1 is changed
- - security_opts_2 is not changed
- - security_opts_3 is not changed
- - security_opts_4 is changed
-
-####################################################################
-## shm_size ########################################################
-####################################################################
-
-- name: shm_size
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- shm_size: 96M
- state: started
- register: shm_size_1
-
-- name: shm_size (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- shm_size: 96M
- state: started
- register: shm_size_2
-
-- name: shm_size (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- shm_size: 75M
- state: started
- force_kill: yes
- register: shm_size_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - shm_size_1 is changed
- - shm_size_2 is not changed
- - shm_size_3 is changed
-
-####################################################################
-## stop_signal #####################################################
-####################################################################
-
-- name: stop_signal
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- stop_signal: "30"
- state: started
- register: stop_signal_1
-
-- name: stop_signal (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- stop_signal: "30"
- state: started
- register: stop_signal_2
-
-- name: stop_signal (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- stop_signal: "9"
- state: started
- force_kill: yes
- register: stop_signal_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - stop_signal_1 is changed
- - stop_signal_2 is not changed
- - stop_signal_3 is changed
-
-####################################################################
-## stop_timeout ####################################################
-####################################################################
-
-- name: stop_timeout
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- stop_timeout: 2
- state: started
- register: stop_timeout_1
-
-- name: stop_timeout (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- stop_timeout: 2
- state: started
- register: stop_timeout_2
-
-- name: stop_timeout (no change)
- # stop_timeout changes are ignored by default
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- stop_timeout: 1
- state: started
- register: stop_timeout_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - stop_timeout_1 is changed
- - stop_timeout_2 is not changed
- - stop_timeout_3 is not changed
-
-####################################################################
-## sysctls #########################################################
-####################################################################
-
-# In case some of the options stop working, here are some more
-# options which *currently* work with all integration test targets:
-# net.ipv4.conf.default.log_martians: 1
-# net.ipv4.conf.default.secure_redirects: 0
-# net.ipv4.conf.default.send_redirects: 0
-# net.ipv4.conf.all.log_martians: 1
-# net.ipv4.conf.all.accept_redirects: 0
-# net.ipv4.conf.all.secure_redirects: 0
-# net.ipv4.conf.all.send_redirects: 0
-
-- name: sysctls
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- sysctls:
- net.ipv4.icmp_echo_ignore_all: 1
- net.ipv4.ip_forward: 1
- register: sysctls_1
- ignore_errors: yes
-
-- name: sysctls (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- sysctls:
- net.ipv4.ip_forward: 1
- net.ipv4.icmp_echo_ignore_all: 1
- register: sysctls_2
- ignore_errors: yes
-
-- name: sysctls (less sysctls)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- sysctls:
- net.ipv4.icmp_echo_ignore_all: 1
- register: sysctls_3
- ignore_errors: yes
-
-- name: sysctls (more sysctls)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- sysctls:
- net.ipv4.icmp_echo_ignore_all: 1
- net.ipv6.conf.default.accept_redirects: 0
- force_kill: yes
- register: sysctls_4
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - sysctls_1 is changed
- - sysctls_2 is not changed
- - sysctls_3 is not changed
- - sysctls_4 is changed
- when: docker_py_version is version('1.10.0', '>=')
-- assert:
- that:
- - sysctls_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in sysctls_1.msg"
- - "'Minimum version required is 1.10.0 ' in sysctls_1.msg"
- when: docker_py_version is version('1.10.0', '<')
-
-####################################################################
-## tmpfs ###########################################################
-####################################################################
-
-- name: tmpfs
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- tmpfs:
- - "/test1:rw,noexec,nosuid,size=65536k"
- - "/test2:rw,noexec,nosuid,size=65536k"
- register: tmpfs_1
-
-- name: tmpfs (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- tmpfs:
- - "/test2:rw,noexec,nosuid,size=65536k"
- - "/test1:rw,noexec,nosuid,size=65536k"
- register: tmpfs_2
-
-- name: tmpfs (less tmpfs)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- tmpfs:
- - "/test1:rw,noexec,nosuid,size=65536k"
- register: tmpfs_3
-
-- name: tmpfs (more tmpfs)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- tmpfs:
- - "/test1:rw,noexec,nosuid,size=65536k"
- - "/test3:rw,noexec,nosuid,size=65536k"
- force_kill: yes
- register: tmpfs_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - tmpfs_1 is changed
- - tmpfs_2 is not changed
- - tmpfs_3 is not changed
- - tmpfs_4 is changed
-
-####################################################################
-## tty #############################################################
-####################################################################
-
-- name: tty
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- tty: yes
- state: started
- register: tty_1
-
-- name: tty (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- tty: yes
- state: started
- register: tty_2
-
-- name: tty (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- tty: no
- state: started
- force_kill: yes
- register: tty_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - tty_1 is changed
- - tty_2 is not changed
- - tty_3 is changed
-
-####################################################################
-## ulimits #########################################################
-####################################################################
-
-- name: ulimits
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- ulimits:
- - "nofile:1234:1234"
- - "nproc:3:6"
- register: ulimits_1
-
-- name: ulimits (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- ulimits:
- - "nproc:3:6"
- - "nofile:1234:1234"
- register: ulimits_2
-
-- name: ulimits (less ulimits)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- ulimits:
- - "nofile:1234:1234"
- register: ulimits_3
-
-- name: ulimits (more ulimits)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- ulimits:
- - "nofile:1234:1234"
- - "sigpending:100:200"
- force_kill: yes
- register: ulimits_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - ulimits_1 is changed
- - ulimits_2 is not changed
- - ulimits_3 is not changed
- - ulimits_4 is changed
-
-####################################################################
-## user ############################################################
-####################################################################
-
-- name: user
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- user: nobody
- state: started
- register: user_1
-
-- name: user (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- user: nobody
- state: started
- register: user_2
-
-- name: user (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- user: root
- state: started
- force_kill: yes
- register: user_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - user_1 is changed
- - user_2 is not changed
- - user_3 is changed
-
-####################################################################
-## userns_mode #####################################################
-####################################################################
-
-- name: userns_mode
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- userns_mode: host
- state: started
- register: userns_mode_1
- ignore_errors: yes
-
-- name: userns_mode (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- userns_mode: host
- state: started
- register: userns_mode_2
- ignore_errors: yes
-
-- name: userns_mode (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- userns_mode: ""
- state: started
- force_kill: yes
- register: userns_mode_3
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - userns_mode_1 is changed
- - userns_mode_2 is not changed
- - userns_mode_3 is changed
- when: docker_py_version is version('1.10.0', '>=')
-- assert:
- that:
- - userns_mode_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in userns_mode_1.msg"
- - "'Minimum version required is 1.10.0 ' in userns_mode_1.msg"
- when: docker_py_version is version('1.10.0', '<')
-
-####################################################################
-## uts #############################################################
-####################################################################
-
-- name: uts
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- uts: host
- state: started
- register: uts_1
- ignore_errors: yes
-
-- name: uts (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- uts: host
- state: started
- register: uts_2
- ignore_errors: yes
-
-- name: uts (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- uts: ""
- state: started
- force_kill: yes
- register: uts_3
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - uts_1 is changed
- - uts_2 is not changed
- - uts_3 is changed
- when: docker_py_version is version('3.5.0', '>=')
-- assert:
- that:
- - uts_1 is failed
- - "('version is ' ~ docker_py_version ~ ' ') in uts_1.msg"
- - "'Minimum version required is 3.5.0 ' in uts_1.msg"
- when: docker_py_version is version('3.5.0', '<')
-
-####################################################################
-## working_dir #####################################################
-####################################################################
-
-- name: working_dir
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- working_dir: /tmp
- state: started
- register: working_dir_1
-
-- name: working_dir (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- working_dir: /tmp
- state: started
- register: working_dir_2
-
-- name: working_dir (change)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- working_dir: /
- state: started
- force_kill: yes
- register: working_dir_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - working_dir_1 is changed
- - working_dir_2 is not changed
- - working_dir_3 is changed
-
-####################################################################
-####################################################################
-####################################################################
diff --git a/test/integration/targets/docker_container/tasks/tests/ports.yml b/test/integration/targets/docker_container/tasks/tests/ports.yml
deleted file mode 100644
index e60fb3245a..0000000000
--- a/test/integration/targets/docker_container/tasks/tests/ports.yml
+++ /dev/null
@@ -1,286 +0,0 @@
----
-- name: Registering container name
- set_fact:
- cname: "{{ cname_prefix ~ '-options' }}"
- cname2: "{{ cname_prefix ~ '-options-h1' }}"
-- name: Registering container name
- set_fact:
- cnames: "{{ cnames + [cname, cname2] }}"
-
-####################################################################
-## published_ports: all ############################################
-####################################################################
-
-- name: published_ports -- all
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- exposed_ports:
- - "9001"
- - "9002"
- published_ports:
- - all
- force_kill: yes
- register: published_ports_1
-
-- name: published_ports -- all (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- exposed_ports:
- - "9001"
- - "9002"
- published_ports:
- - all
- force_kill: yes
- register: published_ports_2
-
-- name: published_ports -- all (writing out 'all')
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- exposed_ports:
- - "9001"
- - "9002"
- published_ports:
- - "9001"
- - "9002"
- force_kill: yes
- register: published_ports_3
-
-- name: published_ports -- all (idempotency 2)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- exposed_ports:
- - "9001"
- - "9002"
- published_ports:
- - "9002"
- - "9001"
- force_kill: yes
- register: published_ports_4
-
-- name: published_ports -- all (switching back to 'all')
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- exposed_ports:
- - "9001"
- - "9002"
- published_ports:
- - all
- force_kill: yes
- register: published_ports_5
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - published_ports_1 is changed
- - published_ports_2 is not changed
- - published_ports_3 is changed
- - published_ports_4 is not changed
- - published_ports_5 is changed
-
-####################################################################
-## published_ports: port range #####################################
-####################################################################
-
-- name: published_ports -- port range
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- exposed_ports:
- - "9001"
- - "9010-9050"
- published_ports:
- - "9001:9001"
- - "9010-9050:9010-9050"
- force_kill: yes
- register: published_ports_1
-
-- name: published_ports -- port range (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- exposed_ports:
- - "9001"
- - "9010-9050"
- published_ports:
- - "9001:9001"
- - "9010-9050:9010-9050"
- force_kill: yes
- register: published_ports_2
-
-- name: published_ports -- port range (different range)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- exposed_ports:
- - "9001"
- - "9010-9050"
- published_ports:
- - "9001:9001"
- - "9020-9060:9020-9060"
- force_kill: yes
- register: published_ports_3
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - published_ports_1 is changed
- - published_ports_2 is not changed
- - published_ports_3 is changed
-
-####################################################################
-## published_ports: one-element container port range ###############
-####################################################################
-
-- name: published_ports -- one-element container port range
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ item }}"
- state: started
- published_ports:
- - "9010-9050:9010"
- force_kill: yes
- loop:
- - '{{ cname }}'
- - '{{ cname2 }}'
- register: published_ports_1
-
-- name: published_ports -- one-element container port range (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ item }}"
- state: started
- published_ports:
- - "9010-9050:9010"
- force_kill: yes
- loop:
- - '{{ cname }}'
- - '{{ cname2 }}'
- register: published_ports_2
-
-- name: published_ports -- one-element container port range (different range)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ item }}"
- state: started
- published_ports:
- - "9010-9051:9010"
- force_kill: yes
- loop:
- - '{{ cname }}'
- - '{{ cname2 }}'
- register: published_ports_3
-
-- name: cleanup
- docker_container:
- name: "{{ item }}"
- state: absent
- force_kill: yes
- loop:
- - '{{ cname }}'
- - '{{ cname2 }}'
- diff: no
-
-- assert:
- that:
- - published_ports_1 is changed
- - published_ports_2 is not changed
- - published_ports_3 is changed
-
-####################################################################
-## published_ports: IPv6 addresses #################################
-####################################################################
-
-- name: published_ports -- IPv6
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- published_ports:
- - "[::1]:9001:9001"
- force_kill: yes
- register: published_ports_1
-
-- name: published_ports -- IPv6 (idempotency)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- published_ports:
- - "[::1]:9001:9001"
- force_kill: yes
- register: published_ports_2
-
-- name: published_ports -- IPv6 (different IP)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- published_ports:
- - "127.0.0.1:9001:9001"
- force_kill: yes
- register: published_ports_3
-
-- name: published_ports -- IPv6 (hostname)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- published_ports:
- - "localhost:9001:9001"
- force_kill: yes
- register: published_ports_4
- ignore_errors: yes
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - published_ports_1 is changed
- - published_ports_2 is not changed
- - published_ports_3 is changed
- - published_ports_4 is failed
diff --git a/test/integration/targets/docker_container/tasks/tests/regression-45700-dont-parse-on-absent.yml b/test/integration/targets/docker_container/tasks/tests/regression-45700-dont-parse-on-absent.yml
deleted file mode 100644
index bb7b1f2b5c..0000000000
--- a/test/integration/targets/docker_container/tasks/tests/regression-45700-dont-parse-on-absent.yml
+++ /dev/null
@@ -1,34 +0,0 @@
----
-# Regression test for https://github.com/ansible/ansible/pull/45700
-- name: Registering container name
- set_fact:
- cname: "{{ cname_prefix ~ '-45700' }}"
-- name: Registering container name
- set_fact:
- cnames: "{{ cnames + [cname] }}"
-
-- name: Start container
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
-
-- name: Stop container with a lot of invalid options
- docker_container:
- name: "{{ cname }}"
- force_kill: yes
- # Some options with "invalid" values, which would
- # have to be parsed. The values are "invalid" because
- # the containers and networks listed here do not exist.
- # This can happen because the networks are removed
- # before the container is stopped (see
- # https://github.com/ansible/ansible/issues/45486).
- networks:
- - name: "nonexistant-network-{{ (2**32) | random }}"
- published_ports:
- - '1:2'
- - '3'
- links:
- - "nonexistant-container-{{ (2**32) | random }}:test"
- state: absent
diff --git a/test/integration/targets/docker_container/tasks/tests/start-stop.yml b/test/integration/targets/docker_container/tasks/tests/start-stop.yml
deleted file mode 100644
index c794d5f52a..0000000000
--- a/test/integration/targets/docker_container/tasks/tests/start-stop.yml
+++ /dev/null
@@ -1,455 +0,0 @@
----
-- name: Registering container name
- set_fact:
- cname: "{{ cname_prefix ~ '-hi' }}"
-- name: Registering container name
- set_fact:
- cnames: "{{ cnames + [cname] }}"
-
-####################################################################
-## Creation ########################################################
-####################################################################
-
-- name: Create container (check)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: present
- check_mode: yes
- register: create_1
-
-- name: Create container
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: present
- register: create_2
-
-- name: Create container (idempotent)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: present
- register: create_3
-
-- name: Create container (idempotent check)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: present
- check_mode: yes
- register: create_4
-
-- assert:
- that:
- - create_1 is changed
- - create_2 is changed
- - create_3 is not changed
- - create_4 is not changed
-
-####################################################################
-## Starting (after creation) #######################################
-####################################################################
-
-- name: Start container (check)
- docker_container:
- name: "{{ cname }}"
- state: started
- check_mode: yes
- register: start_1
-
-- name: Start container
- docker_container:
- name: "{{ cname }}"
- state: started
- register: start_2
-
-- name: Start container (idempotent)
- docker_container:
- name: "{{ cname }}"
- state: started
- register: start_3
-
-- name: Start container (idempotent check)
- docker_container:
- name: "{{ cname }}"
- state: started
- check_mode: yes
- register: start_4
-
-- assert:
- that:
- - start_1 is changed
- - start_2 is changed
- - start_3 is not changed
- - start_4 is not changed
-
-####################################################################
-## Present check for running container #############################
-####################################################################
-
-- name: Present check for running container (check)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: present
- check_mode: yes
- register: present_check_1
-
-- name: Present check for running container
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: present
- register: present_check_2
-
-- assert:
- that:
- - present_check_1 is not changed
- - present_check_2 is not changed
-
-####################################################################
-## Starting (from scratch) #########################################
-####################################################################
-
-- name: Remove container (setup for starting from scratch)
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
-
-- name: Start container from scratch (check)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- stop_timeout: 1
- name: "{{ cname }}"
- state: started
- check_mode: yes
- register: start_scratch_1
-
-- name: Start container from scratch
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- stop_timeout: 1
- name: "{{ cname }}"
- state: started
- register: start_scratch_2
-
-- name: Start container from scratch (idempotent)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- stop_timeout: 1
- name: "{{ cname }}"
- state: started
- register: start_scratch_3
-
-- name: Start container from scratch (idempotent check)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- stop_timeout: 1
- name: "{{ cname }}"
- state: started
- check_mode: yes
- register: start_scratch_4
-
-- assert:
- that:
- - start_scratch_1 is changed
- - start_scratch_2 is changed
- - start_scratch_3 is not changed
- - start_scratch_4 is not changed
-
-####################################################################
-## Recreating ######################################################
-####################################################################
-
-- name: Recreating container (created)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: present
- force_kill: yes
- register: recreate_1
-
-- name: Recreating container (created, recreate, check mode)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- recreate: yes
- state: present
- force_kill: yes
- register: recreate_2
- check_mode: yes
-
-- name: Recreating container (created, recreate)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- recreate: yes
- state: present
- force_kill: yes
- register: recreate_3
-
-- name: Recreating container (started)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- force_kill: yes
- register: recreate_4
-
-- name: Recreating container (started, recreate, check mode)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- recreate: yes
- removal_wait_timeout: 10
- state: started
- force_kill: yes
- register: recreate_5
- check_mode: yes
-
-- name: Recreating container (started, recreate)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- recreate: yes
- removal_wait_timeout: 10
- state: started
- force_kill: yes
- register: recreate_6
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- debug: var=recreate_1
-- debug: var=recreate_3
-- debug: var=recreate_4
-- debug: var=recreate_6
-
-- assert:
- that:
- - recreate_2 is changed
- - recreate_3 is changed
- - recreate_4 is changed
- - recreate_5 is changed
- - recreate_6 is changed
- - recreate_1.container.Id == recreate_2.container.Id
- - recreate_1.container.Id != recreate_3.container.Id
- - recreate_3.container.Id == recreate_4.container.Id
- - recreate_4.container.Id == recreate_5.container.Id
- - recreate_4.container.Id != recreate_6.container.Id
-
-####################################################################
-## Restarting ######################################################
-####################################################################
-
-- name: Restarting
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- stop_timeout: 1
- volumes:
- - /tmp/tmp
- register: restart_1
-
-- name: Restarting (restart, check mode)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- restart: yes
- state: started
- stop_timeout: 1
- force_kill: yes
- register: restart_2
- check_mode: yes
-
-- name: Restarting (restart)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- restart: yes
- state: started
- stop_timeout: 1
- force_kill: yes
- register: restart_3
-
-- name: Restarting (verify volumes)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
- stop_timeout: 1
- volumes:
- - /tmp/tmp
- register: restart_4
-
-- name: cleanup
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- diff: no
-
-- assert:
- that:
- - restart_1 is changed
- - restart_2 is changed
- - restart_3 is changed
- - restart_1.container.Id == restart_3.container.Id
- - restart_4 is not changed
-
-####################################################################
-## Stopping ########################################################
-####################################################################
-
-- name: Stop container (check)
- docker_container:
- image: alpine:3.8
- name: "{{ cname }}"
- state: stopped
- stop_timeout: 1
- check_mode: yes
- register: stop_1
-
-- name: Stop container
- docker_container:
- image: alpine:3.8
- name: "{{ cname }}"
- state: stopped
- stop_timeout: 1
- register: stop_2
-
-- name: Stop container (idempotent)
- docker_container:
- image: alpine:3.8
- name: "{{ cname }}"
- state: stopped
- stop_timeout: 1
- register: stop_3
-
-- name: Stop container (idempotent check)
- docker_container:
- image: alpine:3.8
- name: "{{ cname }}"
- state: stopped
- stop_timeout: 1
- check_mode: yes
- register: stop_4
-
-- assert:
- that:
- - stop_1 is changed
- - stop_2 is changed
- - stop_3 is not changed
- - stop_4 is not changed
-
-####################################################################
-## Removing ########################################################
-####################################################################
-
-- name: Remove container (check)
- docker_container:
- name: "{{ cname }}"
- state: absent
- check_mode: yes
- register: remove_1
-
-- name: Remove container
- docker_container:
- name: "{{ cname }}"
- state: absent
- register: remove_2
-
-- name: Remove container (idempotent)
- docker_container:
- name: "{{ cname }}"
- state: absent
- register: remove_3
-
-- name: Remove container (idempotent check)
- docker_container:
- name: "{{ cname }}"
- state: absent
- check_mode: yes
- register: remove_4
-
-- assert:
- that:
- - remove_1 is changed
- - remove_2 is changed
- - remove_3 is not changed
- - remove_4 is not changed
-
-####################################################################
-## Removing (from running) #########################################
-####################################################################
-
-- name: Start container (setup for removing from running)
- docker_container:
- image: alpine:3.8
- command: '/bin/sh -c "sleep 10m"'
- name: "{{ cname }}"
- state: started
-
-- name: Remove container from running (check)
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- check_mode: yes
- register: remove_from_running_1
-
-- name: Remove container from running
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- register: remove_from_running_2
-
-- name: Remove container from running (idempotent)
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- register: remove_from_running_3
-
-- name: Remove container from running (idempotent check)
- docker_container:
- name: "{{ cname }}"
- state: absent
- force_kill: yes
- check_mode: yes
- register: remove_from_running_4
-
-- assert:
- that:
- - remove_from_running_1 is changed
- - remove_from_running_2 is changed
- - remove_from_running_3 is not changed
- - remove_from_running_4 is not changed