summaryrefslogtreecommitdiffstats
path: root/collections-debian-merged/ansible_collections/community/docker/tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:03:01 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-14 20:03:01 +0000
commita453ac31f3428614cceb99027f8efbdb9258a40b (patch)
treef61f87408f32a8511cbd91799f9cececb53e0374 /collections-debian-merged/ansible_collections/community/docker/tests
parentInitial commit. (diff)
downloadansible-upstream.tar.xz
ansible-upstream.zip
Adding upstream version 2.10.7+merged+base+2.10.8+dfsg.upstream/2.10.7+merged+base+2.10.8+dfsgupstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'collections-debian-merged/ansible_collections/community/docker/tests')
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection/aliases1
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection/test.sh10
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection/test_connection.yml43
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/aliases3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/meta/main.yml3
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/runme-connection.sh18
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/runme.sh63
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/setup.yml10
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/shutdown.yml15
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/aliases3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/meta/main.yml3
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/runme-connection.sh18
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/runme.sh63
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/setup.yml10
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/shutdown.yml15
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_posix/aliases2
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_posix/test.sh18
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/tasks/main.yml11
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/tasks/test_docker_config.yml139
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/files/env-file2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/filter_plugins/ipaddr_tools.py34
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/main.yml43
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/run-test.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/comparisons.yml463
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/compatibility.yml118
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/image-ids.yml141
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/mounts-volumes.yml445
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/network.yml747
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/options.yml3905
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/ports.yml286
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/regression-45700-dont-parse-on-absent.yml34
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/start-stop.yml455
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container_info/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container_info/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container_info/tasks/main.yml80
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/tasks/main.yml10
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/tasks/test_host_info.yml296
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/main.yml8
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/run-test.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/test.yml49
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/tests/basic.yml78
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/tests/docker_image.yml228
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/tests/options.yml389
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/Dockerfile3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/EtcHostsDockerfile3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/MyDockerfile5
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/StagedDockerfile7
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image_info/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image_info/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image_info/tasks/main.yml59
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/main.yml9
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/run-test.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/test.yml9
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/tests/docker_login.yml139
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/tests/multiple-servers.yml57
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/main.yml38
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/run-test.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/basic.yml134
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/ipam.yml312
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/options.yml240
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/overlay.yml61
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/substring.yml37
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network_info/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network_info/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network_info/tasks/main.yml76
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/aliases3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/tasks/main.yml37
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/tasks/test_node.yml840
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/tasks/main.yml11
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/tasks/test_node_info.yml88
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_prune/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_prune/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_prune/tasks/main.yml68
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/tasks/main.yml10
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/tasks/test_secrets.yml124
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/tasks/main.yml10
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/tasks/test_stack.yml113
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/templates/stack_compose_base.yml5
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/templates/stack_compose_overrides.yml5
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/vars/main.yml15
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/tasks/main.yml10
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/tasks/test_stack_info.yml75
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/templates/stack_compose_base.yml5
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/templates/stack_compose_overrides.yml5
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/vars/main.yml15
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/tasks/main.yml10
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/tasks/test_stack_task_info.yml84
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/templates/stack_compose_base.yml5
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/templates/stack_compose_overrides.yml5
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/vars/main.yml15
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/aliases3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/meta/main.yml4
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/cleanup.yml35
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/main.yml23
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/run-test.yml0
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/basic.yml158
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/options-ca.yml114
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/options.yml1158
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/remote-addr-pool.yml90
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/tasks/main.yml11
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/tasks/test_swarm_info.yml190
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/files/env-file-12
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/files/env-file-22
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/main.yml80
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/run-test.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/configs.yml413
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/logging.yml135
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/misc.yml113
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/mounts.yml601
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/networks.yml450
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/options.yml1878
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/placement.yml202
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/resources.yml193
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/restart_config.yml193
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/rollback_config.yml339
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/secrets.yml411
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/update_config.yml345
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/vars/main.yml54
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/tasks/main.yml11
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/tasks/test_docker_swarm_service_info.yml83
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/tasks/main.yml30
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/tasks/run-test.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/tasks/tests/basic.yml177
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume_info/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume_info/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume_info/tasks/main.yml74
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/aliases3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/inventory_1.docker.yml2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/inventory_2.docker.yml6
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/docker_cleanup.yml22
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/docker_setup.yml22
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/test_inventory_1.yml36
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/test_inventory_2.yml45
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/runme.sh22
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/aliases4
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/docker-machine20
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/inventory_1.docker_machine.yml1
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/inventory_2.docker_machine.yml2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/inventory_3.docker_machine.yml2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/pre-setup.yml18
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/setup.yml11
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/teardown.yml6
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/test_inventory_1.yml50
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/runme.sh68
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/teardown.docker_machine.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/aliases3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/inventory_1.docker_swarm.yml2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/inventory_2.docker_swarm.yml4
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/swarm_cleanup.yml18
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/swarm_setup.yml15
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/test_inventory_1.yml58
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/test_inventory_2.yml35
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/runme.sh22
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/aliases1
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/defaults/main.yml19
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/handlers/main.yml14
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/Debian.yml45
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/Fedora.yml26
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/RedHat-7.yml46
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/RedHat-8.yml35
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/Suse.yml8
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/main.yml154
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Debian.yml6
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Fedora.yml1
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/RedHat-7.yml9
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/RedHat-8.yml12
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Suse.yml8
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Ubuntu-14.yml6
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/default.yml1
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/main.env2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/main.yml11
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/aliases2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/files/nginx.conf46
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/files/nginx.htpasswd1
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/handlers/cleanup.yml55
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/handlers/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/tasks/main.yml9
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/tasks/setup-frontend.yml97
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/tasks/setup.yml80
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/vars/main.yml11
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_epel/tasks/main.yml10
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/meta/main.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/tasks/main.yml31
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/Debian.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/FreeBSD.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/RedHat.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/Suse.yml3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_pkg_mgr/tasks/main.yml17
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_constraints/aliases1
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_constraints/meta/main.yml2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_constraints/tasks/main.yml13
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/handlers/main.yml5
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/tasks/default-cleanup.yml5
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/tasks/default.yml11
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/tasks/main.yml15
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/requirements.yml7
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/sanity/extra/no-unwanted-files.json7
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/sanity/extra/no-unwanted-files.py43
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/sanity/ignore-2.10.txt3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/sanity/ignore-2.11.txt3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/sanity/ignore-2.9.txt3
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/__init__.py0
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/builtins.py33
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/mock.py122
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/unittest.py38
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/connection/test_docker.py67
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/inventory/test_docker_containers.py228
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/module_utils/__init__.py0
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/module_utils/test_common.py518
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/__init__.py0
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/conftest.py31
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_container.py22
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_network.py31
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_swarm_service.py510
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_volume.py36
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/unit/requirements.txt2
-rw-r--r--collections-debian-merged/ansible_collections/community/docker/tests/utils/constraints.txt52
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/check_matrix.py120
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/cloud.sh19
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/linux.sh18
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/remote.sh22
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/rhel.sh22
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/sanity.sh24
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/shippable.sh219
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/timing.py16
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/timing.sh5
-rwxr-xr-xcollections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/units.sh26
263 files changed, 22294 insertions, 0 deletions
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection/aliases
new file mode 100644
index 00000000..136c05e0
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection/aliases
@@ -0,0 +1 @@
+hidden
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection/test.sh b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection/test.sh
new file mode 100755
index 00000000..4e7aa8dd
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection/test.sh
@@ -0,0 +1,10 @@
+#!/usr/bin/env bash
+
+set -eux
+
+[ -f "${INVENTORY}" ]
+
+# Run connection tests with both the default and C locale.
+
+ ansible-playbook test_connection.yml -i "${INVENTORY}" "$@"
+LC_ALL=C LANG=C ansible-playbook test_connection.yml -i "${INVENTORY}" "$@"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection/test_connection.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection/test_connection.yml
new file mode 100644
index 00000000..a662e576
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection/test_connection.yml
@@ -0,0 +1,43 @@
+- hosts: "{{ target_hosts }}"
+ gather_facts: no
+ serial: 1
+ tasks:
+
+ ### raw with unicode arg and output
+
+ - name: raw with unicode arg and output
+ raw: echo 汉语
+ register: command
+ - name: check output of raw with unicode arg and output
+ assert:
+ that:
+ - "'汉语' in command.stdout"
+ - command is changed # as of 2.2, raw should default to changed: true for consistency w/ shell/command/script modules
+
+ ### copy local file with unicode filename and content
+
+ - name: create local file with unicode filename and content
+ local_action: lineinfile dest={{ local_tmp }}-汉语/汉语.txt create=true line=汉语
+ - name: remove remote file with unicode filename and content
+ action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语/汉语.txt state=absent"
+ - name: create remote directory with unicode name
+ action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=directory"
+ - name: copy local file with unicode filename and content
+ action: "{{ action_prefix }}copy src={{ local_tmp }}-汉语/汉语.txt dest={{ remote_tmp }}-汉语/汉语.txt"
+
+ ### fetch remote file with unicode filename and content
+
+ - name: remove local file with unicode filename and content
+ local_action: file path={{ local_tmp }}-汉语/汉语.txt state=absent
+ - name: fetch remote file with unicode filename and content
+ fetch: src={{ remote_tmp }}-汉语/汉语.txt dest={{ local_tmp }}-汉语/汉语.txt fail_on_missing=true validate_checksum=true flat=true
+
+ ### remove local and remote temp files
+
+ - name: remove local temp file
+ local_action: file path={{ local_tmp }}-汉语 state=absent
+ - name: remove remote temp file
+ action: "{{ action_prefix }}file path={{ remote_tmp }}-汉语 state=absent"
+
+ ### test wait_for_connection plugin
+ - ansible.builtin.wait_for_connection:
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/aliases
new file mode 100644
index 00000000..8beddaed
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/aliases
@@ -0,0 +1,3 @@
+shippable/posix/group4
+skip/docker # coverage does not work if we're inside a docker container, since we cannot access this container's /tmp dir from the new container
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/runme-connection.sh b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/runme-connection.sh
new file mode 100755
index 00000000..d3976ff3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/runme-connection.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+set -eux
+
+# Connection tests for POSIX platforms use this script by linking to it from the appropriate 'connection_' target dir.
+# The name of the inventory group to test is extracted from the directory name following the 'connection_' prefix.
+
+group=$(python -c \
+ "from os import path; print(path.basename(path.abspath(path.dirname('$0'))).replace('connection_', ''))")
+
+cd ../connection
+
+INVENTORY="../connection_${group}/test_connection.inventory" ./test.sh \
+ -e target_hosts="${group}" \
+ -e action_prefix= \
+ -e local_tmp=/tmp/ansible-local \
+ -e remote_tmp=/tmp/ansible-remote \
+ "$@"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/runme.sh b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/runme.sh
new file mode 100755
index 00000000..9b6a93d4
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/runme.sh
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+
+# If you use another image, you possibly also need to adjust
+# ansible_python_interpreter in test_connection.inventory.
+source ../setup_docker/vars/main.env
+IMAGE="${DOCKER_TEST_IMAGE_PYTHON3}"
+
+# Setup phase
+
+echo "Setup"
+ANSIBLE_ROLES_PATH=.. ansible-playbook setup.yml
+
+# If docker wasn't installed, don't run the tests
+if [ "$(command -v docker)" == "" ]; then
+ exit
+fi
+
+
+# Test phase
+
+CONTAINER_SUFFIX=-${RANDOM}
+
+DOCKER_CONTAINERS="docker-connection-test-container${CONTAINER_SUFFIX}"
+
+[[ -n "$DEBUG" || -n "$ANSIBLE_DEBUG" ]] && set -x
+
+set -euo pipefail
+
+cleanup() {
+ echo "Cleanup"
+ docker rm -f ${DOCKER_CONTAINERS}
+ echo "Shutdown"
+ ANSIBLE_ROLES_PATH=.. ansible-playbook shutdown.yml
+ echo "Done"
+ exit 0
+}
+
+trap cleanup INT TERM EXIT
+
+echo "Start containers"
+for CONTAINER in ${DOCKER_CONTAINERS}; do
+ if [ "${ANSIBLE_TEST_COVERAGE:-}" == "" ]; then
+ docker run --rm --name ${CONTAINER} --detach "${IMAGE}" /bin/sh -c 'sleep 10m'
+ else
+ docker run --rm --name ${CONTAINER} --detach -v /tmp:/tmp "${IMAGE}" /bin/sh -c 'sleep 10m'
+ docker exec ${CONTAINER} pip3 install coverage
+ fi
+ echo ${CONTAINER}
+done
+
+cat > test_connection.inventory << EOF
+[docker]
+docker-no-pipelining ansible_pipelining=false
+docker-pipelining ansible_pipelining=true
+
+[docker:vars]
+ansible_host=docker-connection-test-container${CONTAINER_SUFFIX}
+ansible_connection=community.docker.docker
+ansible_python_interpreter=/usr/local/bin/python3
+EOF
+
+echo "Run tests"
+./runme-connection.sh "$@"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/setup.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/setup.yml
new file mode 100644
index 00000000..a709d2c7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/setup.yml
@@ -0,0 +1,10 @@
+---
+- hosts: localhost
+ connection: local
+ vars:
+ docker_skip_cleanup: yes
+
+ tasks:
+ - name: Setup docker
+ import_role:
+ name: setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/shutdown.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/shutdown.yml
new file mode 100644
index 00000000..e01d1210
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker/shutdown.yml
@@ -0,0 +1,15 @@
+---
+- hosts: localhost
+ connection: local
+ vars:
+ docker_skip_cleanup: yes
+
+ tasks:
+ - name: Remove docker packages
+ action: "{{ ansible_facts.pkg_mgr }}"
+ args:
+ name:
+ - docker
+ - docker-ce
+ - docker-ce-cli
+ state: absent
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/aliases
new file mode 100644
index 00000000..8beddaed
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/aliases
@@ -0,0 +1,3 @@
+shippable/posix/group4
+skip/docker # coverage does not work if we're inside a docker container, since we cannot access this container's /tmp dir from the new container
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/runme-connection.sh b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/runme-connection.sh
new file mode 100755
index 00000000..d3976ff3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/runme-connection.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+set -eux
+
+# Connection tests for POSIX platforms use this script by linking to it from the appropriate 'connection_' target dir.
+# The name of the inventory group to test is extracted from the directory name following the 'connection_' prefix.
+
+group=$(python -c \
+ "from os import path; print(path.basename(path.abspath(path.dirname('$0'))).replace('connection_', ''))")
+
+cd ../connection
+
+INVENTORY="../connection_${group}/test_connection.inventory" ./test.sh \
+ -e target_hosts="${group}" \
+ -e action_prefix= \
+ -e local_tmp=/tmp/ansible-local \
+ -e remote_tmp=/tmp/ansible-remote \
+ "$@"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/runme.sh b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/runme.sh
new file mode 100755
index 00000000..8e486ac9
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/runme.sh
@@ -0,0 +1,63 @@
+#!/usr/bin/env bash
+
+# If you use another image, you possibly also need to adjust
+# ansible_python_interpreter in test_connection.inventory.
+source ../setup_docker/vars/main.env
+IMAGE="${DOCKER_TEST_IMAGE_PYTHON3}"
+
+# Setup phase
+
+echo "Setup"
+ANSIBLE_ROLES_PATH=.. ansible-playbook setup.yml
+
+# If docker wasn't installed, don't run the tests
+if [ "$(command -v docker)" == "" ]; then
+ exit
+fi
+
+
+# Test phase
+
+CONTAINER_SUFFIX=-${RANDOM}
+
+DOCKER_CONTAINERS="docker-connection-test-container${CONTAINER_SUFFIX}"
+
+[[ -n "$DEBUG" || -n "$ANSIBLE_DEBUG" ]] && set -x
+
+set -euo pipefail
+
+cleanup() {
+ echo "Cleanup"
+ docker rm -f ${DOCKER_CONTAINERS}
+ echo "Shutdown"
+ ANSIBLE_ROLES_PATH=.. ansible-playbook shutdown.yml
+ echo "Done"
+ exit 0
+}
+
+trap cleanup INT TERM EXIT
+
+echo "Start containers"
+for CONTAINER in ${DOCKER_CONTAINERS}; do
+ if [ "${ANSIBLE_TEST_COVERAGE:-}" == "" ]; then
+ docker run --rm --name ${CONTAINER} --detach "${IMAGE}" /bin/sh -c 'sleep 10m'
+ else
+ docker run --rm --name ${CONTAINER} --detach -v /tmp:/tmp "${IMAGE}" /bin/sh -c 'sleep 10m'
+ docker exec ${CONTAINER} pip3 install coverage
+ fi
+ echo ${CONTAINER}
+done
+
+cat > test_connection.inventory << EOF
+[docker_api]
+docker_api-no-pipelining ansible_pipelining=false
+docker_api-pipelining ansible_pipelining=true
+
+[docker_api:vars]
+ansible_host=docker-connection-test-container${CONTAINER_SUFFIX}
+ansible_connection=community.docker.docker_api
+ansible_python_interpreter=/usr/local/bin/python3
+EOF
+
+echo "Run tests"
+./runme-connection.sh "$@"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/setup.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/setup.yml
new file mode 100644
index 00000000..a709d2c7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/setup.yml
@@ -0,0 +1,10 @@
+---
+- hosts: localhost
+ connection: local
+ vars:
+ docker_skip_cleanup: yes
+
+ tasks:
+ - name: Setup docker
+ import_role:
+ name: setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/shutdown.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/shutdown.yml
new file mode 100644
index 00000000..e01d1210
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_docker_api/shutdown.yml
@@ -0,0 +1,15 @@
+---
+- hosts: localhost
+ connection: local
+ vars:
+ docker_skip_cleanup: yes
+
+ tasks:
+ - name: Remove docker packages
+ action: "{{ ansible_facts.pkg_mgr }}"
+ args:
+ name:
+ - docker
+ - docker-ce
+ - docker-ce-cli
+ state: absent
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_posix/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_posix/aliases
new file mode 100644
index 00000000..f5e09799
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_posix/aliases
@@ -0,0 +1,2 @@
+needs/target/connection
+hidden
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_posix/test.sh b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_posix/test.sh
new file mode 100755
index 00000000..d3976ff3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/connection_posix/test.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+set -eux
+
+# Connection tests for POSIX platforms use this script by linking to it from the appropriate 'connection_' target dir.
+# The name of the inventory group to test is extracted from the directory name following the 'connection_' prefix.
+
+group=$(python -c \
+ "from os import path; print(path.basename(path.abspath(path.dirname('$0'))).replace('connection_', ''))")
+
+cd ../connection
+
+INVENTORY="../connection_${group}/test_connection.inventory" ./test.sh \
+ -e target_hosts="${group}" \
+ -e action_prefix= \
+ -e local_tmp=/tmp/ansible-local \
+ -e remote_tmp=/tmp/ansible-remote \
+ "$@"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/aliases
new file mode 100644
index 00000000..cdf1b9b1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group3
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/tasks/main.yml
new file mode 100644
index 00000000..ea3fbde5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/tasks/main.yml
@@ -0,0 +1,11 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- include_tasks: test_docker_config.yml
+ when: docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.30', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_config tests!"
+ when: not(docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.30', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/tasks/test_docker_config.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/tasks/test_docker_config.yml
new file mode 100644
index 00000000..8220e8f5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_config/tasks/test_docker_config.yml
@@ -0,0 +1,139 @@
+---
+- block:
+ - shell: "docker info --format '{% raw %}{{json .}}{% endraw %}' | python -m json.tool"
+
+ - name: Make sure we're not already using Docker swarm
+ docker_swarm:
+ state: absent
+ force: true
+
+ - shell: "docker info --format '{% raw %}{{json .}}{% endraw %}' | python -m json.tool"
+
+ - name: Create a Swarm cluster
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address}}"
+
+ - name: Parameter name should be required
+ docker_config:
+ state: present
+ ignore_errors: yes
+ register: output
+
+ - name: assert failure when called with no name
+ assert:
+ that:
+ - 'output.failed'
+ - 'output.msg == "missing required arguments: name"'
+
+ - name: Test parameters
+ docker_config:
+ name: foo
+ state: present
+ ignore_errors: yes
+ register: output
+
+ - name: assert failure when called with no data
+ assert:
+ that:
+ - 'output.failed'
+ - 'output.msg == "state is present but all of the following are missing: data"'
+
+ - name: Create config
+ docker_config:
+ name: db_password
+ data: opensesame!
+ state: present
+ register: output
+
+ - name: Create variable config_id
+ set_fact:
+ config_id: "{{ output.config_id }}"
+
+ - name: Inspect config
+ command: "docker config inspect {{ config_id }}"
+ register: inspect
+ ignore_errors: yes
+
+ - debug: var=inspect
+
+ - name: assert config creation succeeded
+ assert:
+ that:
+ - "'db_password' in inspect.stdout"
+ - "'ansible_key' in inspect.stdout"
+ when: inspect is not failed
+ - assert:
+ that:
+ - "'is too new. Maximum supported API version is' in inspect.stderr"
+ when: inspect is failed
+
+ - name: Create config again
+ docker_config:
+ name: db_password
+ data: opensesame!
+ state: present
+ register: output
+
+ - name: assert create config is idempotent
+ assert:
+ that:
+ - not output.changed
+
+ - name: Create config again (base64)
+ docker_config:
+ name: db_password
+ data: b3BlbnNlc2FtZSE=
+ data_is_b64: true
+ state: present
+ register: output
+
+ - name: assert create config (base64) is idempotent
+ assert:
+ that:
+ - not output.changed
+
+ - name: Update config
+ docker_config:
+ name: db_password
+ data: newpassword!
+ state: present
+ register: output
+
+ - name: assert config was updated
+ assert:
+ that:
+ - output.changed
+ - output.config_id != config_id
+
+ - name: Remove config
+ docker_config:
+ name: db_password
+ state: absent
+
+ - name: Check that config is removed
+ command: "docker config inspect {{ config_id }}"
+ register: output
+ ignore_errors: yes
+
+ - name: assert config was removed
+ assert:
+ that:
+ - output.failed
+
+ - name: Remove config
+ docker_config:
+ name: db_password
+ state: absent
+ register: output
+
+ - name: assert remove config is idempotent
+ assert:
+ that:
+ - not output.changed
+
+ always:
+ - name: Remove a Swarm cluster
+ docker_swarm:
+ state: absent
+ force: true
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/aliases
new file mode 100644
index 00000000..6e8edef7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group5
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/files/env-file b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/files/env-file
new file mode 100644
index 00000000..b15f1b64
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/files/env-file
@@ -0,0 +1,2 @@
+TEST3=val3
+TEST4=val4
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/filter_plugins/ipaddr_tools.py b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/filter_plugins/ipaddr_tools.py
new file mode 100644
index 00000000..1b809aae
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/filter_plugins/ipaddr_tools.py
@@ -0,0 +1,34 @@
+# (c) 2020, Felix Fontein <felix@fontein.de>
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+from __future__ import absolute_import, division, print_function
+__metaclass__ = type
+
+from ansible_collections.community.crypto.plugins.module_utils.compat import ipaddress
+
+
+def _normalize_ipaddr(ipaddr):
+ return ipaddress.ip_address(ipaddr).compressed
+
+
+class FilterModule(object):
+ """ IP address and network manipulation filters """
+
+ def filters(self):
+ return {
+ 'normalize_ipaddr': _normalize_ipaddr,
+ }
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/main.yml
new file mode 100644
index 00000000..338e0b1c
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/main.yml
@@ -0,0 +1,43 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+# 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 }}"
+
+# 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/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/run-test.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/run-test.yml
new file mode 100644
index 00000000..a2999370
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/run-test.yml
@@ -0,0 +1,3 @@
+---
+- name: "Loading tasks from {{ item }}"
+ include_tasks: "{{ item }}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/comparisons.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/comparisons.yml
new file mode 100644
index 00000000..fadf4dc3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/comparisons.yml
@@ -0,0 +1,463 @@
+---
+- 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ hostname: example.com
+ register: value_1
+
+- name: value (change, ignore)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ groups:
+ - "1010"
+ - "1011"
+ register: set_1
+
+- name: set (change, ignore)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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 {{ docker_test_image_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: "{{ docker_test_image_hello_world }}"
+ source: pull
+
+- name: wildcard
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/compatibility.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/compatibility.yml
new file mode 100644
index 00000000..de8758aa
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/compatibility.yml
@@ -0,0 +1,118 @@
+---
+- 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ state: started
+ container_default_behavior: compatibility
+ register: start_2
+
+- name: Start container (idempotent)
+ docker_container:
+ name: "{{ cname }}"
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/image-ids.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/image-ids.yml
new file mode 100644
index 00000000..ff4a97a7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/image-ids.yml
@@ -0,0 +1,141 @@
+---
+- 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:
+ - "{{ docker_test_image_hello_world }}"
+ - "{{ docker_test_image_alpine }}"
+ loop_control:
+ loop_var: image
+
+- name: Get image ID of {{ docker_test_image_hello_world }} and {{ docker_test_image_alpine }} images
+ docker_image_info:
+ name:
+ - "{{ docker_test_image_hello_world }}"
+ - "{{ docker_test_image_alpine }}"
+ register: image_info
+
+- assert:
+ that:
+ - image_info.images | length == 2
+
+- name: Print image IDs
+ debug:
+ msg: "{{ docker_test_image_hello_world }}: {{ image_info.images[0].Id }}; {{ docker_test_image_alpine }}: {{ image_info.images[1].Id }}"
+
+- name: Create container with {{ docker_test_image_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 {{ docker_test_image_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 {{ docker_test_image_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 {{ docker_test_image_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: "{{ docker_test_image_alpine }}"
+ force_absent: yes
+ state: absent
+
+- name: Create container with {{ docker_test_image_alpine }} image via name (check mode, will pull, same image)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ name: "{{ cname }}"
+ state: present
+ register: create_5
+ check_mode: yes
+
+- name: Create container with {{ docker_test_image_alpine }} image via name (will pull, same image)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: Create container with {{ docker_test_image_digest_base }} image via old digest
+ docker_container:
+ image: "{{ docker_test_image_digest_base }}@sha256:{{ docker_test_image_digest_v1 }}"
+ name: "{{ cname }}"
+ state: present
+ force_kill: yes
+ register: digest_1
+
+- name: Create container with {{ docker_test_image_digest_base }} image via old digest (idempotent)
+ docker_container:
+ image: "{{ docker_test_image_digest_base }}@sha256:{{ docker_test_image_digest_v1 }}"
+ name: "{{ cname }}"
+ state: present
+ force_kill: yes
+ register: digest_2
+
+- name: Update container with {{ docker_test_image_digest_base }} image via new digest
+ docker_container:
+ image: "{{ docker_test_image_digest_base }}@sha256:{{ docker_test_image_digest_v2 }}"
+ 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/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/mounts-volumes.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/mounts-volumes.yml
new file mode 100644
index 00000000..dbb3967f
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/mounts-volumes.yml
@@ -0,0 +1,445 @@
+---
+- 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ volume_driver: local
+ state: started
+ register: volume_driver_1
+
+- name: volume_driver (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ volume_driver: local
+ state: started
+ register: volume_driver_2
+
+- name: volume_driver (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ volumes:
+ - "/tmp:/tmp"
+ register: volumes_3
+
+- name: volumes (more volumes)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/network.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/network.yml
new file mode 100644
index 00000000..9ef33643
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/network.yml
@@ -0,0 +1,747 @@
+---
+- 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_base: 10.{{ 16 + (240 | random) }}.{{ 16 + (240 | random) }}
+ subnet_ipv6_base: fdb6:feea:{{ '%0.4x:%0.4x' | format(65536 | random, 65536 | random) }}
+ # If netaddr would be installed on the controller, one could do:
+ # subnet_ipv4: "10.{{ 16 + (240 | random) }}.{{ 16 + (240 | random) }}.0/24"
+ # subnet_ipv6: "fdb6:feea:{{ '%0.4x:%0.4x' | format(65536 | random, 65536 | random) }}::/64"
+
+- set_fact:
+ subnet_ipv4: "{{ subnet_ipv4_base }}.0/24"
+ subnet_ipv6: "{{ subnet_ipv6_base }}::/64"
+ nname_3_ipv4_2: "{{ subnet_ipv4_base }}.2"
+ nname_3_ipv4_3: "{{ subnet_ipv4_base }}.3"
+ nname_3_ipv4_4: "{{ subnet_ipv4_base }}.4"
+ nname_3_ipv6_2: "{{ subnet_ipv6_base }}::2"
+ nname_3_ipv6_3: "{{ subnet_ipv6_base }}::3"
+ nname_3_ipv6_4: "{{ subnet_ipv6_base }}::4"
+ # If netaddr would be installed on the controller, one could do:
+ # nname_3_ipv4_2: "{{ subnet_ipv4 | ansible.netcommon.next_nth_usable(2) }}"
+ # nname_3_ipv4_3: "{{ subnet_ipv4 | ansible.netcommon.next_nth_usable(3) }}"
+ # nname_3_ipv4_4: "{{ subnet_ipv4 | ansible.netcommon.next_nth_usable(4) }}"
+ # nname_3_ipv6_2: "{{ subnet_ipv6 | ansible.netcommon.next_nth_usable(2) }}"
+ # nname_3_ipv6_3: "{{ subnet_ipv6 | ansible.netcommon.next_nth_usable(3) }}"
+ # nname_3_ipv6_4: "{{ subnet_ipv6 | ansible.netcommon.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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ network_mode: host
+ register: network_mode_1
+
+- name: network_mode (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ network_mode: host
+ register: network_mode_2
+
+- name: network_mode (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname_h1 }}"
+ state: started
+ register: cname_h1_id
+
+- name: network_mode (container mode)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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 | normalize_ipaddr == nname_3_ipv6_2 | normalize_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 | normalize_ipaddr == nname_3_ipv6_2 | normalize_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 | normalize_ipaddr == nname_3_ipv6_2 | normalize_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 | normalize_ipaddr == nname_3_ipv6_3 | normalize_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 | normalize_ipaddr == nname_3_ipv6_3 | normalize_ipaddr
+ - networks_5.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_3
+ - networks_5.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | normalize_ipaddr == nname_3_ipv6_3 | normalize_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 | normalize_ipaddr == nname_3_ipv6_3 | normalize_ipaddr
+ - networks_6.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_4
+ - networks_6.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | normalize_ipaddr == nname_3_ipv6_3 | normalize_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 | normalize_ipaddr == nname_3_ipv6_4 | normalize_ipaddr
+ - networks_7.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_4
+ - networks_7.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | normalize_ipaddr == nname_3_ipv6_4 | normalize_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 | normalize_ipaddr == nname_3_ipv6_4 | normalize_ipaddr
+ - networks_8.container.NetworkSettings.Networks[nname_3].IPAddress == nname_3_ipv4_4
+ - networks_8.container.NetworkSettings.Networks[nname_3].GlobalIPv6Address | normalize_ipaddr == nname_3_ipv6_4 | normalize_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/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/options.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/options.yml
new file mode 100644
index 00000000..0e169fbb
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/options.yml
@@ -0,0 +1,3905 @@
+---
+- 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ blkio_weight: 123
+ register: blkio_weight_1
+
+- name: blkio_weight (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ blkio_weight: 123
+ register: blkio_weight_2
+
+- name: blkio_weight (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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
+
+####################################################################
+## cgroup_parent ###################################################
+####################################################################
+
+- name: cgroup_parent
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ cgroup_parent: ''
+ register: cgroup_parent_1
+
+- name: cgroup_parent (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ cgroup_parent: ''
+ register: cgroup_parent_2
+
+- name: cleanup
+ docker_container:
+ name: "{{ cname }}"
+ state: absent
+ force_kill: yes
+ diff: no
+
+- assert:
+ that:
+ - cgroup_parent_1 is changed
+ - cgroup_parent_2 is not changed
+
+####################################################################
+## command #########################################################
+####################################################################
+
+- name: command
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -v -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ register: command_1
+
+- name: command (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -v -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ register: command_2
+
+- name: command (less parameters)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ cpu_period: 90000
+ state: started
+ register: cpu_period_1
+
+- name: cpu_period (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ cpu_period: 90000
+ state: started
+ register: cpu_period_2
+
+- name: cpu_period (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ cpu_quota: 150000
+ state: started
+ register: cpu_quota_1
+
+- name: cpu_quota (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ cpu_quota: 150000
+ state: started
+ register: cpu_quota_2
+
+- name: cpu_quota (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ cpu_shares: 900
+ state: started
+ register: cpu_shares_1
+
+- name: cpu_shares (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ cpu_shares: 900
+ state: started
+ register: cpu_shares_2
+
+- name: cpu_shares (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ cpuset_cpus: "0"
+ state: started
+ register: cpuset_cpus_1
+
+- name: cpuset_cpus (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ cpuset_cpus: "0"
+ state: started
+ register: cpuset_cpus_2
+
+- name: cpuset_cpus (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ cpuset_mems: "0"
+ state: started
+ register: cpuset_mems_1
+
+- name: cpuset_mems (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ cpuset_mems: "0"
+ state: started
+ register: cpuset_mems_2
+
+- name: cpuset_mems (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ cpus: 1
+ state: started
+ ignore_errors: yes
+ register: cpus_1
+
+- name: cpus (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ cpus: 1
+ state: started
+ ignore_errors: yes
+ register: cpus_2
+
+- name: cpus (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_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: "{{ docker_test_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: "{{ docker_test_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"
+ - detach_no_cleanup.status == 0
+ # - "'Hello from Docker!' in detach_no_cleanup.container.Output"
+ - detach_no_cleanup_cleanup is changed
+ - "'Output' in detach_cleanup.container"
+ - detach_cleanup.status == 0
+ # - "'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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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', '<')
+
+####################################################################
+## device_requests #################################################
+####################################################################
+
+- name: device_requests
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ device_requests: []
+ register: device_requests_1
+ ignore_errors: yes
+
+- name: device_requests (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ device_requests: []
+ register: device_requests_2
+ ignore_errors: yes
+
+- name: cleanup
+ docker_container:
+ name: "{{ cname }}"
+ state: absent
+ force_kill: yes
+ diff: no
+
+- assert:
+ that:
+ - device_requests_1 is changed
+ - device_requests_2 is not changed
+ when: docker_py_version is version('4.3.0', '>=') and docker_api_version is version('1.40', '>=')
+- assert:
+ that:
+ - device_requests_1 is failed
+ - |
+ (('version is ' ~ docker_py_version ~ ' ') in device_requests_1.msg and 'Minimum version required is 4.3.0 ' in device_requests_1.msg) or
+ (('API version is ' ~ docker_api_version ~ '.') in device_requests_1.msg and 'Minimum version required is 1.40 ' in device_requests_1.msg)
+ when: docker_py_version is version('4.3.0', '<') or docker_api_version is version('1.40', '<')
+
+####################################################################
+## dns_opts ########################################################
+####################################################################
+
+- name: dns_opts
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ domainname: example.com
+ state: started
+ register: domainname_1
+
+- name: domainname (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ domainname: example.com
+ state: started
+ register: domainname_2
+
+- name: domainname (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ entrypoint:
+ - /bin/sh
+ - "-v"
+ - "-c"
+ - "'sleep 10m'"
+ name: "{{ cname }}"
+ state: started
+ register: entrypoint_1
+
+- name: entrypoint (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ entrypoint:
+ - /bin/sh
+ - "-c"
+ - "'sleep 10m'"
+ - "-v"
+ name: "{{ cname }}"
+ state: started
+ force_kill: yes
+ register: entrypoint_3
+
+- name: entrypoint (less parameters)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ entrypoint:
+ - /bin/sh
+ - "-c"
+ - "'sleep 10m'"
+ name: "{{ cname }}"
+ state: started
+ force_kill: yes
+ register: entrypoint_4
+
+- name: entrypoint (other parameters)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ env:
+ TEST1: val1
+ register: env_3
+
+- name: env (more environment variables)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ groups:
+ - "1234"
+ - "5678"
+ register: groups_1
+
+- name: groups (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ groups:
+ - "5678"
+ - "1234"
+ register: groups_2
+
+- name: groups (less groups)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ groups:
+ - "1234"
+ register: groups_3
+
+- name: groups (more groups)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ hostname: me.example.com
+ state: started
+ register: hostname_1
+
+- name: hostname (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ hostname: me.example.com
+ state: started
+ register: hostname_2
+
+- name: hostname (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ init: yes
+ state: started
+ register: init_1
+ ignore_errors: yes
+
+- name: init (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ init: yes
+ state: started
+ register: init_2
+ ignore_errors: yes
+
+- name: init (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ interactive: yes
+ state: started
+ register: interactive_1
+
+- name: interactive (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ interactive: yes
+ state: started
+ register: interactive_2
+
+- name: interactive (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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 {{ docker_test_image_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: "{{ docker_test_image_hello_world }}"
+ source: pull
+
+- name: image
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ register: image_1
+
+- name: image (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ register: image_2
+
+- name: ignore_image
+ docker_container:
+ image: "{{ docker_test_image_hello_world }}"
+ ignore_image: yes
+ name: "{{ cname }}"
+ state: started
+ register: ignore_image
+
+- name: image change
+ docker_container:
+ image: "{{ docker_test_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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ links:
+ - "{{ cname_h1 }}:test1"
+ register: links_3
+
+- name: links (more links)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ memory: 64M
+ state: started
+ register: memory_1
+
+- name: memory (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ memory: 64M
+ state: started
+ register: memory_2
+
+- name: memory (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ memory_reservation: 64M
+ state: started
+ register: memory_reservation_1
+
+- name: memory_reservation (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ memory_reservation: 64M
+ state: started
+ register: memory_reservation_2
+
+- name: memory_reservation (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ memory_swappiness: 40
+ state: started
+ register: memory_swappiness_1
+
+- name: memory_swappiness (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ memory_swappiness: 40
+ state: started
+ register: memory_swappiness_2
+
+- name: memory_swappiness (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ oom_killer: yes
+ state: started
+ register: oom_killer_1
+
+- name: oom_killer (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ oom_killer: yes
+ state: started
+ register: oom_killer_2
+
+- name: oom_killer (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: "/bin/sh -c 'sleep 10m'"
+ name: "{{ cname }}"
+ state: started
+ paused: yes
+ force_kill: yes
+ register: paused_3
+
+- name: paused (continue)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname_h1 }}"
+ state: started
+ register: pid_mode_helper
+
+- name: pid_mode
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ privileged: yes
+ state: started
+ register: privileged_1
+
+- name: privileged (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ privileged: yes
+ state: started
+ register: privileged_2
+
+- name: privileged (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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 and default_host_ip #############################
+####################################################################
+
+- name: published_ports
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ published_ports:
+ - '127.0.0.1:9002:9002/tcp'
+ - '[::1]:9003:9003/tcp'
+ - '[fe80::1%test]:90:90/tcp'
+ force_kill: yes
+ register: published_ports_5
+
+- name: published_ports (ports with IP addresses, idempotent)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ published_ports:
+ - '127.0.0.1:9002:9002/tcp'
+ - '[::1]:9003:9003/tcp'
+ - '[fe80::1%test]:90:90/tcp'
+ register: published_ports_6
+
+- name: published_ports (no published ports)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ published_ports: []
+ comparisons:
+ published_ports: strict
+ force_kill: yes
+ register: published_ports_7
+
+- name: published_ports (default_host_ip not set)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ published_ports:
+ - '9001'
+ - '9002'
+ force_kill: yes
+ register: published_ports_8
+
+- name: published_ports (default_host_ip set to empty string)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ published_ports:
+ - '9002'
+ - '9001'
+ default_host_ip: ''
+ force_kill: yes
+ register: published_ports_9
+
+- name: published_ports (default_host_ip set to empty string, idempotent)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ published_ports:
+ - '9002'
+ - '9001'
+ default_host_ip: ''
+ register: published_ports_10
+
+- name: published_ports (default_host_ip unset)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ published_ports:
+ - '9002'
+ - '9001'
+ force_kill: yes
+ register: published_ports_11
+
+- 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
+ - published_ports_6 is not changed
+ - published_ports_7 is changed
+ - published_ports_8 is changed
+ - published_ports_9 is changed
+ - published_ports_10 is not changed
+ - published_ports_11 is changed
+
+####################################################################
+## pull ############################################################
+####################################################################
+
+# TODO: - pull
+
+####################################################################
+## read_only #######################################################
+####################################################################
+
+- name: read_only
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ read_only: yes
+ state: started
+ register: read_only_1
+
+- name: read_only (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ read_only: yes
+ state: started
+ register: read_only_2
+
+- name: read_only (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ restart_policy: always
+ state: started
+ register: restart_policy_1
+
+- name: restart_policy (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ restart_policy: always
+ state: started
+ register: restart_policy_2
+
+- name: restart_policy (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ runtime: runc
+ state: started
+ register: runtime_1
+ ignore_errors: yes
+
+- name: runtime (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ shm_size: 96M
+ state: started
+ register: shm_size_1
+
+- name: shm_size (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ shm_size: 96M
+ state: started
+ register: shm_size_2
+
+- name: shm_size (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ stop_signal: "30"
+ state: started
+ register: stop_signal_1
+
+- name: stop_signal (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ stop_signal: "30"
+ state: started
+ register: stop_signal_2
+
+- name: stop_signal (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ stop_timeout: 2
+ state: started
+ register: stop_timeout_1
+
+- name: stop_timeout (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ tty: yes
+ state: started
+ register: tty_1
+
+- name: tty (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ tty: yes
+ state: started
+ register: tty_2
+
+- name: tty (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ ulimits:
+ - "nofile:1234:1234"
+ register: ulimits_3
+
+- name: ulimits (more ulimits)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ user: nobody
+ state: started
+ register: user_1
+
+- name: user (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ user: nobody
+ state: started
+ register: user_2
+
+- name: user (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ uts: host
+ state: started
+ register: uts_1
+ ignore_errors: yes
+
+- name: uts (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ uts: host
+ state: started
+ register: uts_2
+ ignore_errors: yes
+
+- name: uts (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ working_dir: /tmp
+ state: started
+ register: working_dir_1
+
+- name: working_dir (idempotency)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ working_dir: /tmp
+ state: started
+ register: working_dir_2
+
+- name: working_dir (change)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/ports.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/ports.yml
new file mode 100644
index 00000000..895cd236
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/ports.yml
@@ -0,0 +1,286 @@
+---
+- 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/regression-45700-dont-parse-on-absent.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/regression-45700-dont-parse-on-absent.yml
new file mode 100644
index 00000000..d5150153
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/regression-45700-dont-parse-on-absent.yml
@@ -0,0 +1,34 @@
+---
+# 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: "{{ docker_test_image_alpine }}"
+ 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/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/start-stop.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/start-stop.yml
new file mode 100644
index 00000000..ec9de7c5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container/tasks/tests/start-stop.yml
@@ -0,0 +1,455 @@
+---
+- 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: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: present
+ check_mode: yes
+ register: create_1
+
+- name: Create container
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: present
+ register: create_2
+
+- name: Create container (idempotent)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: present
+ register: create_3
+
+- name: Create container (idempotent check)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ name: "{{ cname }}"
+ state: stopped
+ stop_timeout: 1
+ check_mode: yes
+ register: stop_1
+
+- name: Stop container
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ name: "{{ cname }}"
+ state: stopped
+ stop_timeout: 1
+ register: stop_2
+
+- name: Stop container (idempotent)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ name: "{{ cname }}"
+ state: stopped
+ stop_timeout: 1
+ register: stop_3
+
+- name: Stop container (idempotent check)
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ 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: "{{ docker_test_image_alpine }}"
+ 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
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container_info/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container_info/aliases
new file mode 100644
index 00000000..6e8edef7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container_info/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group5
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container_info/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container_info/tasks/main.yml
new file mode 100644
index 00000000..8ecf2de3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_container_info/tasks/main.yml
@@ -0,0 +1,80 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- block:
+ - name: Create random container name
+ set_fact:
+ cname: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
+
+ - name: Make sure container is not there
+ docker_container:
+ name: "{{ cname }}"
+ state: absent
+ force_kill: yes
+
+ - name: Inspect a non-present container
+ docker_container_info:
+ name: "{{ cname }}"
+ register: result
+
+ - assert:
+ that:
+ - "not result.exists"
+ - "'container' in result"
+ - "result.container is none"
+
+ - name: Make sure container exists
+ docker_container:
+ name: "{{ cname }}"
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ state: started
+ force_kill: yes
+
+ - name: Inspect a present container
+ docker_container_info:
+ name: "{{ cname }}"
+ register: result
+ - name: Dump docker_container_info result
+ debug: var=result
+
+ - name: "Comparison: use 'docker inspect'"
+ command: docker inspect "{{ cname }}"
+ register: docker_inspect
+ ignore_errors: yes
+ - block:
+ - set_fact:
+ docker_inspect_result: "{{ docker_inspect.stdout | from_json }}"
+ - name: Dump docker inspect result
+ debug: var=docker_inspect_result
+ when: docker_inspect is not failed
+
+ - assert:
+ that:
+ - result.exists
+ - "'container' in result"
+ - "result.container"
+
+ - assert:
+ that:
+ - "result.container == docker_inspect_result[0]"
+ when: docker_inspect is not failed
+ - assert:
+ that:
+ - "'is too new. Maximum supported API version is' in docker_inspect.stderr"
+ when: docker_inspect is failed
+
+ always:
+ - name: Cleanup
+ docker_container:
+ name: "{{ cname }}"
+ state: absent
+ force_kill: yes
+
+ 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 docker_container_info tests!"
+ when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/aliases
new file mode 100644
index 00000000..02b78723
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group4
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/tasks/main.yml
new file mode 100644
index 00000000..1f0e10a5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/tasks/main.yml
@@ -0,0 +1,10 @@
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- include_tasks: test_host_info.yml
+ when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.21', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_host_info tests!"
+ when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.21', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/tasks/test_host_info.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/tasks/test_host_info.yml
new file mode 100644
index 00000000..ef2a58a6
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_host_info/tasks/test_host_info.yml
@@ -0,0 +1,296 @@
+---
+- name: Create random container/volume name
+ set_fact:
+ cname: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
+ vname: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
+
+- debug:
+ msg: "Using container name '{{ cname }}' and volume name '{{ vname }}'"
+
+- block:
+ - name: Get info on Docker host
+ docker_host_info:
+ register: output
+
+ - name: assert reading docker host facts when docker is running
+ assert:
+ that:
+ - 'output.host_info.Name is string'
+ - 'output.containers is not defined'
+ - 'output.networks is not defined'
+ - 'output.volumes is not defined'
+ - 'output.images is not defined'
+ - 'output.disk_usage is not defined'
+
+# Container and volume are created so that all lists are non-empty:
+# * container and volume lists are non-emtpy because of the created objects;
+# * image list is non-empty because the image of the container is there;
+# * network list is always non-empty (default networks).
+ - name: Create container
+ docker_container:
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -c "sleep 10m"'
+ name: "{{ cname }}"
+ state: started
+ register: container_output
+
+ - assert:
+ that:
+ - container_output is changed
+
+ - name: Create a volume
+ docker_volume:
+ name: "{{ vname }}"
+ register: volume_output
+
+ - assert:
+ that:
+ - volume_output is changed
+
+ - name: Get info on Docker host and list containers
+ docker_host_info:
+ containers: yes
+ register: output
+
+ - name: assert reading docker host facts when docker is running and list containers
+ assert:
+ that:
+ - 'output.host_info.Name is string'
+ - 'output.networks is not defined'
+ - 'output.volumes is not defined'
+ - 'output.images is not defined'
+ - 'output.disk_usage is not defined'
+ - 'output.containers[0].Image is string'
+ - 'output.containers[0].ImageID is not defined'
+
+ - name: Get info on Docker host and list containers with verbose output
+ docker_host_info:
+ containers: yes
+ verbose_output: yes
+ register: output
+
+ - name: assert reading docker host facts when docker is running and list containers with verbose output
+ assert:
+ that:
+ - 'output.host_info.Name is string'
+ - 'output.networks is not defined'
+ - 'output.volumes is not defined'
+ - 'output.images is not defined'
+ - 'output.disk_usage is not defined'
+ - 'output.containers[0].Image is string'
+ - 'output.containers[0].ImageID is string'
+
+ - name: Get info on Docker host and list images
+ docker_host_info:
+ images: yes
+ register: output
+
+ - name: assert reading docker host facts when docker is running and list images
+ assert:
+ that:
+ - 'output.host_info.Name is string'
+ - 'output.containers is not defined'
+ - 'output.networks is not defined'
+ - 'output.volumes is not defined'
+ - 'output.images[0].Id is string'
+ - 'output.images[0].ParentId is not defined'
+ - 'output.disk_usage is not defined'
+
+ - name: Get info on Docker host and list images with verbose output
+ docker_host_info:
+ images: yes
+ verbose_output: yes
+ register: output
+
+ - name: assert reading docker host facts when docker is running and list images with verbose output
+ assert:
+ that:
+ - 'output.host_info.Name is string'
+ - 'output.containers is not defined'
+ - 'output.networks is not defined'
+ - 'output.volumes is not defined'
+ - 'output.images[0].Id is string'
+ - 'output.images[0].ParentId is string'
+ - 'output.disk_usage is not defined'
+
+ - name: Get info on Docker host and list networks
+ docker_host_info:
+ networks: yes
+ register: output
+
+ - name: assert reading docker host facts when docker is running and list networks
+ assert:
+ that:
+ - 'output.host_info.Name is string'
+ - 'output.containers is not defined'
+ - 'output.networks[0].Id is string'
+ - 'output.networks[0].Created is not defined'
+ - 'output.volumes is not defined'
+ - 'output.images is not defined'
+ - 'output.disk_usage is not defined'
+
+ - name: Get info on Docker host and list networks with verbose output
+ docker_host_info:
+ networks: yes
+ verbose_output: yes
+ register: output
+
+ - name: assert reading docker host facts when docker is running and list networks with verbose output
+ assert:
+ that:
+ - 'output.host_info.Name is string'
+ - 'output.containers is not defined'
+ - 'output.networks[0].Id is string'
+ - 'output.networks[0].Created is string'
+ - 'output.volumes is not defined'
+ - 'output.images is not defined'
+ - 'output.disk_usage is not defined'
+
+ - name: Get info on Docker host and list volumes
+ docker_host_info:
+ volumes: yes
+ register: output
+
+ - name: assert reading docker host facts when docker is running and list volumes
+ assert:
+ that:
+ - 'output.host_info.Name is string'
+ - 'output.containers is not defined'
+ - 'output.networks is not defined'
+ - 'output.volumes[0].Name is string'
+ - 'output.volumes[0].Mountpoint is not defined'
+ - 'output.images is not defined'
+ - 'output.disk_usage is not defined'
+
+ - name: Get info on Docker host and list volumes with verbose output
+ docker_host_info:
+ volumes: yes
+ verbose_output: yes
+ register: output
+
+ - name: assert reading docker host facts when docker is running and list volumes with verbose output
+ assert:
+ that:
+ - 'output.host_info.Name is string'
+ - 'output.containers is not defined'
+ - 'output.networks is not defined'
+ - 'output.volumes[0].Name is string'
+ - 'output.volumes[0].Mountpoint is string'
+ - 'output.images is not defined'
+ - 'output.disk_usage is not defined'
+
+ - name: Get info on Docker host and get disk usage
+ docker_host_info:
+ disk_usage: yes
+ register: output
+ ignore_errors: yes
+
+ - name: assert reading docker host facts when docker is running and get disk usage
+ assert:
+ that:
+ - 'output.host_info.Name is string'
+ - 'output.containers is not defined'
+ - 'output.networks is not defined'
+ - 'output.volumes is not defined'
+ - 'output.images is not defined'
+ - 'output.disk_usage.LayersSize is number'
+ - 'output.disk_usage.BuilderSize is not defined'
+ when: docker_py_version is version('2.2.0', '>=')
+ - assert:
+ that:
+ - output is failed
+ - "('version is ' ~ docker_py_version ~ ' ') in output.msg"
+ - "'Minimum version required is 2.2.0 ' in output.msg"
+ when: docker_py_version is version('2.2.0', '<')
+
+ - name: Get info on Docker host and get disk usage with verbose output
+ docker_host_info:
+ disk_usage: yes
+ verbose_output: yes
+ register: output
+ ignore_errors: yes
+
+ - name: assert reading docker host facts when docker is running and get disk usage with verbose output
+ assert:
+ that:
+ - 'output.host_info.Name is string'
+ - 'output.containers is not defined'
+ - 'output.networks is not defined'
+ - 'output.volumes is not defined'
+ - 'output.images is not defined'
+ - 'output.disk_usage.LayersSize is number'
+ - 'output.disk_usage.BuilderSize is number'
+ when: docker_py_version is version('2.2.0', '>=')
+ - assert:
+ that:
+ - output is failed
+ - "('version is ' ~ docker_py_version ~ ' ') in output.msg"
+ - "'Minimum version required is 2.2.0 ' in output.msg"
+ when: docker_py_version is version('2.2.0', '<')
+
+ - name: Get info on Docker host, disk usage and get all lists together
+ docker_host_info:
+ volumes: yes
+ containers: yes
+ networks: yes
+ images: yes
+ disk_usage: "{{ docker_py_version is version('2.2.0', '>=') }}"
+ register: output
+
+ - name: assert reading docker host facts when docker is running, disk usage and get lists together
+ assert:
+ that:
+ - 'output.host_info.Name is string'
+ - 'output.containers[0].Image is string'
+ - 'output.containers[0].ImageID is not defined'
+ - 'output.networks[0].Id is string'
+ - 'output.networks[0].Created is not defined'
+ - 'output.volumes[0].Name is string'
+ - 'output.volumes[0].Mountpoint is not defined'
+ - 'output.images[0].Id is string'
+ - 'output.images[0].ParentId is not defined'
+ - assert:
+ that:
+ - 'output.disk_usage.LayersSize is number'
+ - 'output.disk_usage.BuilderSize is not defined'
+ when: docker_py_version is version('2.2.0', '>=')
+
+ - name: Get info on Docker host, disk usage and get all lists together with verbose output
+ docker_host_info:
+ volumes: yes
+ containers: yes
+ networks: yes
+ images: yes
+ disk_usage: "{{ docker_py_version is version('2.2.0', '>=') }}"
+ verbose_output: yes
+ register: output
+
+ - name: assert reading docker host facts when docker is running and get disk usage with verbose output
+ assert:
+ that:
+ - 'output.host_info.Name is string'
+ - 'output.containers[0].Image is string'
+ - 'output.containers[0].ImageID is string'
+ - 'output.networks[0].Id is string'
+ - 'output.networks[0].Created is string'
+ - 'output.volumes[0].Name is string'
+ - 'output.volumes[0].Mountpoint is string'
+ - 'output.images[0].Id is string'
+ - 'output.images[0].ParentId is string'
+ - assert:
+ that:
+ - 'output.disk_usage.LayersSize is number'
+ - 'output.disk_usage.BuilderSize is number'
+ when: docker_py_version is version('2.2.0', '>=')
+
+ always:
+ - name: Delete container
+ docker_container:
+ name: "{{ cname }}"
+ state: absent
+ force_kill: yes
+
+ - name: Delete volume
+ docker_volume:
+ name: "{{ vname }}"
+ state: absent
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/aliases
new file mode 100644
index 00000000..02b78723
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group4
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/meta/main.yml
new file mode 100644
index 00000000..21d7a58f
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker_registry
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/main.yml
new file mode 100644
index 00000000..2be493eb
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/main.yml
@@ -0,0 +1,8 @@
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- when: ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['CentOS6', 'RedHat6']
+ include_tasks:
+ file: test.yml
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/run-test.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/run-test.yml
new file mode 100644
index 00000000..a2999370
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/run-test.yml
@@ -0,0 +1,3 @@
+---
+- name: "Loading tasks from {{ item }}"
+ include_tasks: "{{ item }}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/test.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/test.yml
new file mode 100644
index 00000000..023f8ccd
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/test.yml
@@ -0,0 +1,49 @@
+---
+- name: Create random name prefix
+ set_fact:
+ name_prefix: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
+- name: Create image and container list
+ set_fact:
+ inames: []
+ cnames: []
+
+- debug:
+ msg: "Using name prefix {{ name_prefix }}"
+
+- name: Create files directory
+ file:
+ path: '{{ output_dir }}/files'
+ state: directory
+
+- name: Template files
+ template:
+ src: '{{ item }}'
+ dest: '{{ output_dir }}/files/{{ item }}'
+ loop:
+ - Dockerfile
+ - EtcHostsDockerfile
+ - MyDockerfile
+ - StagedDockerfile
+
+- block:
+ - include_tasks: run-test.yml
+ with_fileglob:
+ - "tests/*.yml"
+
+ always:
+ - name: "Make sure all images are removed"
+ docker_image:
+ name: "{{ item }}"
+ state: absent
+ with_items: "{{ inames }}"
+ - name: "Make sure all containers are removed"
+ docker_container:
+ name: "{{ item }}"
+ state: absent
+ force_kill: yes
+ with_items: "{{ cnames }}"
+
+ 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 docker_image tests!"
+ when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/tests/basic.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/tests/basic.yml
new file mode 100644
index 00000000..23a0e148
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/tests/basic.yml
@@ -0,0 +1,78 @@
+---
+####################################################################
+## basic ###########################################################
+####################################################################
+
+- name: Make sure image is not there
+ docker_image:
+ name: "{{ docker_test_image_hello_world }}"
+ state: absent
+ force_absent: yes
+ register: absent_1
+
+- name: Make sure image is not there (idempotency)
+ docker_image:
+ name: "{{ docker_test_image_hello_world }}"
+ state: absent
+ register: absent_2
+
+- assert:
+ that:
+ - absent_2 is not changed
+
+- name: Make sure image is there
+ docker_image:
+ name: "{{ docker_test_image_hello_world }}"
+ state: present
+ source: pull
+ register: present_1
+
+- name: Make sure image is there (idempotent)
+ docker_image:
+ name: "{{ docker_test_image_hello_world }}"
+ state: present
+ source: pull
+ register: present_2
+
+- assert:
+ that:
+ - present_1 is changed
+ - present_2 is not changed
+
+- name: Make sure tag is not there
+ docker_image:
+ name: "{{ docker_test_image_hello_world_base }}:alias"
+ state: absent
+
+- name: Tag image with alias
+ docker_image:
+ source: local
+ name: "{{ docker_test_image_hello_world }}"
+ repository: "{{ docker_test_image_hello_world_base }}:alias"
+ register: tag_1
+
+- name: Tag image with alias (idempotent)
+ docker_image:
+ source: local
+ name: "{{ docker_test_image_hello_world }}"
+ repository: "{{ docker_test_image_hello_world_base }}:alias"
+ register: tag_2
+
+- name: Tag image with alias (force, still idempotent)
+ docker_image:
+ source: local
+ name: "{{ docker_test_image_hello_world }}"
+ repository: "{{ docker_test_image_hello_world_base }}:alias"
+ force_tag: yes
+ register: tag_3
+
+- assert:
+ that:
+ - tag_1 is changed
+ - tag_2 is not changed
+ - tag_3 is not changed
+
+- name: Cleanup alias tag
+ docker_image:
+ name: "{{ docker_test_image_hello_world_base }}:alias"
+ state: absent
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/tests/docker_image.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/tests/docker_image.yml
new file mode 100644
index 00000000..f256f8d8
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/tests/docker_image.yml
@@ -0,0 +1,228 @@
+---
+- name: Registering image name
+ set_fact:
+ iname: "{{ name_prefix ~ '-options' }}"
+
+- name: Determining pushed image names
+ set_fact:
+ hello_world_image_base: "{{ registry_address }}/test/hello-world"
+ test_image_base: "{{ registry_address }}/test/{{ iname }}"
+
+- name: Registering image name
+ set_fact:
+ inames: "{{ inames + [iname, test_image_base ~ ':latest', hello_world_image_base ~ ':latest', hello_world_image_base ~ ':newtag', hello_world_image_base ~ ':newtag2'] }}"
+
+####################################################################
+## interact with test registry #####################################
+####################################################################
+
+- name: Make sure image is not there
+ docker_image:
+ name: "{{ hello_world_image_base }}:latest"
+ state: absent
+ force_absent: yes
+
+- name: Make sure we have {{ docker_test_image_hello_world }}
+ docker_image:
+ name: "{{ docker_test_image_hello_world }}"
+ source: pull
+
+- name: Push image to test registry
+ docker_image:
+ name: "{{ docker_test_image_hello_world }}"
+ repository: "{{ hello_world_image_base }}:latest"
+ push: yes
+ source: local
+ register: push_1
+
+- name: Push image to test registry (idempotent)
+ docker_image:
+ name: "{{ docker_test_image_hello_world }}"
+ repository: "{{ hello_world_image_base }}:latest"
+ push: yes
+ source: local
+ register: push_2
+
+- name: Push image to test registry (force, still idempotent)
+ docker_image:
+ name: "{{ docker_test_image_hello_world }}"
+ repository: "{{ hello_world_image_base }}:latest"
+ push: yes
+ source: local
+ force_tag: yes
+ register: push_3
+
+- assert:
+ that:
+ - push_1 is changed
+ - push_2 is not changed
+ - push_3 is not changed
+
+- name: Get facts of local image
+ docker_image_info:
+ name: "{{ hello_world_image_base }}:latest"
+ register: facts_1
+
+- name: Make sure image is not there
+ docker_image:
+ name: "{{ hello_world_image_base }}:latest"
+ state: absent
+ force_absent: yes
+
+- name: Get facts of local image (absent)
+ docker_image_info:
+ name: "{{ hello_world_image_base }}:latest"
+ register: facts_2
+
+- name: Pull image from test registry
+ docker_image:
+ name: "{{ hello_world_image_base }}:latest"
+ state: present
+ source: pull
+ register: pull_1
+
+- name: Pull image from test registry (idempotency)
+ docker_image:
+ name: "{{ hello_world_image_base }}:latest"
+ state: present
+ source: pull
+ register: pull_2
+
+- name: Get facts of local image (present)
+ docker_image_info:
+ name: "{{ hello_world_image_base }}:latest"
+ register: facts_3
+
+- assert:
+ that:
+ - pull_1 is changed
+ - pull_2 is not changed
+ - facts_1.images | length == 1
+ - facts_2.images | length == 0
+ - facts_3.images | length == 1
+
+- name: Tag different image with new tag
+ docker_image:
+ name: "{{ docker_test_image_alpine_different }}"
+ repository: "{{ hello_world_image_base }}:newtag"
+ push: no
+ source: pull
+
+- name: Push different image with new tag
+ docker_image:
+ name: "{{ hello_world_image_base }}"
+ repository: "{{ hello_world_image_base }}"
+ tag: newtag
+ push: yes
+ source: local
+ register: push_1_different
+
+- name: Push different image with new tag (idempotent)
+ docker_image:
+ name: "{{ hello_world_image_base }}"
+ repository: "{{ hello_world_image_base }}"
+ tag: newtag
+ push: yes
+ source: local
+ register: push_2_different
+
+- assert:
+ that:
+ - push_1_different is changed
+ - push_2_different is not changed
+
+- name: Tag same image with new tag
+ docker_image:
+ name: "{{ docker_test_image_alpine_different }}"
+ repository: "{{ hello_world_image_base }}:newtag2"
+ push: no
+ source: pull
+
+- name: Push same image with new tag
+ docker_image:
+ name: "{{ hello_world_image_base }}"
+ repository: "{{ hello_world_image_base }}"
+ tag: newtag2
+ push: yes
+ source: local
+ register: push_1_same
+
+- name: Push same image with new tag (idempotent)
+ docker_image:
+ name: "{{ hello_world_image_base }}"
+ repository: "{{ hello_world_image_base }}"
+ tag: newtag2
+ push: yes
+ source: local
+ register: push_2_same
+
+- assert:
+ that:
+ # NOTE: This should be:
+ # - push_1_same is changed
+ # Unfortunately docker does *NOT* report whether the tag already existed or not.
+ # Here are the logs returned by client.push() for both tasks (which are exactly the same):
+ # push_1_same:
+ # {"status": "The push refers to repository [localhost:32796/test/hello-world]"},
+ # {"id": "3fc64803ca2d", "progressDetail": {}, "status": "Preparing"},
+ # {"id": "3fc64803ca2d", "progressDetail": {}, "status": "Layer already exists"},
+ # {"status": "newtag2: digest: sha256:92251458088c638061cda8fd8b403b76d661a4dc6b7ee71b6affcf1872557b2b size: 528"},
+ # {"aux": {"Digest": "sha256:92251458088c638061cda8fd8b403b76d661a4dc6b7ee71b6affcf1872557b2b", "Size": 528, "Tag": "newtag2"}, "progressDetail": {}}
+ # push_2_same:
+ # {"status": "The push refers to repository [localhost:32796/test/hello-world]"},
+ # {"id": "3fc64803ca2d", "progressDetail": {}, "status": "Preparing"},
+ # {"id": "3fc64803ca2d", "progressDetail": {}, "status": "Layer already exists"},
+ # {"status": "newtag2: digest: sha256:92251458088c638061cda8fd8b403b76d661a4dc6b7ee71b6affcf1872557b2b size: 528"},
+ # {"aux": {"Digest": "sha256:92251458088c638061cda8fd8b403b76d661a4dc6b7ee71b6affcf1872557b2b", "Size": 528, "Tag": "newtag2"}, "progressDetail": {}}
+ - push_1_same is not changed
+ - push_2_same is not changed
+
+####################################################################
+## repository ######################################################
+####################################################################
+
+- name: Make sure image is not there
+ docker_image:
+ name: "{{ test_image_base }}:latest"
+ state: absent
+ force_absent: yes
+
+- name: repository
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ pull: no
+ repository: "{{ test_image_base }}"
+ source: build
+ register: repository_1
+
+- name: repository (idempotent)
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ pull: no
+ repository: "{{ test_image_base }}"
+ source: build
+ register: repository_2
+
+- assert:
+ that:
+ - repository_1 is changed
+ - repository_2 is not changed
+
+- name: Get facts of image
+ docker_image_info:
+ name: "{{ test_image_base }}:latest"
+ register: facts_1
+
+- name: cleanup
+ docker_image:
+ name: "{{ test_image_base }}:latest"
+ state: absent
+ force_absent: yes
+
+- assert:
+ that:
+ - facts_1.images | length == 1
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/tests/options.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/tests/options.yml
new file mode 100644
index 00000000..a966ea2c
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/tasks/tests/options.yml
@@ -0,0 +1,389 @@
+---
+- name: Registering image name
+ set_fact:
+ iname: "{{ name_prefix ~ '-options' }}"
+ iname_1: "{{ name_prefix ~ '-options-1' }}"
+
+- name: Registering image name
+ set_fact:
+ inames: "{{ inames + [iname, iname_1] }}"
+
+####################################################################
+## build.args ######################################################
+####################################################################
+
+- name: cleanup
+ docker_image:
+ name: "{{ iname }}"
+ state: absent
+ force_absent: yes
+
+- name: buildargs
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ args:
+ TEST1: val1
+ TEST2: val2
+ TEST3: "True"
+ pull: no
+ source: build
+ register: buildargs_1
+ ignore_errors: yes
+
+- name: buildargs (idempotency)
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ args:
+ TEST1: val1
+ TEST2: val2
+ TEST3: "True"
+ pull: no
+ source: build
+ register: buildargs_2
+ ignore_errors: yes
+
+- name: cleanup
+ docker_image:
+ name: "{{ iname }}"
+ state: absent
+ force_absent: yes
+
+- assert:
+ that:
+ - buildargs_1 is changed
+ - buildargs_2 is not failed and buildargs_2 is not changed
+ when: docker_py_version is version('1.6.0', '>=')
+
+- assert:
+ that:
+ - buildargs_1 is failed
+ - buildargs_2 is failed
+ when: docker_py_version is version('1.6.0', '<')
+
+####################################################################
+## build.container_limits ##########################################
+####################################################################
+
+- name: container_limits (Failed due to min memory limit)
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ container_limits:
+ memory: 4000
+ pull: no
+ source: build
+ ignore_errors: yes
+ register: container_limits_1
+
+- name: container_limits
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ container_limits:
+ memory: 7000000
+ memswap: 8000000
+ pull: no
+ source: build
+ register: container_limits_2
+
+- name: cleanup
+ docker_image:
+ name: "{{ iname }}"
+ state: absent
+ force_absent: yes
+
+- assert:
+ that:
+ # It *sometimes* happens that the first task does not fail.
+ # For now, we work around this by
+ # a) requiring that if it fails, the message must
+ # contain 'Minimum memory limit allowed is (4|6)MB', and
+ # b) requiring that either the first task, or the second
+ # task is changed, but not both.
+ - "not container_limits_1 is failed or ('Minimum memory limit allowed is ') in container_limits_1.msg"
+ - "container_limits_1 is changed or container_limits_2 is changed and not (container_limits_1 is changed and container_limits_2 is changed)"
+
+####################################################################
+## build.dockerfile ################################################
+####################################################################
+
+- name: dockerfile
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ dockerfile: "MyDockerfile"
+ pull: no
+ source: build
+ register: dockerfile_1
+
+- name: cleanup
+ docker_image:
+ name: "{{ iname }}"
+ state: absent
+ force_absent: yes
+
+- assert:
+ that:
+ - dockerfile_1 is changed
+ - "('FROM ' ~ docker_test_image_alpine) in dockerfile_1.stdout"
+ - dockerfile_1['image']['Config']['WorkingDir'] == '/newdata'
+
+####################################################################
+## build.platform ##################################################
+####################################################################
+
+- name: cleanup
+ docker_image:
+ name: "{{ iname }}"
+ state: absent
+ force_absent: yes
+
+- name: build.platform
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ platform: linux
+ pull: no
+ source: build
+ register: platform_1
+ ignore_errors: yes
+
+- name: build.platform (idempotency)
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ platform: linux
+ pull: no
+ source: build
+ register: platform_2
+ ignore_errors: yes
+
+- name: cleanup
+ docker_image:
+ name: "{{ iname }}"
+ state: absent
+ force_absent: yes
+
+- assert:
+ that:
+ - platform_1 is changed
+ - platform_2 is not failed and platform_2 is not changed
+ when: docker_py_version is version('3.0.0', '>=')
+
+- assert:
+ that:
+ - platform_1 is failed
+ - platform_2 is failed
+ when: docker_py_version is version('3.0.0', '<')
+
+####################################################################
+## force ###########################################################
+####################################################################
+
+- name: Build an image
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ pull: no
+ source: build
+
+- name: force (changed)
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ dockerfile: "MyDockerfile"
+ pull: no
+ source: build
+ force_source: yes
+ register: force_1
+
+- name: force (unchanged)
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ dockerfile: "MyDockerfile"
+ pull: no
+ source: build
+ force_source: yes
+ register: force_2
+
+- name: cleanup
+ docker_image:
+ name: "{{ iname }}"
+ state: absent
+ force_absent: yes
+
+- assert:
+ that:
+ - force_1 is changed
+ - force_2 is not changed
+
+####################################################################
+## load path #######################################################
+####################################################################
+
+- name: Archive image
+ docker_image:
+ name: "{{ docker_test_image_hello_world }}"
+ archive_path: "{{ output_dir }}/image.tar"
+ source: pull
+ register: archive_image
+
+- name: Create invalid archive
+ copy:
+ dest: "{{ output_dir }}/image-invalid.tar"
+ content: "this is not a valid image"
+
+- name: remove image
+ docker_image:
+ name: "{{ docker_test_image_hello_world }}"
+ state: absent
+ force_absent: yes
+
+- name: load image (changed)
+ docker_image:
+ name: "{{ docker_test_image_hello_world }}"
+ load_path: "{{ output_dir }}/image.tar"
+ source: load
+ register: load_image
+
+- name: load image (idempotency)
+ docker_image:
+ name: "{{ docker_test_image_hello_world }}"
+ load_path: "{{ output_dir }}/image.tar"
+ source: load
+ register: load_image_1
+
+- name: load image (wrong name)
+ docker_image:
+ name: foo:bar
+ load_path: "{{ output_dir }}/image.tar"
+ source: load
+ register: load_image_2
+ ignore_errors: true
+
+- name: load image (invalid image)
+ docker_image:
+ name: foo:bar
+ load_path: "{{ output_dir }}/image-invalid.tar"
+ source: load
+ register: load_image_3
+ ignore_errors: true
+
+- name: load image (invalid image, old API version)
+ docker_image:
+ name: foo:bar
+ load_path: "{{ output_dir }}/image-invalid.tar"
+ source: load
+ api_version: "1.22"
+ register: load_image_4
+
+- assert:
+ that:
+ - load_image is changed
+ - archive_image['image']['Id'] == load_image['image']['Id']
+ - load_image_1 is not changed
+ - load_image_2 is failed
+ - >-
+ "The archive did not contain image 'foo:bar'. Instead, found '" ~ docker_test_image_hello_world ~ "'." == load_image_2.msg
+ - load_image_3 is failed
+ - '"Detected no loaded images. Archive potentially corrupt?" == load_image_3.msg'
+ - load_image_4 is changed
+ - "'The API version of your Docker daemon is < 1.23, which does not return the image loading result from the Docker daemon. Therefore, we cannot verify whether the expected image was loaded, whether multiple images where loaded, or whether the load actually succeeded. You should consider upgrading your Docker daemon.' in load_image_4.warnings"
+
+####################################################################
+## build.path ######################################################
+####################################################################
+
+- name: Build image
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ pull: no
+ source: build
+ register: path_1
+
+- name: Build image (idempotency)
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ pull: no
+ source: build
+ register: path_2
+
+- name: cleanup
+ docker_image:
+ name: "{{ iname }}"
+ state: absent
+ force_absent: yes
+
+- assert:
+ that:
+ - path_1 is changed
+ - path_2 is not changed
+
+####################################################################
+## build.target ####################################################
+####################################################################
+
+- name: Build multi-stage image
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ dockerfile: "StagedDockerfile"
+ target: first
+ pull: no
+ source: build
+ register: dockerfile_2
+
+- name: cleanup
+ docker_image:
+ name: "{{ iname }}"
+ state: absent
+ force_absent: yes
+
+- assert:
+ that:
+ - dockerfile_2 is changed
+ - dockerfile_2.image.Config.WorkingDir == '/first'
+
+####################################################################
+## build.etc_hosts #################################################
+####################################################################
+
+- name: Build image with custom etc_hosts
+ docker_image:
+ name: "{{ iname }}"
+ build:
+ path: "{{ output_dir }}/files"
+ dockerfile: "EtcHostsDockerfile"
+ pull: no
+ etc_hosts:
+ some-custom-host: "127.0.0.1"
+ source: build
+ register: path_1
+
+- name: cleanup
+ docker_image:
+ name: "{{ iname }}"
+ state: absent
+ force_absent: yes
+
+- assert:
+ that:
+ - path_1 is changed
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/Dockerfile b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/Dockerfile
new file mode 100644
index 00000000..c5032944
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/Dockerfile
@@ -0,0 +1,3 @@
+FROM {{ docker_test_image_busybox }}
+ENV foo /bar
+WORKDIR ${foo}
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/EtcHostsDockerfile b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/EtcHostsDockerfile
new file mode 100644
index 00000000..f1b54e3b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/EtcHostsDockerfile
@@ -0,0 +1,3 @@
+FROM {{ docker_test_image_busybox }}
+# This should fail building if docker cannot resolve some-custom-host
+RUN ping -c1 some-custom-host
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/MyDockerfile b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/MyDockerfile
new file mode 100644
index 00000000..68bca8a2
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/MyDockerfile
@@ -0,0 +1,5 @@
+FROM {{ docker_test_image_alpine }}
+ENV INSTALL_PATH /newdata
+RUN mkdir -p $INSTALL_PATH
+
+WORKDIR $INSTALL_PATH
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/StagedDockerfile b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/StagedDockerfile
new file mode 100644
index 00000000..fc4623a3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image/templates/StagedDockerfile
@@ -0,0 +1,7 @@
+FROM {{ docker_test_image_busybox }} AS first
+ENV dir /first
+WORKDIR ${dir}
+
+FROM {{ docker_test_image_busybox }} AS second
+ENV dir /second
+WORKDIR ${dir}
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image_info/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image_info/aliases
new file mode 100644
index 00000000..02b78723
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image_info/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group4
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image_info/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image_info/tasks/main.yml
new file mode 100644
index 00000000..8b510c9c
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_image_info/tasks/main.yml
@@ -0,0 +1,59 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- block:
+ - name: Make sure image is not there
+ docker_image:
+ name: "{{ docker_test_image_alpine_different }}"
+ state: absent
+
+ - name: Inspect a non-available image
+ docker_image_info:
+ name: "{{ docker_test_image_alpine_different }}"
+ register: result
+
+ - assert:
+ that:
+ - "result.images|length == 0"
+
+ - name: Make sure images are there
+ docker_image:
+ name: "{{ item }}"
+ source: pull
+ state: present
+ loop:
+ - "{{ docker_test_image_hello_world }}"
+ - "{{ docker_test_image_alpine }}"
+
+ - name: Inspect an available image
+ docker_image_info:
+ name: "{{ docker_test_image_hello_world }}"
+ register: result
+
+ - assert:
+ that:
+ - "result.images|length == 1"
+ - "docker_test_image_hello_world in result.images[0].RepoTags"
+
+ - name: Inspect multiple images
+ docker_image_info:
+ name:
+ - "{{ docker_test_image_hello_world }}"
+ - "{{ docker_test_image_alpine }}"
+ register: result
+
+ - debug: var=result
+
+ - assert:
+ that:
+ - "result.images|length == 2"
+ - "docker_test_image_hello_world in result.images[0].RepoTags"
+ - "docker_test_image_alpine in result.images[1].RepoTags"
+
+ 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 docker_image_info tests!"
+ when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/aliases
new file mode 100644
index 00000000..02b78723
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group4
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/meta/main.yml
new file mode 100644
index 00000000..21d7a58f
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker_registry
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/main.yml
new file mode 100644
index 00000000..115c31e6
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/main.yml
@@ -0,0 +1,9 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- when: ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['CentOS6', 'RedHat6']
+ include_tasks:
+ file: test.yml
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/run-test.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/run-test.yml
new file mode 100644
index 00000000..a2999370
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/run-test.yml
@@ -0,0 +1,3 @@
+---
+- name: "Loading tasks from {{ item }}"
+ include_tasks: "{{ item }}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/test.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/test.yml
new file mode 100644
index 00000000..5a6f15fa
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/test.yml
@@ -0,0 +1,9 @@
+---
+- block:
+ - include_tasks: run-test.yml
+ with_fileglob:
+ - "tests/*.yml"
+ 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 docker_image tests!"
+ when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/tests/docker_login.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/tests/docker_login.yml
new file mode 100644
index 00000000..1c584c0f
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/tests/docker_login.yml
@@ -0,0 +1,139 @@
+---
+- block:
+ - name: Log in with wrong password (check mode)
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ username: testuser
+ password: "1234"
+ state: present
+ register: login_failed_check
+ ignore_errors: yes
+ check_mode: yes
+
+ - name: Log in with wrong password
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ username: testuser
+ password: "1234"
+ state: present
+ register: login_failed
+ ignore_errors: yes
+
+ - name: Make sure that login failed
+ assert:
+ that:
+ - login_failed_check is failed
+ - "('login attempt to http://' ~ registry_frontend_address ~ '/v2/ failed') in login_failed_check.msg"
+ - login_failed is failed
+ - "('login attempt to http://' ~ registry_frontend_address ~ '/v2/ failed') in login_failed.msg"
+
+ - name: Log in (check mode)
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ username: testuser
+ password: hunter2
+ state: present
+ register: login_1
+ check_mode: yes
+
+ - name: Log in
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ username: testuser
+ password: hunter2
+ state: present
+ register: login_2
+
+ - name: Get permissions of ~/.docker/config.json
+ stat:
+ path: ~/.docker/config.json
+ register: login_2_stat
+
+ - name: Log in (idempotent)
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ username: testuser
+ password: hunter2
+ state: present
+ register: login_3
+
+ - name: Log in (idempotent, check mode)
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ username: testuser
+ password: hunter2
+ state: present
+ register: login_4
+ check_mode: yes
+
+ - name: Make sure that login worked
+ assert:
+ that:
+ - login_1 is changed
+ - login_2 is changed
+ - login_3 is not changed
+ - login_4 is not changed
+ - login_2_stat.stat.mode == '0600'
+
+ - name: Log in again with wrong password (check mode)
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ username: testuser
+ password: "1234"
+ state: present
+ register: login_failed_check
+ ignore_errors: yes
+ check_mode: yes
+
+ - name: Log in again with wrong password
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ username: testuser
+ password: "1234"
+ state: present
+ register: login_failed
+ ignore_errors: yes
+
+ - name: Make sure that login failed again
+ assert:
+ that:
+ - login_failed_check is failed
+ - "('login attempt to http://' ~ registry_frontend_address ~ '/v2/ failed') in login_failed_check.msg"
+ - login_failed is failed
+ - "('login attempt to http://' ~ registry_frontend_address ~ '/v2/ failed') in login_failed.msg"
+
+ - name: Log out (check mode)
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ state: absent
+ register: logout_1
+ check_mode: yes
+
+ - name: Log out
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ state: absent
+ register: logout_2
+
+ - name: Log out (idempotent)
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ state: absent
+ register: logout_3
+
+ - name: Log out (idempotent, check mode)
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ state: absent
+ register: logout_4
+ check_mode: yes
+
+ - name: Make sure that login worked
+ assert:
+ that:
+ - logout_1 is changed
+ - logout_2 is changed
+ - logout_3 is not changed
+ - logout_4 is not changed
+
+ when: registry_frontend_address != 'n/a'
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/tests/multiple-servers.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/tests/multiple-servers.yml
new file mode 100644
index 00000000..2ad0b66f
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_login/tasks/tests/multiple-servers.yml
@@ -0,0 +1,57 @@
+---
+- block:
+ - name: Log out server 1
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ username: testuser
+ password: hunter2
+ state: absent
+
+ - name: Log out server 2
+ docker_login:
+ registry_url: "{{ registry_frontend2_address }}"
+ username: testuser
+ password: hunter2
+ state: absent
+
+ - name: Log in server 1
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ username: testuser
+ password: hunter2
+ state: present
+ register: login_1
+
+ - name: Log in server 2
+ docker_login:
+ registry_url: "{{ registry_frontend2_address }}"
+ username: testuser
+ password: hunter2
+ state: present
+ register: login_2
+
+ - name: Log in server 1 (idempotent)
+ docker_login:
+ registry_url: "{{ registry_frontend_address }}"
+ username: testuser
+ password: hunter2
+ state: present
+ register: login_1_2
+
+ - name: Log in server 2 (idempotent)
+ docker_login:
+ registry_url: "{{ registry_frontend2_address }}"
+ username: testuser
+ password: hunter2
+ state: present
+ register: login_2_2
+
+ - name: Make sure that login worked
+ assert:
+ that:
+ - login_1 is changed
+ - login_2 is changed
+ - login_1_2 is not changed
+ - login_2_2 is not changed
+
+ when: registry_frontend_address != 'n/a' and registry_frontend2_address != 'n/a'
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/aliases
new file mode 100644
index 00000000..02b78723
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group4
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/main.yml
new file mode 100644
index 00000000..d5fcdb91
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/main.yml
@@ -0,0 +1,38 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- name: Create random name prefix
+ set_fact:
+ name_prefix: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
+ cnames: []
+ dnetworks: []
+
+- debug:
+ msg: "Using name prefix {{ name_prefix }}"
+
+- 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
+ loop: "{{ cnames }}"
+ - name: "Make sure all networks are removed"
+ docker_network:
+ name: "{{ item }}"
+ state: absent
+ force: yes
+ loop: "{{ dnetworks }}"
+
+ when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.20', '>=') # FIXME: find out API version!
+
+- fail: msg="Too old docker / docker-py version to run docker_network tests!"
+ when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/run-test.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/run-test.yml
new file mode 100644
index 00000000..a2999370
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/run-test.yml
@@ -0,0 +1,3 @@
+---
+- name: "Loading tasks from {{ item }}"
+ include_tasks: "{{ item }}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/basic.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/basic.yml
new file mode 100644
index 00000000..e6290715
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/basic.yml
@@ -0,0 +1,134 @@
+---
+- name: Registering container and network names
+ set_fact:
+ cname_1: "{{ name_prefix ~ '-container-1' }}"
+ cname_2: "{{ name_prefix ~ '-container-2' }}"
+ cname_3: "{{ name_prefix ~ '-container-3' }}"
+ nname_1: "{{ name_prefix ~ '-network-1' }}"
+ nname_2: "{{ name_prefix ~ '-network-2' }}"
+- name: Registering container and network names
+ set_fact:
+ cnames: "{{ cnames + [cname_1, cname_2, cname_3] }}"
+ dnetworks: "{{ dnetworks + [nname_1, nname_2] }}"
+
+- name: Create containers
+ docker_container:
+ name: "{{ container_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ command: /bin/sleep 10m
+ state: started
+ loop:
+ - "{{ cname_1 }}"
+ - "{{ cname_2 }}"
+ - "{{ cname_3 }}"
+ loop_control:
+ loop_var: container_name
+
+####################################################################
+
+- name: Create network
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: present
+ register: networks_1
+
+- name: Connect network to containers 1
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: present
+ connected:
+ - "{{ cname_1 }}"
+ register: networks_2
+
+- name: Connect network to containers 1 (idempotency)
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: present
+ connected:
+ - "{{ cname_1 }}"
+ register: networks_2_idem
+
+- name: Connect network to containers 1 and 2
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: present
+ connected:
+ - "{{ cname_1 }}"
+ - "{{ cname_2 }}"
+ register: networks_3
+
+- name: Connect network to containers 1 and 2 (idempotency)
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: present
+ connected:
+ - "{{ cname_1 }}"
+ - "{{ cname_2 }}"
+ register: networks_3_idem
+
+- name: Connect network to container 3
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: present
+ connected:
+ - "{{ cname_3 }}"
+ appends: yes
+ register: networks_4
+
+- name: Connect network to container 3 (idempotency)
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: present
+ connected:
+ - "{{ cname_3 }}"
+ appends: yes
+ register: networks_4_idem
+
+- name: Disconnect network from container 1
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: present
+ connected:
+ - "{{ cname_2 }}"
+ - "{{ cname_3 }}"
+ register: networks_5
+
+- name: Disconnect network from container 1 (idempotency)
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: present
+ connected:
+ - "{{ cname_2 }}"
+ - "{{ cname_3 }}"
+ register: networks_5_idem
+
+- name: Cleanup
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: absent
+
+- assert:
+ that:
+ - networks_1 is changed
+ - networks_2 is changed
+ - networks_2_idem is not changed
+ - networks_3 is changed
+ - networks_3_idem is not changed
+ - networks_4 is changed
+ - networks_4_idem is not changed
+ - networks_5 is changed
+ - networks_5_idem is not changed
+
+####################################################################
+
+- name: Delete containers
+ docker_container:
+ name: "{{ container_name }}"
+ state: absent
+ force_kill: yes
+ loop:
+ - "{{ cname_1 }}"
+ - "{{ cname_2 }}"
+ - "{{ cname_3 }}"
+ loop_control:
+ loop_var: container_name
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/ipam.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/ipam.yml
new file mode 100644
index 00000000..214036c3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/ipam.yml
@@ -0,0 +1,312 @@
+---
+- name: Registering network names
+ set_fact:
+ nname_ipam_0: "{{ name_prefix ~ '-network-ipam-0' }}"
+ nname_ipam_1: "{{ name_prefix ~ '-network-ipam-1' }}"
+ nname_ipam_2: "{{ name_prefix ~ '-network-ipam-2' }}"
+ nname_ipam_3: "{{ name_prefix ~ '-network-ipam-3' }}"
+
+- name: Registering network names
+ set_fact:
+ dnetworks: "{{ dnetworks + [nname_ipam_0, nname_ipam_1, nname_ipam_2, nname_ipam_3] }}"
+
+
+#################### IPv4 IPAM config ####################
+
+- name: Create network with custom IPAM config
+ docker_network:
+ name: "{{ nname_ipam_1 }}"
+ ipam_config:
+ - subnet: 172.3.27.0/24
+ gateway: 172.3.27.2
+ iprange: 172.3.27.0/26
+ aux_addresses:
+ host1: 172.3.27.3
+ host2: 172.3.27.4
+ register: network
+
+- assert:
+ that:
+ - network is changed
+
+- name: Create network with custom IPAM config (idempotence)
+ docker_network:
+ name: "{{ nname_ipam_1 }}"
+ ipam_config:
+ - subnet: 172.3.27.0/24
+ gateway: 172.3.27.2
+ iprange: 172.3.27.0/26
+ aux_addresses:
+ host1: 172.3.27.3
+ host2: 172.3.27.4
+ register: network
+
+- assert:
+ that:
+ - network is not changed
+
+- name: Change of network created with custom IPAM config
+ docker_network:
+ name: "{{ nname_ipam_1 }}"
+ ipam_config:
+ - subnet: 172.3.28.0/24
+ gateway: 172.3.28.2
+ iprange: 172.3.28.0/26
+ aux_addresses:
+ host1: 172.3.28.3
+ register: network
+ diff: yes
+
+- assert:
+ that:
+ - network is changed
+ - network.diff.differences | length == 4
+ - '"ipam_config[0].subnet" in network.diff.differences'
+ - '"ipam_config[0].gateway" in network.diff.differences'
+ - '"ipam_config[0].iprange" in network.diff.differences'
+ - '"ipam_config[0].aux_addresses" in network.diff.differences'
+
+- name: Remove gateway and iprange of network with custom IPAM config
+ docker_network:
+ name: "{{ nname_ipam_1 }}"
+ ipam_config:
+ - subnet: 172.3.28.0/24
+ register: network
+
+- assert:
+ that:
+ - network is not changed
+
+- name: Cleanup network with custom IPAM config
+ docker_network:
+ name: "{{ nname_ipam_1 }}"
+ state: absent
+
+
+#################### IPv6 IPAM config ####################
+
+- name: Create network with IPv6 IPAM config
+ docker_network:
+ name: "{{ nname_ipam_2 }}"
+ enable_ipv6: yes
+ ipam_config:
+ - subnet: fdd1:ac8c:0557:7ce0::/64
+ register: network
+
+- assert:
+ that:
+ - network is changed
+
+- name: Create network with IPv6 IPAM config (idempotence)
+ docker_network:
+ name: "{{ nname_ipam_2 }}"
+ enable_ipv6: yes
+ ipam_config:
+ - subnet: fdd1:ac8c:0557:7ce0::/64
+ register: network
+
+- assert:
+ that:
+ - network is not changed
+
+- name: Change subnet of network with IPv6 IPAM config
+ docker_network:
+ name: "{{ nname_ipam_2 }}"
+ enable_ipv6: yes
+ ipam_config:
+ - subnet: fdd1:ac8c:0557:7ce1::/64
+ register: network
+ diff: yes
+
+- assert:
+ that:
+ - network is changed
+ - network.diff.differences | length == 1
+ - network.diff.differences[0] == "ipam_config[0].subnet"
+
+- name: Change subnet of network with IPv6 IPAM config
+ docker_network:
+ name: "{{ nname_ipam_2 }}"
+ enable_ipv6: yes
+ ipam_config:
+ - subnet: "fdd1:ac8c:0557:7ce1::"
+ register: network
+ ignore_errors: yes
+
+- assert:
+ that:
+ - network is failed
+ - "network.msg == '\"fdd1:ac8c:0557:7ce1::\" is not a valid CIDR'"
+
+- name: Cleanup network with IPv6 IPAM config
+ docker_network:
+ name: "{{ nname_ipam_2 }}"
+ state: absent
+
+
+#################### IPv4 and IPv6 network ####################
+
+- name: Create network with IPv6 and custom IPv4 IPAM config
+ docker_network:
+ name: "{{ nname_ipam_3 }}"
+ enable_ipv6: yes
+ ipam_config:
+ - subnet: 172.4.27.0/24
+ - subnet: fdd1:ac8c:0557:7ce2::/64
+ register: network
+
+- assert:
+ that:
+ - network is changed
+
+- name: Change subnet order of network with IPv6 and custom IPv4 IPAM config (idempotence)
+ docker_network:
+ name: "{{ nname_ipam_3 }}"
+ enable_ipv6: yes
+ ipam_config:
+ - subnet: fdd1:ac8c:0557:7ce2::/64
+ - subnet: 172.4.27.0/24
+ register: network
+
+- assert:
+ that:
+ - network is not changed
+
+- name: Remove IPv6 from network with custom IPv4 and IPv6 IPAM config (change)
+ docker_network:
+ name: "{{ nname_ipam_3 }}"
+ enable_ipv6: no
+ ipam_config:
+ - subnet: 172.4.27.0/24
+ register: network
+ diff: yes
+
+- assert:
+ that:
+ - network is changed
+ - network.diff.differences | length == 1
+ - network.diff.differences[0] == "enable_ipv6"
+
+- name: Cleanup network with IPv6 and custom IPv4 IPAM config
+ docker_network:
+ name: "{{ nname_ipam_3 }}"
+ state: absent
+
+
+#################### multiple IPv4 networks ####################
+
+- block:
+ - name: Create network with two IPv4 IPAM configs
+ docker_network:
+ name: "{{ nname_ipam_3 }}"
+ driver: "macvlan"
+ driver_options:
+ parent: "{{ ansible_default_ipv4.alias }}"
+ ipam_config:
+ - subnet: 172.4.27.0/24
+ - subnet: 172.4.28.0/24
+ register: network
+
+ - assert:
+ that:
+ - network is changed
+
+ - name: Create network with two IPv4 IPAM configs (idempotence)
+ docker_network:
+ name: "{{ nname_ipam_3 }}"
+ driver: "macvlan"
+ driver_options:
+ parent: "{{ ansible_default_ipv4.alias }}"
+ ipam_config:
+ - subnet: 172.4.28.0/24
+ - subnet: 172.4.27.0/24
+ register: network
+
+ - assert:
+ that:
+ - network is not changed
+
+ - name: Create network with two IPv4 IPAM configs (change)
+ docker_network:
+ name: "{{ nname_ipam_3 }}"
+ driver: "macvlan"
+ driver_options:
+ parent: "{{ ansible_default_ipv4.alias }}"
+ ipam_config:
+ - subnet: 172.4.27.0/24
+ - subnet: 172.4.29.0/24
+ register: network
+ diff: yes
+
+ - assert:
+ that:
+ - network is changed
+ - network.diff.differences | length == 1
+
+ - name: Create network with one IPv4 IPAM config (no change)
+ docker_network:
+ name: "{{ nname_ipam_3 }}"
+ driver: "macvlan"
+ driver_options:
+ parent: "{{ ansible_default_ipv4.alias }}"
+ ipam_config:
+ - subnet: 172.4.29.0/24
+ register: network
+
+ - assert:
+ that:
+ - network is not changed
+
+ - name: Cleanup network
+ docker_network:
+ name: "{{ nname_ipam_3 }}"
+ state: absent
+
+ when: ansible_facts.virtualization_type != 'docker'
+
+
+#################### IPAM driver options ####################
+
+- name: Create network with IPAM driver options
+ docker_network:
+ name: "{{ nname_ipam_3 }}"
+ ipam_driver: default
+ ipam_driver_options:
+ a: b
+ register: network_1
+ ignore_errors: yes
+- name: Create network with IPAM driver options (idempotence)
+ docker_network:
+ name: "{{ nname_ipam_3 }}"
+ ipam_driver: default
+ ipam_driver_options:
+ a: b
+ diff: yes
+ register: network_2
+ ignore_errors: yes
+- name: Create network with IPAM driver options (change)
+ docker_network:
+ name: "{{ nname_ipam_3 }}"
+ ipam_driver: default
+ ipam_driver_options:
+ a: c
+ diff: yes
+ register: network_3
+ ignore_errors: yes
+- name: Cleanup network
+ docker_network:
+ name: "{{ nname_ipam_3 }}"
+ state: absent
+
+- assert:
+ that:
+ - network_1 is changed
+ - network_2 is not changed
+ - network_3 is changed
+ when: docker_py_version is version('2.0.0', '>=')
+- assert:
+ that:
+ - network_1 is failed
+ - "('version is ' ~ docker_py_version ~ ' ') in network_1.msg"
+ - "'Minimum version required is 2.0.0 ' in network_1.msg"
+ when: docker_py_version is version('2.0.0', '<')
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/options.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/options.yml
new file mode 100644
index 00000000..ea073db3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/options.yml
@@ -0,0 +1,240 @@
+---
+- name: Registering network name
+ set_fact:
+ nname_1: "{{ name_prefix ~ '-network-1' }}"
+- name: Registering network name
+ set_fact:
+ dnetworks: "{{ dnetworks + [nname_1] }}"
+
+####################################################################
+## internal ########################################################
+####################################################################
+
+- name: internal
+ docker_network:
+ name: "{{ nname_1 }}"
+ internal: yes
+ register: internal_1
+
+- name: internal (idempotency)
+ docker_network:
+ name: "{{ nname_1 }}"
+ internal: yes
+ register: internal_2
+
+- name: internal (change)
+ docker_network:
+ name: "{{ nname_1 }}"
+ internal: no
+ register: internal_3
+
+- name: cleanup
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: absent
+ force: yes
+
+- assert:
+ that:
+ - internal_1 is changed
+ - internal_2 is not changed
+ - internal_3 is changed
+
+####################################################################
+## driver_options ##################################################
+####################################################################
+
+- name: driver_options
+ docker_network:
+ name: "{{ nname_1 }}"
+ driver_options:
+ com.docker.network.bridge.enable_icc: 'false'
+ register: driver_options_1
+
+- name: driver_options (idempotency)
+ docker_network:
+ name: "{{ nname_1 }}"
+ driver_options:
+ com.docker.network.bridge.enable_icc: 'false'
+ register: driver_options_2
+
+- name: driver_options (idempotency with string translation)
+ docker_network:
+ name: "{{ nname_1 }}"
+ driver_options:
+ com.docker.network.bridge.enable_icc: False
+ register: driver_options_3
+
+- name: driver_options (change)
+ docker_network:
+ name: "{{ nname_1 }}"
+ driver_options:
+ com.docker.network.bridge.enable_icc: 'true'
+ register: driver_options_4
+
+- name: driver_options (idempotency with string translation)
+ docker_network:
+ name: "{{ nname_1 }}"
+ driver_options:
+ com.docker.network.bridge.enable_icc: True
+ register: driver_options_5
+
+- name: cleanup
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: absent
+ force: yes
+
+- assert:
+ that:
+ - driver_options_1 is changed
+ - driver_options_2 is not changed
+ - driver_options_3 is not changed
+ - driver_options_4 is changed
+ - driver_options_5 is not changed
+
+####################################################################
+## scope ###########################################################
+####################################################################
+
+- block:
+ - name: scope
+ docker_network:
+ name: "{{ nname_1 }}"
+ driver: bridge
+ scope: local
+ register: scope_1
+
+ - name: scope (idempotency)
+ docker_network:
+ name: "{{ nname_1 }}"
+ driver: bridge
+ scope: local
+ register: scope_2
+
+ - name: swarm
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address}}"
+
+ # Driver change alongside scope is intentional - bridge doesn't appear to support anything but local, and overlay can't downgrade to local. Additionally, overlay reports as swarm for swarm OR global, so no change is reported in that case.
+ # Test output indicates that the scope is altered, at least, so manual inspection will be required to verify this going forward, unless we come up with a test driver that supports multiple scopes.
+ - name: scope (change)
+ docker_network:
+ name: "{{ nname_1 }}"
+ driver: overlay
+ scope: swarm
+ register: scope_3
+
+ - name: cleanup network
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: absent
+ force: yes
+
+ - assert:
+ that:
+ - scope_1 is changed
+ - scope_2 is not changed
+ - scope_3 is changed
+
+ always:
+ - name: cleanup swarm
+ docker_swarm:
+ state: absent
+ force: yes
+
+ # Requirements for docker_swarm
+ when: docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.25', '>=')
+
+####################################################################
+## attachable ######################################################
+####################################################################
+
+- name: attachable
+ docker_network:
+ name: "{{ nname_1 }}"
+ attachable: true
+ register: attachable_1
+ ignore_errors: yes
+
+- name: attachable (idempotency)
+ docker_network:
+ name: "{{ nname_1 }}"
+ attachable: true
+ register: attachable_2
+ ignore_errors: yes
+
+- name: attachable (change)
+ docker_network:
+ name: "{{ nname_1 }}"
+ attachable: false
+ register: attachable_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: absent
+ force: yes
+
+- assert:
+ that:
+ - attachable_1 is changed
+ - attachable_2 is not changed
+ - attachable_3 is changed
+ when: docker_py_version is version('2.0.0', '>=')
+- assert:
+ that:
+ - attachable_1 is failed
+ - "('version is ' ~ docker_py_version ~ ' ') in attachable_1.msg"
+ - "'Minimum version required is 2.0.0 ' in attachable_1.msg"
+ when: docker_py_version is version('2.0.0', '<')
+
+####################################################################
+## labels ##########################################################
+####################################################################
+
+- name: labels
+ docker_network:
+ name: "{{ nname_1 }}"
+ labels:
+ ansible.test.1: hello
+ ansible.test.2: world
+ register: labels_1
+
+- name: labels (idempotency)
+ docker_network:
+ name: "{{ nname_1 }}"
+ labels:
+ ansible.test.2: world
+ ansible.test.1: hello
+ register: labels_2
+
+- name: labels (less labels)
+ docker_network:
+ name: "{{ nname_1 }}"
+ labels:
+ ansible.test.1: hello
+ register: labels_3
+
+- name: labels (more labels)
+ docker_network:
+ name: "{{ nname_1 }}"
+ labels:
+ ansible.test.1: hello
+ ansible.test.3: ansible
+ register: labels_4
+
+- name: cleanup
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: absent
+ force: yes
+
+- assert:
+ that:
+ - labels_1 is changed
+ - labels_2 is not changed
+ - labels_3 is not changed
+ - labels_4 is changed
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/overlay.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/overlay.yml
new file mode 100644
index 00000000..832836aa
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/overlay.yml
@@ -0,0 +1,61 @@
+---
+- name: Registering network name
+ set_fact:
+ nname_1: "{{ name_prefix ~ '-network-1' }}"
+- name: Registering network name
+ set_fact:
+ dnetworks: "{{ dnetworks + [nname_1] }}"
+
+####################################################################
+## overlay #########################################################
+####################################################################
+
+- block:
+ # Overlay networks require swarm initialization before they'll work
+ - name: swarm
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address}}"
+
+ - name: overlay
+ docker_network:
+ name: "{{ nname_1 }}"
+ driver: overlay
+ driver_options:
+ com.docker.network.driver.overlay.vxlanid_list: "257"
+ register: overlay_1
+
+ - name: overlay (idempotency)
+ docker_network:
+ name: "{{ nname_1 }}"
+ driver: overlay
+ driver_options:
+ com.docker.network.driver.overlay.vxlanid_list: "257"
+ register: overlay_2
+
+ - name: overlay (change)
+ docker_network:
+ name: "{{ nname_1 }}"
+ driver: bridge
+ register: overlay_3
+
+ - name: cleanup network
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: absent
+ force: yes
+
+ - assert:
+ that:
+ - overlay_1 is changed
+ - overlay_2 is not changed
+ - overlay_3 is changed
+
+ always:
+ - name: cleanup swarm
+ docker_swarm:
+ state: absent
+ force: yes
+
+ # Requirements for docker_swarm
+ when: docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.25', '>=')
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/substring.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/substring.yml
new file mode 100644
index 00000000..bdee190e
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/tests/substring.yml
@@ -0,0 +1,37 @@
+---
+- name: Registering container and network names
+ set_fact:
+ nname_1: "{{ name_prefix ~ '-network-foo' }}"
+ nname_2: "{{ name_prefix ~ '-network-foobar' }}"
+- name: Registering container and network names
+ set_fact:
+ dnetworks: "{{ dnetworks + [nname_1, nname_2] }}"
+
+####################################################################
+
+- name: Create network (superstring)
+ docker_network:
+ name: "{{ nname_2 }}"
+ state: present
+ register: networks_1
+
+- name: Create network (substring)
+ docker_network:
+ name: "{{ nname_1 }}"
+ state: present
+ register: networks_2
+
+- name: Cleanup
+ docker_network:
+ name: "{{ network_name }}"
+ state: absent
+ loop:
+ - "{{ nname_1 }}"
+ - "{{ nname_2 }}"
+ loop_control:
+ loop_var: network_name
+
+- assert:
+ that:
+ - networks_1 is changed
+ - networks_2 is changed
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network_info/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network_info/aliases
new file mode 100644
index 00000000..02b78723
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network_info/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group4
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network_info/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network_info/tasks/main.yml
new file mode 100644
index 00000000..70edcf6c
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_network_info/tasks/main.yml
@@ -0,0 +1,76 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- block:
+ - name: Create random network name
+ set_fact:
+ nname: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
+
+ - name: Make sure network is not there
+ docker_network:
+ name: "{{ nname }}"
+ state: absent
+ force: yes
+
+ - name: Inspect a non-present network
+ docker_network_info:
+ name: "{{ nname }}"
+ register: result
+
+ - assert:
+ that:
+ - "not result.exists"
+ - "'network' in result"
+ - "result.network is none"
+
+ - name: Make sure network exists
+ docker_network:
+ name: "{{ nname }}"
+ state: present
+
+ - name: Inspect a present network
+ docker_network_info:
+ name: "{{ nname }}"
+ register: result
+ - name: Dump docker_network_info result
+ debug: var=result
+
+ - name: "Comparison: use 'docker network inspect'"
+ command: docker network inspect "{{ nname }}"
+ register: docker_inspect
+ ignore_errors: yes
+ - block:
+ - set_fact:
+ docker_inspect_result: "{{ docker_inspect.stdout | from_json }}"
+ - name: Dump docker inspect result
+ debug: var=docker_inspect_result
+ when: docker_inspect is not failed
+
+ - name: Cleanup
+ docker_network:
+ name: "{{ nname }}"
+ state: absent
+ force: yes
+
+ - assert:
+ that:
+ - result.exists
+ - "'network' in result"
+ - "result.network"
+
+ - assert:
+ that:
+ - "result.network == docker_inspect_result[0]"
+ when: docker_inspect is not failed
+ - assert:
+ that:
+ - "'is too new. Maximum supported API version is' in docker_inspect.stderr"
+ when: docker_inspect is failed
+
+ when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.21', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_network_info tests!"
+ when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.21', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/aliases
new file mode 100644
index 00000000..f225f586
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/aliases
@@ -0,0 +1,3 @@
+shippable/posix/group2
+destructive
+needs/root
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/tasks/main.yml
new file mode 100644
index 00000000..a91efc59
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/tasks/main.yml
@@ -0,0 +1,37 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+# Run the tests
+- block:
+ - include_tasks: test_node.yml
+
+ always:
+ - name: Cleanup (trying)
+ docker_swarm:
+ state: absent
+ force: true
+ diff: no
+ ignore_errors: yes
+
+ - name: Restart docker daemon
+ service:
+ name: docker
+ state: restarted
+ become: yes
+ - name: Wait for docker daemon to be fully restarted
+ command: docker ps
+ ignore_errors: yes
+
+ - name: Cleanup
+ docker_swarm:
+ state: absent
+ force: true
+ diff: no
+
+ when: docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_node tests!"
+ when: not(docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/tasks/test_node.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/tasks/test_node.yml
new file mode 100644
index 00000000..bdc01afb
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node/tasks/test_node.yml
@@ -0,0 +1,840 @@
+---
+- block:
+ - name: Make sure we're not already using Docker swarm
+ docker_swarm:
+ state: absent
+ force: true
+
+ - name: Try to get docker_node_info when docker is not running in swarm mode
+ docker_node_info:
+ ignore_errors: yes
+ register: output
+
+ - name: assert failure when called when swarm is not in use or not run on manager node
+ assert:
+ that:
+ - 'output is failed'
+ - 'output.msg == "Error running docker swarm module: must run on swarm manager node"'
+
+ - name: Create a Swarm cluster
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ register: output
+
+ - name: assert changed when create a new swarm cluster
+ assert:
+ that:
+ - 'output is changed'
+ - 'output.actions[0] | regex_search("New Swarm cluster created: ")'
+ - 'output.swarm_facts.JoinTokens.Manager'
+ - 'output.swarm_facts.JoinTokens.Worker'
+
+ - name: Try to get docker_node_info when docker is running in swarm mode and as manager
+ docker_node_info:
+ register: output
+
+ - name: assert reading docker swarm node facts
+ assert:
+ that:
+ - 'output.nodes | length > 0'
+ - 'output.nodes[0].ID is string'
+
+ - name: Register node ID
+ set_fact:
+ nodeid: "{{ output.nodes[0].ID }}"
+
+####################################################################
+## Set node as swarm manager #######################################
+####################################################################
+
+ - name: Try to set node as manager (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ role: manager
+ check_mode: yes
+ register: set_as_manager_1
+
+ - name: Try to set node as manager
+ docker_node:
+ hostname: "{{ nodeid }}"
+ role: manager
+ register: set_as_manager_2
+
+ - name: Try to set node as manager (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ role: manager
+ register: set_as_manager_3
+
+ - name: Try to set node as manager (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ role: manager
+ check_mode: yes
+ register: set_as_manager_4
+
+ - name: assert that node role does has not changed
+ assert:
+ that:
+ - 'set_as_manager_1 is not changed'
+ - 'set_as_manager_2 is not changed'
+ - 'set_as_manager_3 is not changed'
+ - 'set_as_manager_4 is not changed'
+ - 'set_as_manager_1.node.Spec.Role == "manager"'
+ - 'set_as_manager_2.node.Spec.Role == "manager"'
+ - 'set_as_manager_3.node.Spec.Role == "manager"'
+ - 'set_as_manager_4.node.Spec.Role == "manager"'
+
+####################################################################
+## Set node as swarm worker ########################################
+####################################################################
+
+ - name: Try to set node as worker (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ role: worker
+ check_mode: yes
+ register: set_as_worker_1
+
+ - name: Try to set node as worker
+ docker_node:
+ hostname: "{{ nodeid }}"
+ role: worker
+ ignore_errors: yes
+ register: set_as_worker_2
+
+ - name: assert that node cannot change role to worker
+ assert:
+ that:
+ - 'set_as_worker_1 is changed'
+ - 'set_as_worker_2 is failed'
+ - 'set_as_worker_2.msg | regex_search("attempting to demote the last manager of the swarm")'
+
+####################################################################
+## Set node as pasued ##############################################
+####################################################################
+
+ - name: Try to set node availability as paused (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ availability: pause
+ check_mode: yes
+ register: set_as_paused_1
+
+ - name: Try to set node availability as paused
+ docker_node:
+ hostname: "{{ nodeid }}"
+ availability: pause
+ register: set_as_paused_2
+
+ - name: Try to set node availability as paused (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ availability: pause
+ register: set_as_paused_3
+
+ - name: Try to set node availability as paused (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ availability: pause
+ check_mode: yes
+ register: set_as_paused_4
+
+ - name: assert node changed availability to paused
+ assert:
+ that:
+ - 'set_as_paused_1 is changed'
+ - 'set_as_paused_2 is changed'
+ - 'set_as_paused_3 is not changed'
+ - 'set_as_paused_4 is not changed'
+ - 'set_as_paused_2.node.Spec.Availability == "pause"'
+
+####################################################################
+## Set node as drained #############################################
+####################################################################
+
+ - name: Try to set node availability as drained (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ availability: drain
+ check_mode: yes
+ register: output_drain_1
+
+ - name: Try to set node availability as drained
+ docker_node:
+ hostname: "{{ nodeid }}"
+ availability: drain
+ register: output_drain_2
+
+ - name: Try to set node availability as drained (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ availability: drain
+ register: output_drain_3
+
+ - name: Try to set node availability as drained (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ availability: drain
+ check_mode: yes
+ register: output_drain_4
+
+ - name: assert node changed availability to drained
+ assert:
+ that:
+ - 'output_drain_1 is changed'
+ - 'output_drain_2 is changed'
+ - 'output_drain_3 is not changed'
+ - 'output_drain_4 is not changed'
+ - 'output_drain_2.node.Spec.Availability == "drain"'
+
+
+####################################################################
+## Set node as active ##############################################
+####################################################################
+
+ - name: Try to set node availability as active (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ availability: active
+ check_mode: yes
+ register: output_active_1
+
+ - name: Try to set node availability as active
+ docker_node:
+ hostname: "{{ nodeid }}"
+ availability: active
+ register: output_active_2
+
+ - name: Try to set node availability as active (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ availability: active
+ register: output_active_3
+
+ - name: Try to set node availability as active (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ availability: active
+ check_mode: yes
+ register: output_active_4
+
+ - name: assert node changed availability to active
+ assert:
+ that:
+ - 'output_active_1 is changed'
+ - 'output_active_2 is changed'
+ - 'output_active_3 is not changed'
+ - 'output_active_4 is not changed'
+ - 'output_active_2.node.Spec.Availability == "active"'
+
+####################################################################
+## Add single label ###############################################
+####################################################################
+
+ - name: Try to add single label to swarm node (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label1: value1
+ check_mode: yes
+ register: output_add_single_label_1
+
+ - name: Try to add single label to swarm node
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label1: value1
+ register: output_add_single_label_2
+
+ - name: Try to add single label to swarm node (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label1: value1
+ register: output_add_single_label_3
+
+ - name: Try to add single label to swarm node (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label1: value1
+ check_mode: yes
+ register: output_add_single_label_4
+
+ - name: assert adding single label to swarm node
+ assert:
+ that:
+ - 'output_add_single_label_1 is changed'
+ - 'output_add_single_label_2 is changed'
+ - 'output_add_single_label_3 is not changed'
+ - 'output_add_single_label_4 is not changed'
+ - 'output_add_single_label_2.node.Spec.Labels | length == 1'
+ - 'output_add_single_label_2.node.Spec.Labels.label1 == "value1"'
+
+####################################################################
+## Add multiple labels #############################################
+####################################################################
+
+ - name: Try to add five labels to swarm node (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label2: value2
+ label3: value3
+ label4: value4
+ label5: value5
+ label6: value6
+ check_mode: yes
+ register: output_add_multiple_labels_1
+
+ - name: Try to add five labels to swarm node
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label2: value2
+ label3: value3
+ label4: value4
+ label5: value5
+ label6: value6
+ register: output_add_multiple_labels_2
+
+ - name: Try to add five labels to swarm node (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label2: value2
+ label3: value3
+ label4: value4
+ label5: value5
+ label6: value6
+ register: output_add_multiple_labels_3
+
+ - name: Try to add five labels to swarm node (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label2: value2
+ label3: value3
+ label4: value4
+ label5: value5
+ label6: value6
+ check_mode: yes
+ register: output_add_multiple_labels_4
+
+ - name: assert adding multiple labels to swarm node
+ assert:
+ that:
+ - 'output_add_multiple_labels_1 is changed'
+ - 'output_add_multiple_labels_2 is changed'
+ - 'output_add_multiple_labels_3 is not changed'
+ - 'output_add_multiple_labels_4 is not changed'
+ - 'output_add_multiple_labels_2.node.Spec.Labels | length == 6'
+ - 'output_add_multiple_labels_2.node.Spec.Labels.label1 == "value1"'
+ - 'output_add_multiple_labels_2.node.Spec.Labels.label6 == "value6"'
+
+####################################################################
+## Update label value ##############################################
+####################################################################
+
+ - name: Update value of existing label (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label1: value1111
+ check_mode: yes
+ register: output_update_label_1
+
+ - name: Update value of existing label
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label1: value1111
+ register: output_update_label_2
+
+ - name: Update value of existing label (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label1: value1111
+ register: output_update_label_3
+
+ - name: Update value of existing label (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label1: value1111
+ check_mode: yes
+ register: output_update_label_4
+
+ - name: assert updating single label assigned to swarm node
+ assert:
+ that:
+ - 'output_update_label_1 is changed'
+ - 'output_update_label_2 is changed'
+ - 'output_update_label_3 is not changed'
+ - 'output_update_label_4 is not changed'
+ - 'output_update_label_2.node.Spec.Labels | length == 6'
+ - 'output_update_label_2.node.Spec.Labels.label1 == "value1111"'
+ - 'output_update_label_2.node.Spec.Labels.label5 == "value5"'
+
+####################################################################
+## Update multiple labels values ###################################
+####################################################################
+
+ - name: Update value of multiple existing label (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label2: value2222
+ label3: value3333
+ check_mode: yes
+ register: output_update_labels_1
+
+ - name: Update value of multiple existing label
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label2: value2222
+ label3: value3333
+ register: output_update_labels_2
+
+ - name: Update value of multiple existing label (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label2: value2222
+ label3: value3333
+ register: output_update_labels_3
+
+ - name: Update value of multiple existing label (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label2: value2222
+ label3: value3333
+ check_mode: yes
+ register: output_update_labels_4
+
+ - name: assert updating multiple labels assigned to swarm node
+ assert:
+ that:
+ - 'output_update_labels_1 is changed'
+ - 'output_update_labels_2 is changed'
+ - 'output_update_labels_3 is not changed'
+ - 'output_update_labels_4 is not changed'
+ - 'output_update_labels_2.node.Spec.Labels | length == 6'
+ - 'output_update_labels_2.node.Spec.Labels.label1 == "value1111"'
+ - 'output_update_labels_2.node.Spec.Labels.label3 == "value3333"'
+ - 'output_update_labels_2.node.Spec.Labels.label5 == "value5"'
+
+####################################################################
+## Remove single label #############################################
+####################################################################
+
+ - name: Try to remove single existing label from swarm node (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - label1
+ check_mode: yes
+ register: output_remove_label_1
+
+ - name: Try to remove single existing label from swarm node
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - label1
+ register: output_remove_label_2
+
+ - name: Try to remove single existing label from swarm node (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - label1
+ register: output_remove_label_3
+
+ - name: Try to remove single existing label from swarm node (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - label1
+ check_mode: yes
+ register: output_remove_label_4
+
+ - name: assert removing single label from swarm node
+ assert:
+ that:
+ - 'output_remove_label_1 is changed'
+ - 'output_remove_label_2 is changed'
+ - 'output_remove_label_3 is not changed'
+ - 'output_remove_label_4 is not changed'
+ - 'output_remove_label_2.node.Spec.Labels | length == 5'
+ - '"label1" not in output_remove_label_2.node.Spec.Labels'
+ - 'output_remove_label_2.node.Spec.Labels.label3 == "value3333"'
+ - 'output_remove_label_2.node.Spec.Labels.label5 == "value5"'
+
+
+####################################################################
+## Remove single not assigned to swarm label #######################
+####################################################################
+
+ - name: Try to remove single non-existing label from swarm node (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - labelnotexist
+ check_mode: yes
+ register: output_remove_nonexist_label_1
+
+ - name: Try to remove single non-existing label from swarm node
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - labelnotexist
+ register: output_remove_nonexist_label_2
+
+ - name: Try to remove single non-existing label from swarm node (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - labelnotexist
+ register: output_remove_nonexist_label_3
+
+ - name: Try to remove single non-existing label from swarm node (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - labelnotexist
+ check_mode: yes
+ register: output_remove_nonexist_label_4
+
+ - name: assert removing single non-existing label from swarm node
+ assert:
+ that:
+ - 'output_remove_nonexist_label_1 is not changed'
+ - 'output_remove_nonexist_label_2 is not changed'
+ - 'output_remove_nonexist_label_3 is not changed'
+ - 'output_remove_nonexist_label_4 is not changed'
+ - 'output_remove_nonexist_label_2.node.Spec.Labels | length == 5'
+ - '"label1" not in output_remove_nonexist_label_2.node.Spec.Labels'
+ - 'output_remove_nonexist_label_2.node.Spec.Labels.label3 == "value3333"'
+ - 'output_remove_nonexist_label_2.node.Spec.Labels.label5 == "value5"'
+
+####################################################################
+## Remove multiple labels ##########################################
+####################################################################
+
+ - name: Try to remove two existing labels from swarm node (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - label2
+ - label3
+ check_mode: yes
+ register: output_remove_label_1
+
+ - name: Try to remove two existing labels from swarm node
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - label2
+ - label3
+ register: output_remove_label_2
+
+ - name: Try to remove two existing labels from swarm node (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - label2
+ - label3
+ register: output_remove_label_3
+
+ - name: Try to remove two existing labels from swarm node (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - label2
+ - label3
+ check_mode: yes
+ register: output_remove_label_4
+
+ - name: assert removing multiple labels from swarm node
+ assert:
+ that:
+ - 'output_remove_label_1 is changed'
+ - 'output_remove_label_2 is changed'
+ - 'output_remove_label_3 is not changed'
+ - 'output_remove_label_4 is not changed'
+ - 'output_remove_label_2.node.Spec.Labels | length == 3'
+ - '"label1" not in output_remove_label_2.node.Spec.Labels'
+ - '"label2" not in output_remove_label_2.node.Spec.Labels'
+ - 'output_remove_label_2.node.Spec.Labels.label5 == "value5"'
+
+####################################################################
+## Remove multiple labels, mix assigned and not assigned ##########
+####################################################################
+
+ - name: Try to remove mix of existing amd non-existing labels from swarm node (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - label4
+ - labelisnotthere
+ check_mode: yes
+ register: output_remove_mix_labels_1
+
+ - name: Try to remove mix of existing amd non-existing labels from swarm node
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - label4
+ - labelisnotthere
+ register: output_remove_mix_labels_2
+
+ - name: Try to remove mix of existing amd non-existing labels from swarm node (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - label4
+ - labelisnotthere
+ register: output_remove_mix_labels_3
+
+ - name: Try to remove mix of existing amd non-existing labels from swarm node (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_to_remove:
+ - label4
+ - labelisnotthere
+ check_mode: yes
+ register: output_remove_mix_labels_4
+
+ - name: assert removing mix of existing and non-existing labels from swarm node
+ assert:
+ that:
+ - 'output_remove_mix_labels_1 is changed'
+ - 'output_remove_mix_labels_2 is changed'
+ - 'output_remove_mix_labels_3 is not changed'
+ - 'output_remove_mix_labels_4 is not changed'
+ - 'output_remove_mix_labels_2.node.Spec.Labels | length == 2'
+ - '"label1" not in output_remove_mix_labels_2.node.Spec.Labels'
+ - '"label4" not in output_remove_mix_labels_2.node.Spec.Labels'
+ - 'output_remove_mix_labels_2.node.Spec.Labels.label5 == "value5"'
+
+####################################################################
+## Add and remove labels ###########################################
+####################################################################
+
+ - name: Try to add and remove nonoverlapping labels at the same time (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label7: value7
+ label8: value8
+ labels_to_remove:
+ - label5
+ check_mode: yes
+ register: output_add_del_labels_1
+
+ - name: Try to add and remove nonoverlapping labels at the same time
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label7: value7
+ label8: value8
+ labels_to_remove:
+ - label5
+ register: output_add_del_labels_2
+
+ - name: Try to add and remove nonoverlapping labels at the same time (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label7: value7
+ label8: value8
+ labels_to_remove:
+ - label5
+ register: output_add_del_labels_3
+
+ - name: Try to add and remove nonoverlapping labels at the same time (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label7: value7
+ label8: value8
+ labels_to_remove:
+ - label5
+ check_mode: yes
+ register: output_add_del_labels_4
+
+ - name: assert adding and removing nonoverlapping labels from swarm node
+ assert:
+ that:
+ - 'output_add_del_labels_1 is changed'
+ - 'output_add_del_labels_2 is changed'
+ - 'output_add_del_labels_3 is not changed'
+ - 'output_add_del_labels_4 is not changed'
+ - 'output_add_del_labels_2.node.Spec.Labels | length == 3'
+ - '"label5" not in output_add_del_labels_2.node.Spec.Labels'
+ - 'output_add_del_labels_2.node.Spec.Labels.label8 == "value8"'
+
+####################################################################
+## Add and remove labels with label in both lists ##################
+####################################################################
+
+ - name: Try to add or update and remove overlapping labels at the same time (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label22: value22
+ label6: value6666
+ labels_to_remove:
+ - label6
+ - label7
+ check_mode: yes
+ register: output_add_del_overlap_lables_1
+
+ - name: Try to add or update and remove overlapping labels at the same time
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label22: value22
+ label6: value6666
+ labels_to_remove:
+ - label6
+ - label7
+ register: output_add_del_overlap_lables_2
+
+ - name: Try to add or update and remove overlapping labels at the same time (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label22: value22
+ label6: value6666
+ labels_to_remove:
+ - label6
+ - label7
+ register: output_add_del_overlap_lables_3
+
+ - name: Try to add or update and remove overlapping labels at the same time (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label22: value22
+ label6: value6666
+ labels_to_remove:
+ - label6
+ - label7
+ check_mode: yes
+ register: output_add_del_overlap_lables_4
+
+ - name: assert adding or updating and removing overlapping labels from swarm node
+ assert:
+ that:
+ - 'output_add_del_overlap_lables_1 is changed'
+ - 'output_add_del_overlap_lables_2 is changed'
+ - 'output_add_del_overlap_lables_3 is not changed'
+ - 'output_add_del_overlap_lables_4 is not changed'
+ - 'output_add_del_overlap_lables_2.node.Spec.Labels | length == 3'
+ - '"label7" not in output_add_del_overlap_lables_2.node.Spec.Labels'
+ - 'output_add_del_overlap_lables_2.node.Spec.Labels.label6 == "value6666"'
+ - 'output_add_del_overlap_lables_2.node.Spec.Labels.label22 == "value22"'
+
+####################################################################
+## Replace labels #############################################
+####################################################################
+
+ - name: Replace labels on swarm node (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label11: value11
+ label12: value12
+ labels_state: replace
+ check_mode: yes
+ register: output_replace_labels_1
+
+ - name: Replace labels on swarm node
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label11: value11
+ label12: value12
+ labels_state: replace
+ register: output_replace_labels_2
+
+ - name: Replace labels on swarm node (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label11: value11
+ label12: value12
+ labels_state: replace
+ register: output_replace_labels_3
+
+ - name: Replace labels on swarm node (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels:
+ label11: value11
+ label12: value12
+ labels_state: replace
+ check_mode: yes
+ register: output_replace_labels_4
+
+ - name: assert replacing labels from swarm node
+ assert:
+ that:
+ - 'output_replace_labels_1 is changed'
+ - 'output_replace_labels_2 is changed'
+ - 'output_replace_labels_3 is not changed'
+ - 'output_replace_labels_4 is not changed'
+ - 'output_replace_labels_2.node.Spec.Labels | length == 2'
+ - '"label6" not in output_replace_labels_2.node.Spec.Labels'
+ - 'output_replace_labels_2.node.Spec.Labels.label12 == "value12"'
+
+####################################################################
+## Remove all labels #############################################
+####################################################################
+
+ - name: Remove all labels from swarm node (check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_state: replace
+ check_mode: yes
+ register: output_remove_labels_1
+
+ - name: Remove all labels from swarm node
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_state: replace
+ register: output_remove_labels_2
+
+ - name: Remove all labels from swarm node (idempotent)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_state: replace
+ register: output_remove_labels_3
+
+ - name: Remove all labels from swarm node (idempotent check)
+ docker_node:
+ hostname: "{{ nodeid }}"
+ labels_state: replace
+ check_mode: yes
+ register: output_remove_labels_4
+
+ - name: assert removing all lables from swarm node
+ assert:
+ that:
+ - 'output_remove_labels_1 is changed'
+ - 'output_remove_labels_2 is changed'
+ - 'output_remove_labels_3 is not changed'
+ - 'output_remove_labels_4 is not changed'
+ - 'output_remove_labels_2.node.Spec.Labels | length == 0'
+
+ always:
+ - name: Cleanup
+ docker_swarm:
+ state: absent
+ force: true
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/aliases
new file mode 100644
index 00000000..ca7c9128
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group2
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/tasks/main.yml
new file mode 100644
index 00000000..7855f7e2
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/tasks/main.yml
@@ -0,0 +1,11 @@
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- include_tasks: test_node_info.yml
+ # Maximum of 1.24 (docker API version for docker_node_info) and 1.25 (docker API version for docker_swarm) is 1.25
+ when: docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_node_info tests!"
+ when: not(docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/tasks/test_node_info.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/tasks/test_node_info.yml
new file mode 100644
index 00000000..3ee5549b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_node_info/tasks/test_node_info.yml
@@ -0,0 +1,88 @@
+---
+- block:
+ - name: Make sure we're not already using Docker swarm
+ docker_swarm:
+ state: absent
+ force: true
+
+ - name: Try to get docker_node_info when docker is not running in swarm mode
+ docker_node_info:
+ ignore_errors: yes
+ register: output
+
+ - name: assert failure when called when swarm is not in use or not run on manager node
+ assert:
+ that:
+ - 'output is failed'
+ - 'output.msg == "Error running docker swarm module: must run on swarm manager node"'
+
+ - name: Create a Swarm cluster
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ register: output
+
+ - name: assert changed when create a new swarm cluster
+ assert:
+ that:
+ - 'output is changed'
+ - 'output.actions[0] | regex_search("New Swarm cluster created: ")'
+ - 'output.swarm_facts.JoinTokens.Manager'
+ - 'output.swarm_facts.JoinTokens.Worker'
+
+ - name: Try to get docker_node_info when docker is running in swarm mode and as manager
+ docker_node_info:
+ register: output
+
+ - name: assert reading docker swarm node facts
+ assert:
+ that:
+ - 'output.nodes | length > 0'
+ - 'output.nodes[0].ID is string'
+
+ - name: Try to get docker_node_info using the self parameter
+ docker_node_info:
+ self: yes
+ register: output
+
+ - name: assert reading swarm facts with list of nodes option
+ assert:
+ that:
+ - 'output.nodes | length == 1'
+ - 'output.nodes[0].ID is string'
+
+ - name: Get local docker node name
+ set_fact:
+ localnodename: "{{ output.nodes[0].Description.Hostname }}"
+
+
+ - name: Try to get docker_node_info using the local node name as parameter
+ docker_node_info:
+ name: "{{ localnodename }}"
+ register: output
+
+ - name: assert reading reading swarm facts and using node filter (random node name)
+ assert:
+ that:
+ - 'output.nodes | length == 1'
+ - 'output.nodes[0].ID is string'
+
+ - name: Create random name
+ set_fact:
+ randomnodename: "{{ 'node-%0x' % ((2**32) | random) }}"
+
+ - name: Try to get docker_node_info using random node name as parameter
+ docker_node_info:
+ name: "{{ randomnodename }}"
+ register: output
+
+ - name: assert reading reading swarm facts and using node filter (random node name)
+ assert:
+ that:
+ - 'output.nodes | length == 0'
+
+ always:
+ - name: Cleanup
+ docker_swarm:
+ state: absent
+ force: true
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_prune/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_prune/aliases
new file mode 100644
index 00000000..02b78723
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_prune/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group4
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_prune/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_prune/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_prune/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_prune/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_prune/tasks/main.yml
new file mode 100644
index 00000000..16c4aa05
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_prune/tasks/main.yml
@@ -0,0 +1,68 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- name: Create random names
+ set_fact:
+ cname: "{{ 'ansible-container-%0x' % ((2**32) | random) }}"
+ nname: "{{ 'ansible-network-%0x' % ((2**32) | random) }}"
+ vname: "{{ 'ansible-volume-%0x' % ((2**32) | random) }}"
+
+- block:
+ # Create objects to be pruned
+ - docker_container:
+ name: "{{ cname }}"
+ image: "{{ docker_test_image_hello_world }}"
+ state: present
+ register: container
+ - docker_network:
+ name: "{{ nname }}"
+ state: present
+ register: network
+ - docker_volume:
+ name: "{{ vname }}"
+ state: present
+ register: volume
+
+ # Prune objects
+ - docker_prune:
+ containers: yes
+ images: yes
+ networks: yes
+ volumes: yes
+ builder_cache: "{{ docker_py_version is version('3.3.0', '>=') }}"
+ register: result
+
+ # Analyze result
+ - debug: var=result
+ - assert:
+ that:
+ # containers
+ - container.container.Id in result.containers
+ - "'containers_space_reclaimed' in result"
+ # images
+ - "'images_space_reclaimed' in result"
+ # networks
+ - network.network.Name in result.networks
+ # volumes
+ - volume.volume.Name in result.volumes
+ - "'volumes_space_reclaimed' in result"
+ # builder_cache
+ - "'builder_cache_space_reclaimed' in result or docker_py_version is version('3.3.0', '<')"
+ - "'builder_cache_space_reclaimed' not in result or docker_py_version is version('3.3.0', '>=')"
+
+ # Test with filters
+ - docker_prune:
+ images: yes
+ images_filters:
+ dangling: true
+ register: result
+
+ - debug: var=result
+
+ when: docker_py_version is version('2.1.0', '>=') and docker_api_version is version('1.25', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_prune tests!"
+ when: not(docker_py_version is version('2.1.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/aliases
new file mode 100644
index 00000000..cdf1b9b1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group3
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/tasks/main.yml
new file mode 100644
index 00000000..68d3df8d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/tasks/main.yml
@@ -0,0 +1,10 @@
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- include_tasks: test_secrets.yml
+ when: docker_py_version is version('2.1.0', '>=') and docker_api_version is version('1.25', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_secrets tests!"
+ when: not(docker_py_version is version('2.1.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/tasks/test_secrets.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/tasks/test_secrets.yml
new file mode 100644
index 00000000..2c078488
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_secret/tasks/test_secrets.yml
@@ -0,0 +1,124 @@
+---
+- block:
+ - name: Make sure we're not already using Docker swarm
+ docker_swarm:
+ state: absent
+ force: true
+
+ - name: Create a Swarm cluster
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address}}"
+
+ - name: Parameter name should be required
+ docker_secret:
+ state: present
+ ignore_errors: yes
+ register: output
+
+ - name: assert failure when called with no name
+ assert:
+ that:
+ - 'output.failed'
+ - 'output.msg == "missing required arguments: name"'
+
+ - name: Test parameters
+ docker_secret:
+ name: foo
+ state: present
+ ignore_errors: yes
+ register: output
+
+ - name: assert failure when called with no data
+ assert:
+ that:
+ - 'output.failed'
+ - 'output.msg == "state is present but all of the following are missing: data"'
+
+ - name: Create secret
+ docker_secret:
+ name: db_password
+ data: opensesame!
+ state: present
+ register: output
+
+ - name: Create variable secret_id
+ set_fact:
+ secret_id: "{{ output.secret_id }}"
+
+ - name: Inspect secret
+ command: "docker secret inspect {{ secret_id }}"
+ register: inspect
+ ignore_errors: yes
+
+ - debug: var=inspect
+
+ - name: assert secret creation succeeded
+ assert:
+ that:
+ - "'db_password' in inspect.stdout"
+ - "'ansible_key' in inspect.stdout"
+ when: inspect is not failed
+ - assert:
+ that:
+ - "'is too new. Maximum supported API version is' in inspect.stderr"
+ when: inspect is failed
+
+ - name: Create secret again
+ docker_secret:
+ name: db_password
+ data: opensesame!
+ state: present
+ register: output
+
+ - name: assert create secret is idempotent
+ assert:
+ that:
+ - not output.changed
+
+ - name: Create secret again (base64)
+ docker_secret:
+ name: db_password
+ data: b3BlbnNlc2FtZSE=
+ data_is_b64: true
+ state: present
+ register: output
+
+ - name: assert create secret (base64) is idempotent
+ assert:
+ that:
+ - not output.changed
+
+ - name: Update secret
+ docker_secret:
+ name: db_password
+ data: newpassword!
+ state: present
+ register: output
+
+ - name: assert secret was updated
+ assert:
+ that:
+ - output.changed
+ - output.secret_id != secret_id
+
+ - name: Remove secret
+ docker_secret:
+ name: db_password
+ state: absent
+
+ - name: Check that secret is removed
+ command: "docker secret inspect {{ secret_id }}"
+ register: output
+ ignore_errors: yes
+
+ - name: assert secret was removed
+ assert:
+ that:
+ - output.failed
+
+ always:
+ - name: Remove Swarm cluster
+ docker_swarm:
+ state: absent
+ force: true
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/aliases
new file mode 100644
index 00000000..ca7c9128
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group2
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/tasks/main.yml
new file mode 100644
index 00000000..5ed63f3e
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/tasks/main.yml
@@ -0,0 +1,10 @@
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- include_tasks: test_stack.yml
+ when: docker_api_version is version('1.25', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_stack tests!"
+ when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/tasks/test_stack.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/tasks/test_stack.yml
new file mode 100644
index 00000000..d1f332c2
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/tasks/test_stack.yml
@@ -0,0 +1,113 @@
+---
+- block:
+ - name: Make sure we're not already using Docker swarm
+ docker_swarm:
+ state: absent
+ force: true
+
+ - name: Create a Swarm cluster
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address}}"
+
+ - name: install docker_stack python requirements
+ pip:
+ name: jsondiff,pyyaml
+
+ - name: Create a stack without name
+ register: output
+ docker_stack:
+ state: present
+ ignore_errors: yes
+
+ - name: assert failure when name not set
+ assert:
+ that:
+ - output is failed
+ - 'output.msg == "missing required arguments: name"'
+
+ - name: Create a stack without compose
+ register: output
+ docker_stack:
+ name: test_stack
+ ignore_errors: yes
+
+ - name: assert failure when compose not set
+ assert:
+ that:
+ - output is failed
+ - 'output.msg == "compose parameter must be a list containing at least one element"'
+
+ - name: Ensure stack is absent
+ register: output
+ docker_stack:
+ state: absent
+ name: test_stack
+ absent_retries: 30
+
+ - name: Template compose files
+ template:
+ src: "{{item}}"
+ dest: "{{output_dir}}/"
+ with_items:
+ - stack_compose_base.yml
+ - stack_compose_overrides.yml
+
+ - name: Create stack with compose file
+ register: output
+ docker_stack:
+ state: present
+ name: test_stack
+ compose:
+ - "{{output_dir}}/stack_compose_base.yml"
+
+ - name: assert test_stack changed on stack creation with compose file
+ assert:
+ that:
+ - output is changed
+
+ # FIXME: updating the stack prevents leaving the swarm on Shippable
+ #- name: Update stack with YAML
+ # register: output
+ # docker_stack:
+ # state: present
+ # name: test_stack
+ # compose:
+ # - "{{stack_compose_base}}"
+ # - "{{stack_compose_overrides}}"
+ #
+ #- name: assert test_stack correctly changed on update with yaml
+ # assert:
+ # that:
+ # - output is changed
+ # - output.stack_spec_diff == stack_update_expected_diff
+
+ - name: Delete stack
+ register: output
+ docker_stack:
+ state: absent
+ name: test_stack
+ absent_retries: 30
+
+ - name: assert delete of existing stack returns changed
+ assert:
+ that:
+ - output is changed
+
+ - name: Delete stack again
+ register: output
+ docker_stack:
+ state: absent
+ name: test_stack
+ absent_retries: 30
+
+ - name: assert state=absent idempotency
+ assert:
+ that:
+ - output is not changed
+
+ always:
+ - name: Remove a Swarm cluster
+ docker_swarm:
+ state: absent
+ force: true
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/templates/stack_compose_base.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/templates/stack_compose_base.yml
new file mode 100644
index 00000000..b5162d68
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/templates/stack_compose_base.yml
@@ -0,0 +1,5 @@
+version: '3'
+services:
+ busybox:
+ image: "{{ docker_test_image_busybox }}"
+ command: sleep 3600
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/templates/stack_compose_overrides.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/templates/stack_compose_overrides.yml
new file mode 100644
index 00000000..1b81c71b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/templates/stack_compose_overrides.yml
@@ -0,0 +1,5 @@
+version: '3'
+services:
+ busybox:
+ environment:
+ envvar: value
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/vars/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/vars/main.yml
new file mode 100644
index 00000000..7751c86e
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack/vars/main.yml
@@ -0,0 +1,15 @@
+stack_compose_base:
+ version: '3'
+ services:
+ busybox:
+ image: "{{ docker_test_image_busybox }}"
+ command: sleep 3600
+
+stack_compose_overrides:
+ version: '3'
+ services:
+ busybox:
+ environment:
+ envvar: value
+
+stack_update_expected_diff: '{"test_stack_busybox": {"TaskTemplate": {"ContainerSpec": {"Env": ["envvar=value"]}}}}'
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/aliases
new file mode 100644
index 00000000..ca7c9128
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group2
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/tasks/main.yml
new file mode 100644
index 00000000..b499f80d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/tasks/main.yml
@@ -0,0 +1,10 @@
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- include_tasks: test_stack_info.yml
+ when: docker_api_version is version('1.25', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_stack tests!"
+ when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/tasks/test_stack_info.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/tasks/test_stack_info.yml
new file mode 100644
index 00000000..a2a39727
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/tasks/test_stack_info.yml
@@ -0,0 +1,75 @@
+---
+- block:
+ - name: Make sure we're not already using Docker swarm
+ docker_swarm:
+ state: absent
+ force: true
+
+ - name: Get docker_stack_info when docker is not running in swarm mode
+ docker_stack_info:
+ ignore_errors: true
+ register: output
+
+ - name: Assert failure when called when swarm is not running
+ assert:
+ that:
+ - 'output is failed'
+ - '"Error running docker stack" in output.msg'
+
+ - name: Create a swarm cluster
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address}}"
+
+ - name: Get docker_stack_info when docker is running and not stack available
+ docker_stack_info:
+ register: output
+
+ - name: Assert stack facts
+ assert:
+ that:
+ - 'output.results | type_debug == "list"'
+ - 'output.results | length == 0'
+
+ - name: Template compose files
+ template:
+ src: "{{ item }}"
+ dest: "{{ output_dir }}/"
+ with_items:
+ - stack_compose_base.yml
+ - stack_compose_overrides.yml
+
+ - name: Install docker_stack python requirements
+ pip:
+ name: jsondiff,pyyaml
+
+ - name: Create stack with compose file
+ register: output
+ docker_stack:
+ state: present
+ name: test_stack
+ compose:
+ - "{{ output_dir }}/stack_compose_base.yml"
+
+ - name: Assert test_stack changed on stack creation with compose file
+ assert:
+ that:
+ - output is changed
+
+ - name: Get docker_stack_info when docker is running
+ docker_stack_info:
+ register: output
+
+ - name: assert stack facts
+ assert:
+ that:
+ - 'output.results | type_debug == "list"'
+ - 'output.results[0].Name == "test_stack"'
+ - 'output.results[0].Orchestrator == "Swarm"'
+ - 'output.results[0].Services == "1"'
+
+ always:
+ - name: Cleanup
+ docker_swarm:
+ state: absent
+ force: true
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/templates/stack_compose_base.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/templates/stack_compose_base.yml
new file mode 100644
index 00000000..b5162d68
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/templates/stack_compose_base.yml
@@ -0,0 +1,5 @@
+version: '3'
+services:
+ busybox:
+ image: "{{ docker_test_image_busybox }}"
+ command: sleep 3600
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/templates/stack_compose_overrides.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/templates/stack_compose_overrides.yml
new file mode 100644
index 00000000..1b81c71b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/templates/stack_compose_overrides.yml
@@ -0,0 +1,5 @@
+version: '3'
+services:
+ busybox:
+ environment:
+ envvar: value
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/vars/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/vars/main.yml
new file mode 100644
index 00000000..7751c86e
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_info/vars/main.yml
@@ -0,0 +1,15 @@
+stack_compose_base:
+ version: '3'
+ services:
+ busybox:
+ image: "{{ docker_test_image_busybox }}"
+ command: sleep 3600
+
+stack_compose_overrides:
+ version: '3'
+ services:
+ busybox:
+ environment:
+ envvar: value
+
+stack_update_expected_diff: '{"test_stack_busybox": {"TaskTemplate": {"ContainerSpec": {"Env": ["envvar=value"]}}}}'
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/aliases
new file mode 100644
index 00000000..ca7c9128
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group2
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/tasks/main.yml
new file mode 100644
index 00000000..0990e90b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/tasks/main.yml
@@ -0,0 +1,10 @@
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- include_tasks: test_stack_task_info.yml
+ when: docker_api_version is version('1.25', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_stack tests!"
+ when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/tasks/test_stack_task_info.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/tasks/test_stack_task_info.yml
new file mode 100644
index 00000000..88e9eca3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/tasks/test_stack_task_info.yml
@@ -0,0 +1,84 @@
+---
+- block:
+ - name: Make sure we're not already using Docker swarm
+ docker_swarm:
+ state: absent
+ force: true
+
+ - name: Get docker_stack_info when docker is not running in swarm mode
+ docker_stack_info:
+ ignore_errors: true
+ register: output
+
+ - name: Assert failure when called when swarm is not running
+ assert:
+ that:
+ - 'output is failed'
+ - '"Error running docker stack" in output.msg'
+
+ - name: Create a swarm cluster
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ ansible_default_ipv4.address }}"
+
+ - name: Get docker_stack_info when docker is running and not stack available
+ docker_stack_info:
+ register: output
+
+ - name: Assert stack facts
+ assert:
+ that:
+ - 'output.results | type_debug == "list"'
+ - 'output.results | length == 0'
+
+ - name: Template compose files
+ template:
+ src: "{{ item }}"
+ dest: "{{ output_dir }}/"
+ with_items:
+ - stack_compose_base.yml
+ - stack_compose_overrides.yml
+
+ - name: Install docker_stack python requirements
+ pip:
+ name: jsondiff,pyyaml
+
+ - name: Create stack with compose file
+ register: output
+ docker_stack:
+ state: present
+ name: test_stack
+ compose:
+ - "{{ output_dir }}/stack_compose_base.yml"
+
+ - name: Assert test_stack changed on stack creation with compose file
+ assert:
+ that:
+ - output is changed
+
+ - name: Wait a bit to make sure stack is running
+ pause:
+ seconds: 5
+
+ - name: Get docker_stack_info when docker is running
+ docker_stack_info:
+ register: output
+
+ - name: Get docker_stack_task_info first element
+ docker_stack_task_info:
+ name: "{{ output.results[0].Name }}"
+ register: output
+
+ - name: assert stack facts
+ assert:
+ that:
+ - 'output.results | type_debug == "list"'
+ - 'output.results[0].DesiredState == "Running"'
+ - 'output.results[0].Image == docker_test_image_busybox'
+ - 'output.results[0].Name == "test_stack_busybox.1"'
+
+ always:
+ - name: Cleanup
+ docker_swarm:
+ state: absent
+ force: true
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/templates/stack_compose_base.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/templates/stack_compose_base.yml
new file mode 100644
index 00000000..b5162d68
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/templates/stack_compose_base.yml
@@ -0,0 +1,5 @@
+version: '3'
+services:
+ busybox:
+ image: "{{ docker_test_image_busybox }}"
+ command: sleep 3600
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/templates/stack_compose_overrides.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/templates/stack_compose_overrides.yml
new file mode 100644
index 00000000..1b81c71b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/templates/stack_compose_overrides.yml
@@ -0,0 +1,5 @@
+version: '3'
+services:
+ busybox:
+ environment:
+ envvar: value
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/vars/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/vars/main.yml
new file mode 100644
index 00000000..7751c86e
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_stack_task_info/vars/main.yml
@@ -0,0 +1,15 @@
+stack_compose_base:
+ version: '3'
+ services:
+ busybox:
+ image: "{{ docker_test_image_busybox }}"
+ command: sleep 3600
+
+stack_compose_overrides:
+ version: '3'
+ services:
+ busybox:
+ environment:
+ envvar: value
+
+stack_update_expected_diff: '{"test_stack_busybox": {"TaskTemplate": {"ContainerSpec": {"Env": ["envvar=value"]}}}}'
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/aliases
new file mode 100644
index 00000000..3bab2a23
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/aliases
@@ -0,0 +1,3 @@
+shippable/posix/group1
+destructive
+needs/root
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/meta/main.yml
new file mode 100644
index 00000000..078660a8
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/meta/main.yml
@@ -0,0 +1,4 @@
+---
+dependencies:
+ - setup_docker
+ - setup_openssl
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/cleanup.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/cleanup.yml
new file mode 100644
index 00000000..3e19bfcd
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/cleanup.yml
@@ -0,0 +1,35 @@
+- name: CLEANUP | Leave Docker Swarm
+ docker_swarm:
+ state: absent
+ force: true
+ ignore_errors: yes
+ register: leave_swarm
+
+- name: CLEANUP | Kill Docker and cleanup
+ when: leave_swarm is failed
+ block:
+ - name: CLEANUP | Kill docker daemon
+ command: systemctl kill -s 9 docker
+ become: yes
+
+ - name: CLEANUP | Clear out /var/lib/docker
+ shell: rm -rf /var/lib/docker/*
+ args:
+ warn: no
+
+ - name: CLEANUP | Start docker daemon
+ service:
+ name: docker
+ state: started
+ become: yes
+
+ - name: CLEANUP | Wait for docker daemon to be fully started
+ command: docker ps
+ register: result
+ until: result is success
+ retries: 10
+
+ - name: CLEANUP | Leave Docker Swarm
+ docker_swarm:
+ state: absent
+ force: true
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/main.yml
new file mode 100644
index 00000000..597b71a8
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/main.yml
@@ -0,0 +1,23 @@
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- name: Run Docker Swarm tests
+ when:
+ - docker_py_version is version('1.10.0', '>=')
+ - docker_api_version is version('1.25', '>=')
+
+ block:
+ - include_tasks: "{{ item }}"
+ with_fileglob:
+ - 'tests/*.yml'
+
+ always:
+ - import_tasks: cleanup.yml
+
+- fail:
+ msg: "Too old docker / docker-py version to run docker_swarm tests!"
+ when:
+ - not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.25', '>='))
+ - (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/run-test.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/run-test.yml
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/run-test.yml
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/basic.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/basic.yml
new file mode 100644
index 00000000..4e9005fc
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/basic.yml
@@ -0,0 +1,158 @@
+- debug:
+ msg: Running tests/basic.yml
+
+####################################################################
+## Errors ##########################################################
+####################################################################
+- name: Test parameters with state=join
+ docker_swarm:
+ state: join
+ ignore_errors: yes
+ register: output
+
+- name: assert failure when called with state=join and no remote_addrs,join_token
+ assert:
+ that:
+ - 'output.failed'
+ - 'output.msg == "state is join but all of the following are missing: remote_addrs, join_token"'
+
+- name: Test parameters with state=remove
+ docker_swarm:
+ state: remove
+ ignore_errors: yes
+ register: output
+
+- name: assert failure when called with state=remove and no node_id
+ assert:
+ that:
+ - 'output.failed'
+ - 'output.msg == "state is remove but all of the following are missing: node_id"'
+
+####################################################################
+## Creation ########################################################
+####################################################################
+
+- name: Create a Swarm cluster (check mode)
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: Create a Swarm cluster
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ diff: yes
+ register: output_2
+
+- name: Create a Swarm cluster (idempotent)
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ diff: yes
+ register: output_3
+
+- name: Create a Swarm cluster (idempotent, check mode)
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: Create a Swarm cluster (force re-create)
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ force: yes
+ diff: yes
+ register: output_5
+
+- name: Create a Swarm cluster (force re-create, check mode)
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ force: yes
+ check_mode: yes
+ diff: yes
+ register: output_6
+
+- name: assert changed when create a new swarm cluster
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] | regex_search("New Swarm cluster created: ")'
+ - 'output_2.swarm_facts.JoinTokens.Manager'
+ - 'output_2.swarm_facts.JoinTokens.Worker'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+ - 'output_5 is changed'
+ - 'output_5.diff.before is defined'
+ - 'output_5.diff.after is defined'
+ - 'output_6 is changed'
+ - 'output_6.diff.before is defined'
+ - 'output_6.diff.after is defined'
+
+####################################################################
+## Removal #########################################################
+####################################################################
+
+- name: Remove a Swarm cluster (check mode)
+ docker_swarm:
+ state: absent
+ force: true
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: Remove a Swarm cluster
+ docker_swarm:
+ state: absent
+ force: true
+ diff: yes
+ register: output_2
+
+- name: Remove a Swarm cluster (idempotent)
+ docker_swarm:
+ state: absent
+ force: true
+ diff: yes
+ register: output_3
+
+- name: Remove a Swarm cluster (idempotent, check mode)
+ docker_swarm:
+ state: absent
+ force: true
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: assert changed when remove a swarm cluster
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Node has left the swarm cluster"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+
+- include_tasks: cleanup.yml
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/options-ca.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/options-ca.yml
new file mode 100644
index 00000000..6221e3e7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/options-ca.yml
@@ -0,0 +1,114 @@
+- debug:
+ msg: Running tests/options-ca.yml
+- name: options-ca
+ when: cryptography_version.stdout is version('1.6', '>=')
+ block:
+ - name: Generate privatekey
+ loop:
+ - key1
+ - key2
+ loop_control:
+ loop_var: key
+ community.crypto.openssl_privatekey:
+ path: '{{ output_dir }}/ansible_{{ key }}.key'
+ size: 2048
+ mode: '0666'
+ - name: Generate CSR
+ loop:
+ - key1
+ - key2
+ loop_control:
+ loop_var: key
+ community.crypto.openssl_csr:
+ path: '{{ output_dir }}/ansible_{{ key }}.csr'
+ privatekey_path: '{{ output_dir }}/ansible_{{ key }}.key'
+ basic_constraints:
+ - CA:TRUE
+ key_usage:
+ - keyCertSign
+ - name: Generate self-signed certificate
+ loop:
+ - key1
+ - key2
+ loop_control:
+ loop_var: key
+ community.crypto.openssl_certificate:
+ path: '{{ output_dir }}/ansible_{{ key }}.pem'
+ privatekey_path: '{{ output_dir }}/ansible_{{ key }}.key'
+ csr_path: '{{ output_dir }}/ansible_{{ key }}.csr'
+ provider: selfsigned
+ - name: signing_ca_cert and signing_ca_key (check mode)
+ docker_swarm:
+ advertise_addr: '{{ansible_default_ipv4.address | default(''127.0.0.1'')}}'
+ state: present
+ signing_ca_cert: '{{ lookup(''file'', output_dir ~ ''/ansible_key1.pem'') }}'
+ signing_ca_key: '{{ lookup(''file'', output_dir ~ ''/ansible_key1.key'') }}'
+ timeout: 120
+ check_mode: true
+ diff: true
+ register: output_1
+ ignore_errors: true
+ - name: signing_ca_cert and signing_ca_key
+ docker_swarm:
+ advertise_addr: '{{ansible_default_ipv4.address | default(''127.0.0.1'')}}'
+ state: present
+ signing_ca_cert: '{{ lookup(''file'', output_dir ~ ''/ansible_key1.pem'') }}'
+ signing_ca_key: '{{ lookup(''file'', output_dir ~ ''/ansible_key1.key'') }}'
+ timeout: 120
+ diff: true
+ register: output_2
+ ignore_errors: true
+ - name: Private key
+ debug: msg="{{ lookup('file', output_dir ~ '/ansible_key1.key') }}"
+ - name: Cert
+ debug: msg="{{ lookup('file', output_dir ~ '/ansible_key1.pem') }}"
+ - docker_swarm_info: null
+ register: output
+ ignore_errors: true
+ - debug: var=output
+ - name: signing_ca_cert and signing_ca_key (change, check mode)
+ docker_swarm:
+ state: present
+ signing_ca_cert: '{{ lookup(''file'', output_dir ~ ''/ansible_key2.pem'') }}'
+ signing_ca_key: '{{ lookup(''file'', output_dir ~ ''/ansible_key2.key'') }}'
+ timeout: 120
+ check_mode: true
+ diff: true
+ register: output_5
+ ignore_errors: true
+ - name: signing_ca_cert and signing_ca_key (change)
+ docker_swarm:
+ state: present
+ signing_ca_cert: '{{ lookup(''file'', output_dir ~ ''/ansible_key2.pem'') }}'
+ signing_ca_key: '{{ lookup(''file'', output_dir ~ ''/ansible_key2.key'') }}'
+ timeout: 120
+ diff: true
+ register: output_6
+ ignore_errors: true
+ - name: assert signing_ca_cert and signing_ca_key
+ assert:
+ that:
+ - output_1 is changed
+ - 'output_1.actions[0] | regex_search("New Swarm cluster created: ")'
+ - output_1.diff.before is defined
+ - output_1.diff.after is defined
+ - output_2 is changed
+ - 'output_2.actions[0] | regex_search("New Swarm cluster created: ")'
+ - output_2.diff.before is defined
+ - output_2.diff.after is defined
+ - output_5 is changed
+ - output_5.actions[0] == "Swarm cluster updated"
+ - output_5.diff.before is defined
+ - output_5.diff.after is defined
+ - output_6 is changed
+ - output_6.actions[0] == "Swarm cluster updated"
+ - output_6.diff.before is defined
+ - output_6.diff.after is defined
+ when: docker_py_version is version('2.6.0', '>=')
+ - assert:
+ that:
+ - output_1 is failed
+ - ('version is ' ~ docker_py_version ~ ' ') in output_1.msg
+ - '''Minimum version required is 2.6.0 '' in output_1.msg'
+ when: docker_py_version is version('2.6.0', '<')
+ - include_tasks: cleanup.yml
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/options.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/options.yml
new file mode 100644
index 00000000..c23ab3a6
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/options.yml
@@ -0,0 +1,1158 @@
+- debug:
+ msg: Running tests/options.yml
+
+- name: Create a Swarm cluster
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ name: default
+ diff: yes
+
+####################################################################
+## autolock_managers ###############################################
+####################################################################
+
+- name: autolock_managers (check mode)
+ docker_swarm:
+ state: present
+ autolock_managers: yes
+ check_mode: yes
+ diff: yes
+ register: output_1
+ ignore_errors: yes
+
+- name: autolock_managers
+ docker_swarm:
+ state: present
+ autolock_managers: yes
+ diff: yes
+ register: output_2
+ ignore_errors: yes
+
+- name: autolock_managers (idempotent)
+ docker_swarm:
+ state: present
+ autolock_managers: yes
+ diff: yes
+ register: output_3
+ ignore_errors: yes
+
+- name: autolock_managers (idempotent, check mode)
+ docker_swarm:
+ state: present
+ autolock_managers: yes
+ check_mode: yes
+ diff: yes
+ register: output_4
+ ignore_errors: yes
+
+- name: autolock_managers (change, check mode)
+ docker_swarm:
+ state: present
+ autolock_managers: no
+ check_mode: yes
+ diff: yes
+ register: output_5
+ ignore_errors: yes
+
+- name: autolock_managers (change)
+ docker_swarm:
+ state: present
+ autolock_managers: no
+ diff: yes
+ register: output_6
+ ignore_errors: yes
+
+- name: autolock_managers (force new swarm)
+ docker_swarm:
+ state: present
+ force: yes
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ autolock_managers: yes
+ diff: yes
+ register: output_7
+ ignore_errors: yes
+
+- name: assert autolock_managers changes
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.actions[0] == "Swarm cluster updated"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Swarm cluster updated"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.actions[0] == "No modification"'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.actions[0] == "No modification"'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+ - 'output_5 is changed'
+ - 'output_5.actions[0] == "Swarm cluster updated"'
+ - 'output_5.diff.before is defined'
+ - 'output_5.diff.after is defined'
+ - 'output_6 is changed'
+ - 'output_6.actions[0] == "Swarm cluster updated"'
+ - 'output_6.diff.before is defined'
+ - 'output_6.diff.after is defined'
+ when: docker_py_version is version('2.6.0', '>=')
+
+- name: assert UnlockKey in swarm_facts
+ assert:
+ that:
+ - 'output_2.swarm_facts.UnlockKey'
+ - 'output_3.swarm_facts.UnlockKey is none'
+ - 'output_6.swarm_facts.UnlockKey is none'
+ - 'output_7.swarm_facts.UnlockKey'
+ when: docker_py_version is version('2.7.0', '>=')
+
+- assert:
+ that:
+ - output_1 is failed
+ - "('version is ' ~ docker_py_version ~ ' ') in output_1.msg"
+ - "'Minimum version required is 2.6.0 ' in output_1.msg"
+ when: docker_py_version is version('2.6.0', '<')
+
+####################################################################
+## ca_force_rotate #################################################
+####################################################################
+
+- name: ca_force_rotate (check mode)
+ docker_swarm:
+ state: present
+ ca_force_rotate: 1
+ check_mode: yes
+ diff: yes
+ register: output_1
+ ignore_errors: yes
+
+- name: ca_force_rotate
+ docker_swarm:
+ state: present
+ ca_force_rotate: 1
+ diff: yes
+ register: output_2
+ ignore_errors: yes
+
+- name: ca_force_rotate (idempotent)
+ docker_swarm:
+ state: present
+ ca_force_rotate: 1
+ diff: yes
+ register: output_3
+ ignore_errors: yes
+
+- name: ca_force_rotate (idempotent, check mode)
+ docker_swarm:
+ state: present
+ ca_force_rotate: 1
+ check_mode: yes
+ diff: yes
+ register: output_4
+ ignore_errors: yes
+
+- name: ca_force_rotate (change, check mode)
+ docker_swarm:
+ state: present
+ ca_force_rotate: 0
+ check_mode: yes
+ diff: yes
+ register: output_5
+ ignore_errors: yes
+
+- name: ca_force_rotate (change)
+ docker_swarm:
+ state: present
+ ca_force_rotate: 0
+ diff: yes
+ register: output_6
+ ignore_errors: yes
+
+- name: assert ca_force_rotate changes
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.actions[0] == "Swarm cluster updated"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Swarm cluster updated"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.actions[0] == "No modification"'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.actions[0] == "No modification"'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+ - 'output_5 is changed'
+ - 'output_5.actions[0] == "Swarm cluster updated"'
+ - 'output_5.diff.before is defined'
+ - 'output_5.diff.after is defined'
+ - 'output_6 is changed'
+ - 'output_6.actions[0] == "Swarm cluster updated"'
+ - 'output_6.diff.before is defined'
+ - 'output_6.diff.after is defined'
+ when: docker_py_version is version('2.6.0', '>=')
+- assert:
+ that:
+ - output_1 is failed
+ - "('version is ' ~ docker_py_version ~ ' ') in output_1.msg"
+ - "'Minimum version required is 2.6.0 ' in output_1.msg"
+ when: docker_py_version is version('2.6.0', '<')
+
+####################################################################
+## dispatcher_heartbeat_period #####################################
+####################################################################
+
+- name: dispatcher_heartbeat_period (check mode)
+ docker_swarm:
+ state: present
+ dispatcher_heartbeat_period: 10
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: dispatcher_heartbeat_period
+ docker_swarm:
+ state: present
+ dispatcher_heartbeat_period: 10
+ diff: yes
+ register: output_2
+
+- name: dispatcher_heartbeat_period (idempotent)
+ docker_swarm:
+ state: present
+ dispatcher_heartbeat_period: 10
+ diff: yes
+ register: output_3
+
+- name: dispatcher_heartbeat_period (idempotent, check mode)
+ docker_swarm:
+ state: present
+ dispatcher_heartbeat_period: 10
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: dispatcher_heartbeat_period (change, check mode)
+ docker_swarm:
+ state: present
+ dispatcher_heartbeat_period: 23
+ check_mode: yes
+ diff: yes
+ register: output_5
+
+- name: dispatcher_heartbeat_period (change)
+ docker_swarm:
+ state: present
+ dispatcher_heartbeat_period: 23
+ diff: yes
+ register: output_6
+
+- name: assert dispatcher_heartbeat_period changes
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.actions[0] == "Swarm cluster updated"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Swarm cluster updated"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.actions[0] == "No modification"'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.actions[0] == "No modification"'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+ - 'output_5 is changed'
+ - 'output_5.actions[0] == "Swarm cluster updated"'
+ - 'output_5.diff.before is defined'
+ - 'output_5.diff.after is defined'
+ - 'output_6 is changed'
+ - 'output_6.actions[0] == "Swarm cluster updated"'
+ - 'output_6.diff.before is defined'
+ - 'output_6.diff.after is defined'
+
+####################################################################
+## election_tick ###################################################
+####################################################################
+
+- name: election_tick (check mode)
+ docker_swarm:
+ state: present
+ election_tick: 20
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: election_tick
+ docker_swarm:
+ state: present
+ election_tick: 20
+ diff: yes
+ register: output_2
+
+- name: election_tick (idempotent)
+ docker_swarm:
+ state: present
+ election_tick: 20
+ diff: yes
+ register: output_3
+
+- name: election_tick (idempotent, check mode)
+ docker_swarm:
+ state: present
+ election_tick: 20
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: election_tick (change, check mode)
+ docker_swarm:
+ state: present
+ election_tick: 5
+ check_mode: yes
+ diff: yes
+ register: output_5
+
+- name: election_tick (change)
+ docker_swarm:
+ state: present
+ election_tick: 5
+ diff: yes
+ register: output_6
+
+- name: assert election_tick changes
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.actions[0] == "Swarm cluster updated"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Swarm cluster updated"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.actions[0] == "No modification"'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.actions[0] == "No modification"'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+ - 'output_5 is changed'
+ - 'output_5.actions[0] == "Swarm cluster updated"'
+ - 'output_5.diff.before is defined'
+ - 'output_5.diff.after is defined'
+ - 'output_6 is changed'
+ - 'output_6.actions[0] == "Swarm cluster updated"'
+ - 'output_6.diff.before is defined'
+ - 'output_6.diff.after is defined'
+
+####################################################################
+## heartbeat_tick ##################################################
+####################################################################
+
+- name: heartbeat_tick (check mode)
+ docker_swarm:
+ state: present
+ heartbeat_tick: 2
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: heartbeat_tick
+ docker_swarm:
+ state: present
+ heartbeat_tick: 2
+ diff: yes
+ register: output_2
+
+- name: heartbeat_tick (idempotent)
+ docker_swarm:
+ state: present
+ heartbeat_tick: 2
+ diff: yes
+ register: output_3
+
+- name: heartbeat_tick (idempotent, check mode)
+ docker_swarm:
+ state: present
+ heartbeat_tick: 2
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: heartbeat_tick (change, check mode)
+ docker_swarm:
+ state: present
+ heartbeat_tick: 3
+ check_mode: yes
+ diff: yes
+ register: output_5
+
+- name: heartbeat_tick (change)
+ docker_swarm:
+ state: present
+ heartbeat_tick: 3
+ diff: yes
+ register: output_6
+
+- name: assert heartbeat_tick changes
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.actions[0] == "Swarm cluster updated"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Swarm cluster updated"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.actions[0] == "No modification"'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.actions[0] == "No modification"'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+ - 'output_5 is changed'
+ - 'output_5.actions[0] == "Swarm cluster updated"'
+ - 'output_5.diff.before is defined'
+ - 'output_5.diff.after is defined'
+ - 'output_6 is changed'
+ - 'output_6.actions[0] == "Swarm cluster updated"'
+ - 'output_6.diff.before is defined'
+ - 'output_6.diff.after is defined'
+
+####################################################################
+## keep_old_snapshots ##############################################
+####################################################################
+- name: keep_old_snapshots (check mode)
+ docker_swarm:
+ state: present
+ keep_old_snapshots: 1
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: keep_old_snapshots
+ docker_swarm:
+ state: present
+ keep_old_snapshots: 1
+ diff: yes
+ register: output_2
+
+- name: keep_old_snapshots (idempotent)
+ docker_swarm:
+ state: present
+ keep_old_snapshots: 1
+ diff: yes
+ register: output_3
+
+- name: keep_old_snapshots (idempotent, check mode)
+ docker_swarm:
+ state: present
+ keep_old_snapshots: 1
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: keep_old_snapshots (change, check mode)
+ docker_swarm:
+ state: present
+ keep_old_snapshots: 2
+ check_mode: yes
+ diff: yes
+ register: output_5
+
+- name: keep_old_snapshots (change)
+ docker_swarm:
+ state: present
+ keep_old_snapshots: 2
+ diff: yes
+ register: output_6
+
+- name: assert keep_old_snapshots changes
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.actions[0] == "Swarm cluster updated"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Swarm cluster updated"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.actions[0] == "No modification"'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.actions[0] == "No modification"'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+ - 'output_5 is changed'
+ - 'output_5.actions[0] == "Swarm cluster updated"'
+ - 'output_5.diff.before is defined'
+ - 'output_5.diff.after is defined'
+ - 'output_6 is changed'
+ - 'output_6.actions[0] == "Swarm cluster updated"'
+ - 'output_6.diff.before is defined'
+ - 'output_6.diff.after is defined'
+
+####################################################################
+## labels ##########################################################
+####################################################################
+- name: labels (check mode)
+ docker_swarm:
+ state: present
+ labels:
+ a: v1
+ b: v2
+ check_mode: yes
+ diff: yes
+ register: output_1
+ ignore_errors: yes
+
+- name: labels
+ docker_swarm:
+ state: present
+ labels:
+ a: v1
+ b: v2
+ diff: yes
+ register: output_2
+ ignore_errors: yes
+
+- name: labels (idempotent)
+ docker_swarm:
+ state: present
+ labels:
+ a: v1
+ b: v2
+ diff: yes
+ register: output_3
+ ignore_errors: yes
+
+- name: labels (idempotent, check mode)
+ docker_swarm:
+ state: present
+ labels:
+ a: v1
+ b: v2
+ check_mode: yes
+ diff: yes
+ register: output_4
+ ignore_errors: yes
+
+- name: labels (change, check mode)
+ docker_swarm:
+ state: present
+ labels:
+ a: v1
+ c: v3
+ check_mode: yes
+ diff: yes
+ register: output_5
+ ignore_errors: yes
+
+- name: labels (change)
+ docker_swarm:
+ state: present
+ labels:
+ a: v1
+ c: v3
+ diff: yes
+ register: output_6
+ ignore_errors: yes
+
+- name: labels (not specifying, check mode)
+ docker_swarm:
+ state: present
+ check_mode: yes
+ diff: yes
+ register: output_7
+ ignore_errors: yes
+
+- name: labels (not specifying)
+ docker_swarm:
+ state: present
+ diff: yes
+ register: output_8
+ ignore_errors: yes
+
+- name: labels (idempotency, check that labels are still there)
+ docker_swarm:
+ state: present
+ labels:
+ a: v1
+ c: v3
+ diff: yes
+ register: output_9
+ ignore_errors: yes
+
+- name: labels (empty, check mode)
+ docker_swarm:
+ state: present
+ labels: {}
+ check_mode: yes
+ diff: yes
+ register: output_10
+ ignore_errors: yes
+
+- name: labels (empty)
+ docker_swarm:
+ state: present
+ labels: {}
+ diff: yes
+ register: output_11
+ ignore_errors: yes
+
+- name: labels (empty, idempotent, check mode)
+ docker_swarm:
+ state: present
+ labels: {}
+ check_mode: yes
+ diff: yes
+ register: output_12
+ ignore_errors: yes
+
+- name: labels (empty, idempotent)
+ docker_swarm:
+ state: present
+ labels: {}
+ diff: yes
+ register: output_13
+ ignore_errors: yes
+
+- name: assert labels changes
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.actions[0] == "Swarm cluster updated"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Swarm cluster updated"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.actions[0] == "No modification"'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.actions[0] == "No modification"'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+ - 'output_5 is changed'
+ - 'output_5.actions[0] == "Swarm cluster updated"'
+ - 'output_5.diff.before is defined'
+ - 'output_5.diff.after is defined'
+ - 'output_6 is changed'
+ - 'output_6.actions[0] == "Swarm cluster updated"'
+ - 'output_6.diff.before is defined'
+ - 'output_6.diff.after is defined'
+ - 'output_7 is not changed'
+ - 'output_7.actions[0] == "No modification"'
+ - 'output_7.diff.before is defined'
+ - 'output_7.diff.after is defined'
+ - 'output_8 is not changed'
+ - 'output_8.actions[0] == "No modification"'
+ - 'output_8.diff.before is defined'
+ - 'output_8.diff.after is defined'
+ - 'output_9 is not changed'
+ - 'output_9.actions[0] == "No modification"'
+ - 'output_9.diff.before is defined'
+ - 'output_9.diff.after is defined'
+ - 'output_10 is changed'
+ - 'output_10.actions[0] == "Swarm cluster updated"'
+ - 'output_10.diff.before is defined'
+ - 'output_10.diff.after is defined'
+ - 'output_11 is changed'
+ - 'output_11.actions[0] == "Swarm cluster updated"'
+ - 'output_11.diff.before is defined'
+ - 'output_11.diff.after is defined'
+ - 'output_12 is not changed'
+ - 'output_12.actions[0] == "No modification"'
+ - 'output_12.diff.before is defined'
+ - 'output_12.diff.after is defined'
+ - 'output_13 is not changed'
+ - 'output_13.actions[0] == "No modification"'
+ - 'output_13.diff.before is defined'
+ - 'output_13.diff.after is defined'
+ when: docker_py_version is version('2.6.0', '>=')
+- assert:
+ that:
+ - output_1 is failed
+ - "('version is ' ~ docker_py_version ~ ' ') in output_1.msg"
+ - "'Minimum version required is 2.6.0 ' in output_1.msg"
+ when: docker_py_version is version('2.6.0', '<')
+
+####################################################################
+## log_entries_for_slow_followers ##################################
+####################################################################
+- name: log_entries_for_slow_followers (check mode)
+ docker_swarm:
+ state: present
+ log_entries_for_slow_followers: 42
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: log_entries_for_slow_followers
+ docker_swarm:
+ state: present
+ log_entries_for_slow_followers: 42
+ diff: yes
+ register: output_2
+
+- name: log_entries_for_slow_followers (idempotent)
+ docker_swarm:
+ state: present
+ log_entries_for_slow_followers: 42
+ diff: yes
+ register: output_3
+
+- name: log_entries_for_slow_followers (idempotent, check mode)
+ docker_swarm:
+ state: present
+ log_entries_for_slow_followers: 42
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: log_entries_for_slow_followers (change, check mode)
+ docker_swarm:
+ state: present
+ log_entries_for_slow_followers: 23
+ check_mode: yes
+ diff: yes
+ register: output_5
+
+- name: log_entries_for_slow_followers (change)
+ docker_swarm:
+ state: present
+ log_entries_for_slow_followers: 23
+ diff: yes
+ register: output_6
+
+- name: assert log_entries_for_slow_followers changes
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.actions[0] == "Swarm cluster updated"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Swarm cluster updated"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.actions[0] == "No modification"'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.actions[0] == "No modification"'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+ - 'output_5 is changed'
+ - 'output_5.actions[0] == "Swarm cluster updated"'
+ - 'output_5.diff.before is defined'
+ - 'output_5.diff.after is defined'
+ - 'output_6 is changed'
+ - 'output_6.actions[0] == "Swarm cluster updated"'
+ - 'output_6.diff.before is defined'
+ - 'output_6.diff.after is defined'
+
+####################################################################
+## name ############################################################
+####################################################################
+- name: name (idempotent, check mode)
+ docker_swarm:
+ state: present
+ name: default
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: name (idempotent)
+ docker_swarm:
+ state: present
+ name: default
+ diff: yes
+ register: output_2
+
+# The name 'default' is hardcoded in docker swarm. Trying to change
+# it causes a failure. This might change in the future, so we also
+# accept a change for this test.
+- name: name (change, should fail)
+ docker_swarm:
+ state: present
+ name: foobar
+ diff: yes
+ register: output_3
+ ignore_errors: yes
+
+- name: assert name changes
+ assert:
+ that:
+ - 'output_1 is not changed'
+ - 'output_1.actions[0] == "No modification"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is not changed'
+ - 'output_2.actions[0] == "No modification"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is failed or output_3 is changed'
+
+####################################################################
+## node_cert_expiry ################################################
+####################################################################
+- name: node_cert_expiry (check mode)
+ docker_swarm:
+ state: present
+ node_cert_expiry: 7896000000000000
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: node_cert_expiry
+ docker_swarm:
+ state: present
+ node_cert_expiry: 7896000000000000
+ diff: yes
+ register: output_2
+
+- name: node_cert_expiry (idempotent)
+ docker_swarm:
+ state: present
+ node_cert_expiry: 7896000000000000
+ diff: yes
+ register: output_3
+
+- name: node_cert_expiry (idempotent, check mode)
+ docker_swarm:
+ state: present
+ node_cert_expiry: 7896000000000000
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: node_cert_expiry (change, check mode)
+ docker_swarm:
+ state: present
+ node_cert_expiry: 8766000000000000
+ check_mode: yes
+ diff: yes
+ register: output_5
+
+- name: node_cert_expiry (change)
+ docker_swarm:
+ state: present
+ node_cert_expiry: 8766000000000000
+ diff: yes
+ register: output_6
+
+- name: assert node_cert_expiry changes
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.actions[0] == "Swarm cluster updated"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Swarm cluster updated"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.actions[0] == "No modification"'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.actions[0] == "No modification"'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+ - 'output_5 is changed'
+ - 'output_5.actions[0] == "Swarm cluster updated"'
+ - 'output_5.diff.before is defined'
+ - 'output_5.diff.after is defined'
+ - 'output_6 is changed'
+ - 'output_6.actions[0] == "Swarm cluster updated"'
+ - 'output_6.diff.before is defined'
+ - 'output_6.diff.after is defined'
+
+####################################################################
+## rotate_manager_token ############################################
+####################################################################
+- name: rotate_manager_token (true, check mode)
+ docker_swarm:
+ state: present
+ rotate_manager_token: yes
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: rotate_manager_token (true)
+ docker_swarm:
+ state: present
+ rotate_manager_token: yes
+ diff: yes
+ register: output_2
+
+- name: rotate_manager_token (false, idempotent)
+ docker_swarm:
+ state: present
+ rotate_manager_token: no
+ diff: yes
+ register: output_3
+
+- name: rotate_manager_token (false, check mode)
+ docker_swarm:
+ state: present
+ rotate_manager_token: no
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: assert rotate_manager_token changes
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.actions[0] == "Swarm cluster updated"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Swarm cluster updated"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.actions[0] == "No modification"'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.actions[0] == "No modification"'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+
+####################################################################
+## rotate_worker_token #############################################
+####################################################################
+- name: rotate_worker_token (true, check mode)
+ docker_swarm:
+ state: present
+ rotate_worker_token: yes
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: rotate_worker_token (true)
+ docker_swarm:
+ state: present
+ rotate_worker_token: yes
+ diff: yes
+ register: output_2
+
+- name: rotate_worker_token (false, idempotent)
+ docker_swarm:
+ state: present
+ rotate_worker_token: no
+ diff: yes
+ register: output_3
+
+- name: rotate_worker_token (false, check mode)
+ docker_swarm:
+ state: present
+ rotate_worker_token: no
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: assert rotate_worker_token changes
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.actions[0] == "Swarm cluster updated"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Swarm cluster updated"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.actions[0] == "No modification"'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.actions[0] == "No modification"'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+
+####################################################################
+## snapshot_interval ###############################################
+####################################################################
+- name: snapshot_interval (check mode)
+ docker_swarm:
+ state: present
+ snapshot_interval: 12345
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: snapshot_interval
+ docker_swarm:
+ state: present
+ snapshot_interval: 12345
+ diff: yes
+ register: output_2
+
+- name: snapshot_interval (idempotent)
+ docker_swarm:
+ state: present
+ snapshot_interval: 12345
+ diff: yes
+ register: output_3
+
+- name: snapshot_interval (idempotent, check mode)
+ docker_swarm:
+ state: present
+ snapshot_interval: 12345
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: snapshot_interval (change, check mode)
+ docker_swarm:
+ state: present
+ snapshot_interval: 54321
+ check_mode: yes
+ diff: yes
+ register: output_5
+
+- name: snapshot_interval (change)
+ docker_swarm:
+ state: present
+ snapshot_interval: 54321
+ diff: yes
+ register: output_6
+
+- name: assert snapshot_interval changes
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.actions[0] == "Swarm cluster updated"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Swarm cluster updated"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.actions[0] == "No modification"'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.actions[0] == "No modification"'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+ - 'output_5 is changed'
+ - 'output_5.actions[0] == "Swarm cluster updated"'
+ - 'output_5.diff.before is defined'
+ - 'output_5.diff.after is defined'
+ - 'output_6 is changed'
+ - 'output_6.actions[0] == "Swarm cluster updated"'
+ - 'output_6.diff.before is defined'
+ - 'output_6.diff.after is defined'
+
+####################################################################
+## task_history_retention_limit ####################################
+####################################################################
+- name: task_history_retention_limit (check mode)
+ docker_swarm:
+ state: present
+ task_history_retention_limit: 23
+ check_mode: yes
+ diff: yes
+ register: output_1
+
+- name: task_history_retention_limit
+ docker_swarm:
+ state: present
+ task_history_retention_limit: 23
+ diff: yes
+ register: output_2
+
+- name: task_history_retention_limit (idempotent)
+ docker_swarm:
+ state: present
+ task_history_retention_limit: 23
+ diff: yes
+ register: output_3
+
+- name: task_history_retention_limit (idempotent, check mode)
+ docker_swarm:
+ state: present
+ task_history_retention_limit: 23
+ check_mode: yes
+ diff: yes
+ register: output_4
+
+- name: task_history_retention_limit (change, check mode)
+ docker_swarm:
+ state: present
+ task_history_retention_limit: 7
+ check_mode: yes
+ diff: yes
+ register: output_5
+
+- name: task_history_retention_limit (change)
+ docker_swarm:
+ state: present
+ task_history_retention_limit: 7
+ diff: yes
+ register: output_6
+
+- name: assert task_history_retention_limit changes
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_1.actions[0] == "Swarm cluster updated"'
+ - 'output_1.diff.before is defined'
+ - 'output_1.diff.after is defined'
+ - 'output_2 is changed'
+ - 'output_2.actions[0] == "Swarm cluster updated"'
+ - 'output_2.diff.before is defined'
+ - 'output_2.diff.after is defined'
+ - 'output_3 is not changed'
+ - 'output_3.actions[0] == "No modification"'
+ - 'output_3.diff.before is defined'
+ - 'output_3.diff.after is defined'
+ - 'output_4 is not changed'
+ - 'output_4.actions[0] == "No modification"'
+ - 'output_4.diff.before is defined'
+ - 'output_4.diff.after is defined'
+ - 'output_5 is changed'
+ - 'output_5.actions[0] == "Swarm cluster updated"'
+ - 'output_5.diff.before is defined'
+ - 'output_5.diff.after is defined'
+ - 'output_6 is changed'
+ - 'output_6.actions[0] == "Swarm cluster updated"'
+ - 'output_6.diff.before is defined'
+ - 'output_6.diff.after is defined'
+
+- include_tasks: cleanup.yml
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/remote-addr-pool.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/remote-addr-pool.yml
new file mode 100644
index 00000000..a900953e
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm/tasks/tests/remote-addr-pool.yml
@@ -0,0 +1,90 @@
+- debug:
+ msg: Running tests/remote-addr-pool.yml
+
+####################################################################
+## default_addr_pool ###############################################
+####################################################################
+
+- name: default_addr_pool
+ docker_swarm:
+ state: present
+ default_addr_pool:
+ - "2.0.0.0/16"
+ diff: yes
+ register: output_1
+ ignore_errors: yes
+
+- name: default_addr_pool (idempotent)
+ docker_swarm:
+ state: present
+ default_addr_pool:
+ - "2.0.0.0/16"
+ diff: yes
+ register: output_2
+ ignore_errors: yes
+
+- name: assert default_addr_pool
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_2 is not changed'
+ - 'output_2.swarm_facts.DefaultAddrPool == ["2.0.0.0/16"]'
+ when:
+ - docker_api_version is version('1.39', '>=')
+ - docker_py_version is version('4.0.0', '>=')
+
+- name: assert default_addr_pool failed when unsupported
+ assert:
+ that:
+ - 'output_1 is failed'
+ - "'Minimum version required' in output_1.msg"
+ when: docker_api_version is version('1.39', '<') or
+ docker_py_version is version('4.0.0', '<')
+
+####################################################################
+## subnet_size #####################################################
+####################################################################
+- name: Leave swarm
+ docker_swarm:
+ state: absent
+ force: yes
+ default_addr_pool:
+ - "2.0.0.0/16"
+ diff: yes
+
+- name: subnet_size
+ docker_swarm:
+ state: present
+ force: yes
+ subnet_size: 26
+ diff: yes
+ register: output_1
+ ignore_errors: yes
+
+- name: subnet_size (idempotent)
+ docker_swarm:
+ state: present
+ subnet_size: 26
+ diff: yes
+ register: output_2
+ ignore_errors: yes
+
+- name: assert subnet_size
+ assert:
+ that:
+ - 'output_1 is changed'
+ - 'output_2 is not changed'
+ - 'output_2.swarm_facts.SubnetSize == 26'
+ when:
+ - docker_api_version is version('1.39', '>=')
+ - docker_py_version is version('4.0.0', '>=')
+
+- name: assert subnet_size failed when unsupported
+ assert:
+ that:
+ - output_1 is failed
+ - "'Minimum version required' in output_1.msg"
+ when: docker_api_version is version('1.39', '<') or
+ docker_py_version is version('4.0.0', '<')
+
+- include_tasks: cleanup.yml
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/aliases
new file mode 100644
index 00000000..6eae8bd8
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group1
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/tasks/main.yml
new file mode 100644
index 00000000..1421701f
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/tasks/main.yml
@@ -0,0 +1,11 @@
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- include_tasks: test_swarm_info.yml
+ # Maximum of 1.24 (docker API version for docker_swarm_info) and 1.25 (docker API version for docker_swarm) is 1.25
+ when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.25', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_swarm_info tests!"
+ when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/tasks/test_swarm_info.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/tasks/test_swarm_info.yml
new file mode 100644
index 00000000..349d7cc5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_info/tasks/test_swarm_info.yml
@@ -0,0 +1,190 @@
+---
+- block:
+ - name: Make sure we're not already using Docker swarm
+ docker_swarm:
+ state: absent
+ force: true
+
+ - name: Try to get docker_swarm_info when docker is not running in swarm mode
+ docker_swarm_info:
+ ignore_errors: yes
+ register: output
+
+ - name: assert failure when called when swarm is not in use or not run on mamager node
+ assert:
+ that:
+ - 'output is failed'
+ - 'output.msg == "Error running docker swarm module: must run on swarm manager node"'
+ - 'output.can_talk_to_docker == true'
+ - 'output.docker_swarm_active == false'
+ - 'output.docker_swarm_manager == false'
+ - 'output.swarm_unlock_key is not defined'
+
+ - name: Create a Swarm cluster
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ register: output
+
+ - name: assert changed when create a new swarm cluster
+ assert:
+ that:
+ - 'output is changed'
+ - 'output.actions[0] | regex_search("New Swarm cluster created: ")'
+ - 'output.swarm_facts.JoinTokens.Manager'
+ - 'output.swarm_facts.JoinTokens.Worker'
+
+ - name: Try to get docker_swarm_info when docker is running in swarm mode and as manager
+ docker_swarm_info:
+ register: output
+
+ - name: assert creding docker swarm facts
+ assert:
+ that:
+ - 'output.swarm_facts.JoinTokens.Manager'
+ - 'output.swarm_facts.JoinTokens.Worker'
+ - 'output.swarm_facts.ID'
+ - 'output.can_talk_to_docker == true'
+ - 'output.docker_swarm_active == true'
+ - 'output.docker_swarm_manager == true'
+ - 'output.swarm_unlock_key is not defined'
+
+ - name: Try to get docker_swarm_info and list of nodes when docker is running in swarm mode and as manager
+ docker_swarm_info:
+ nodes: yes
+ register: output
+
+ - name: assert reding swarm facts with list of nodes option
+ assert:
+ that:
+ - 'output.swarm_facts.JoinTokens.Manager'
+ - 'output.swarm_facts.JoinTokens.Worker'
+ - 'output.swarm_facts.ID'
+ - 'output.nodes[0].ID is string'
+ - 'output.can_talk_to_docker == true'
+ - 'output.docker_swarm_active == true'
+ - 'output.docker_swarm_manager == true'
+ - 'output.swarm_unlock_key is not defined'
+
+ - name: Get local docker node name
+ set_fact:
+ localnodename: "{{ output.nodes[0].Hostname }}"
+
+
+ - name: Try to get docker_swarm_info and verbose list of nodes when docker is running in swarm mode and as manager
+ docker_swarm_info:
+ nodes: yes
+ verbose_output: yes
+ register: output
+
+ - name: assert reading swarm facts with list of nodes and versbose output options
+ assert:
+ that:
+ - 'output.swarm_facts.JoinTokens.Manager'
+ - 'output.swarm_facts.JoinTokens.Worker'
+ - 'output.swarm_facts.ID'
+ - 'output.nodes[0].ID is string'
+ - 'output.nodes[0].CreatedAt'
+ - 'output.can_talk_to_docker == true'
+ - 'output.docker_swarm_active == true'
+ - 'output.docker_swarm_manager == true'
+ - 'output.swarm_unlock_key is not defined'
+
+ - name: Try to get docker_swarm_info and list of nodes with filters providing existing node name
+ docker_swarm_info:
+ nodes: yes
+ nodes_filters:
+ name: "{{ localnodename }}"
+ register: output
+
+ - name: assert reading reading swarm facts and using node filter (random node name)
+ assert:
+ that:
+ - 'output.swarm_facts.JoinTokens.Manager'
+ - 'output.swarm_facts.JoinTokens.Worker'
+ - 'output.swarm_facts.ID'
+ - 'output.nodes | length == 1'
+ - 'output.can_talk_to_docker == true'
+ - 'output.docker_swarm_active == true'
+ - 'output.docker_swarm_manager == true'
+ - 'output.swarm_unlock_key is not defined'
+
+ - name: Create random name
+ set_fact:
+ randomnodename: "{{ 'node-%0x' % ((2**32) | random) }}"
+
+ - name: Try to get docker_swarm_info and list of nodes with filters providing non-existing random node name
+ docker_swarm_info:
+ nodes: yes
+ nodes_filters:
+ name: "{{ randomnodename }}"
+ register: output
+
+ - name: assert reading reading swarm facts and using node filter (random node name)
+ assert:
+ that:
+ - 'output.swarm_facts.JoinTokens.Manager'
+ - 'output.swarm_facts.JoinTokens.Worker'
+ - 'output.swarm_facts.ID'
+ - 'output.nodes | length == 0'
+ - 'output.can_talk_to_docker == true'
+ - 'output.docker_swarm_active == true'
+ - 'output.docker_swarm_manager == true'
+ - 'output.swarm_unlock_key is not defined'
+
+ - name: Try to get docker_swarm_info and swarm_unlock_key on non a unlocked swarm
+ docker_swarm_info:
+ unlock_key: yes
+ register: output
+ ignore_errors: yes
+
+ - name: assert reading swarm facts and non existing swarm unlock key
+ assert:
+ that:
+ - 'output.swarm_unlock_key is none'
+ - 'output.can_talk_to_docker == true'
+ - 'output.docker_swarm_active == true'
+ - 'output.docker_swarm_manager == true'
+ when: docker_py_version is version('2.7.0', '>=')
+ - assert:
+ that:
+ - output is failed
+ - "('version is ' ~ docker_py_version ~ ' ') in output.msg"
+ - "'Minimum version required is 2.7.0 ' in output.msg"
+ when: docker_py_version is version('2.7.0', '<')
+
+ - name: Update swarm cluster to be locked
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ autolock_managers: true
+ register: autolock_managers_update_output
+ ignore_errors: yes
+
+ - name: Try to get docker_swarm_info and swarm_unlock_key
+ docker_swarm_info:
+ unlock_key: yes
+ register: output
+ ignore_errors: yes
+
+ - name: assert reading swarm facts and swarm unlock key
+ assert:
+ that:
+ - 'output.swarm_unlock_key is string'
+ - 'output.swarm_unlock_key == autolock_managers_update_output.swarm_facts.UnlockKey'
+ - 'output.can_talk_to_docker == true'
+ - 'output.docker_swarm_active == true'
+ - 'output.docker_swarm_manager == true'
+ when: docker_py_version is version('2.7.0', '>=')
+ - assert:
+ that:
+ - output is failed
+ - "('version is ' ~ docker_py_version ~ ' ') in output.msg"
+ - "'Minimum version required is 2.7.0 ' in output.msg"
+ when: docker_py_version is version('2.7.0', '<')
+
+ always:
+ - name: Cleanup
+ docker_swarm:
+ state: absent
+ force: true
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/aliases
new file mode 100644
index 00000000..cdf1b9b1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group3
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/files/env-file-1 b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/files/env-file-1
new file mode 100644
index 00000000..b15f1b64
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/files/env-file-1
@@ -0,0 +1,2 @@
+TEST3=val3
+TEST4=val4
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/files/env-file-2 b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/files/env-file-2
new file mode 100644
index 00000000..eff99aca
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/files/env-file-2
@@ -0,0 +1,2 @@
+TEST3=val5
+TEST5=val5
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/main.yml
new file mode 100644
index 00000000..4cb69597
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/main.yml
@@ -0,0 +1,80 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+
+# Create random name prefix (for containers, networks, ...)
+- name: Create random name prefix
+ set_fact:
+ name_prefix: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
+ service_names: []
+ network_names: []
+ config_names: []
+ secret_names: []
+ volume_names: []
+
+- debug:
+ msg: "Using container name prefix {{ name_prefix }}"
+
+# Run the tests
+- block:
+ - name: Create a Swarm cluster
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+
+ - include_tasks: run-test.yml
+ with_fileglob:
+ - "tests/*.yml"
+
+ always:
+ - name: Make sure all services are removed
+ docker_swarm_service:
+ name: "{{ item }}"
+ state: absent
+ loop: "{{ service_names }}"
+ ignore_errors: yes
+
+ - name: Make sure all networks are removed
+ docker_network:
+ name: "{{ item }}"
+ state: absent
+ force: yes
+ loop: "{{ network_names }}"
+ ignore_errors: yes
+
+ - name: Make sure all configs are removed
+ docker_config:
+ name: "{{ item }}"
+ state: absent
+ force: yes
+ loop: "{{ config_names }}"
+ ignore_errors: yes
+
+ - name: Make sure all volumes are removed
+ docker_volume:
+ name: "{{ item }}"
+ state: absent
+ loop: "{{ volume_names }}"
+ ignore_errors: yes
+
+ - name: Make sure all secrets are removed
+ docker_secret:
+ name: "{{ item }}"
+ state: absent
+ force: yes
+ loop: "{{ secret_names }}"
+ ignore_errors: yes
+
+ - name: Make sure swarm is removed
+ docker_swarm:
+ state: absent
+ force: yes
+ ignore_errors: yes
+ # Maximum of 1.24 (docker API version for docker_swarm_service) and 1.25 (docker API version for docker_swarm) is 1.25
+ when: docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_swarm_service tests!"
+ when: not(docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/run-test.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/run-test.yml
new file mode 100644
index 00000000..a2999370
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/run-test.yml
@@ -0,0 +1,3 @@
+---
+- name: "Loading tasks from {{ item }}"
+ include_tasks: "{{ item }}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/configs.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/configs.yml
new file mode 100644
index 00000000..ad4d5695
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/configs.yml
@@ -0,0 +1,413 @@
+---
+
+- name: Registering container name
+ set_fact:
+ service_name: "{{ name_prefix ~ '-configs' }}"
+ config_name_1: "{{ name_prefix ~ '-configs-1' }}"
+ config_name_2: "{{ name_prefix ~ '-configs-2' }}"
+
+- name: Registering container name
+ set_fact:
+ config_names: "{{ config_names + [config_name_1, config_name_2] }}"
+
+- docker_config:
+ name: "{{ config_name_1 }}"
+ data: "hello"
+ state: present
+ register: "config_result_1"
+ when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
+
+- docker_config:
+ name: "{{ config_name_2 }}"
+ data: "test"
+ state: present
+ register: "config_result_2"
+ when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
+
+####################################################################
+## configs #########################################################
+####################################################################
+
+- name: configs
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ filename: "/tmp/{{ config_name_1 }}.txt"
+ register: configs_1
+ ignore_errors: yes
+
+- name: configs (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_name: "{{ config_name_1 }}"
+ filename: "/tmp/{{ config_name_1 }}.txt"
+ register: configs_2
+ ignore_errors: yes
+
+- name: configs (add)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ filename: "/tmp/{{ config_name_1 }}.txt"
+ - config_name: "{{ config_name_2 }}"
+ filename: "/tmp/{{ config_name_2 }}.txt"
+ register: configs_3
+ ignore_errors: yes
+
+- name: configs (add idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_name: "{{ config_name_1 }}"
+ filename: "/tmp/{{ config_name_1 }}.txt"
+ - config_id: "{{ config_result_2.config_id|default('') }}"
+ config_name: "{{ config_name_2 }}"
+ filename: "/tmp/{{ config_name_2 }}.txt"
+ register: configs_4
+ ignore_errors: yes
+
+- name: configs (add idempotency no id)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_name: "{{ config_name_1 }}"
+ filename: "/tmp/{{ config_name_1 }}.txt"
+ - config_name: "{{ config_name_2 }}"
+ filename: "/tmp/{{ config_name_2 }}.txt"
+ register: configs_5
+ ignore_errors: yes
+
+- name: configs (add idempotency no id and re-ordered)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_name: "{{ config_name_2 }}"
+ filename: "/tmp/{{ config_name_2 }}.txt"
+ - config_name: "{{ config_name_1 }}"
+ filename: "/tmp/{{ config_name_1 }}.txt"
+ register: configs_6
+ ignore_errors: yes
+
+- name: configs (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs: []
+ register: configs_7
+ ignore_errors: yes
+
+- name: configs (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs: []
+ register: configs_8
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - configs_1 is changed
+ - configs_2 is not changed
+ - configs_3 is changed
+ - configs_4 is not changed
+ - configs_5 is not changed
+ - configs_6 is not changed
+ - configs_7 is changed
+ - configs_8 is not changed
+ when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
+
+- assert:
+ that:
+ - configs_1 is failed
+ - "'Minimum version required' in configs_1.msg"
+ when: docker_api_version is version('1.30', '<') or docker_py_version is version('2.6.0', '<')
+
+####################################################################
+## configs (uid) ###################################################
+####################################################################
+
+- name: configs (uid int)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ uid: 1000
+ register: configs_1
+ ignore_errors: yes
+
+- name: configs (uid int idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ uid: 1000
+ register: configs_2
+ ignore_errors: yes
+
+- name: configs (uid int change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ uid: 1002
+ register: configs_3
+ ignore_errors: yes
+
+- name: configs (uid str)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ uid: "1001"
+ register: configs_4
+ ignore_errors: yes
+
+- name: configs (uid str idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ uid: "1001"
+ register: configs_5
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+- assert:
+ that:
+ - configs_1 is changed
+ - configs_2 is not changed
+ - configs_3 is changed
+ - configs_4 is changed
+ - configs_5 is not changed
+ when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
+
+- assert:
+ that:
+ - configs_1 is failed
+ - "'Minimum version required' in configs_1.msg"
+ when: docker_api_version is version('1.30', '<') or docker_py_version is version('2.6.0', '<')
+
+
+####################################################################
+## configs (gid) ###################################################
+####################################################################
+
+- name: configs (gid int)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ gid: 1000
+ register: configs_1
+ ignore_errors: yes
+
+- name: configs (gid int idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ gid: 1000
+ register: configs_2
+ ignore_errors: yes
+
+- name: configs (gid int change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ gid: 1002
+ register: configs_3
+ ignore_errors: yes
+
+- name: configs (gid str)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ gid: "1001"
+ register: configs_4
+ ignore_errors: yes
+
+- name: configs (gid str idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ gid: "1001"
+ register: configs_5
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+- assert:
+ that:
+ - configs_1 is changed
+ - configs_2 is not changed
+ - configs_3 is changed
+ - configs_4 is changed
+ - configs_5 is not changed
+ when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
+
+- assert:
+ that:
+ - configs_1 is failed
+ - "'Minimum version required' in configs_1.msg"
+ when: docker_api_version is version('1.30', '<') or docker_py_version is version('2.6.0', '<')
+
+####################################################################
+## configs (mode) ##################################################
+####################################################################
+
+- name: configs (mode)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ mode: 0600
+ register: configs_1
+ ignore_errors: yes
+
+- name: configs (mode idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ mode: 0600
+ register: configs_2
+ ignore_errors: yes
+
+- name: configs (mode change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ configs:
+ - config_id: "{{ config_result_1.config_id|default('') }}"
+ config_name: "{{ config_name_1 }}"
+ mode: 0777
+ register: configs_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+- assert:
+ that:
+ - configs_1 is changed
+ - configs_2 is not changed
+ - configs_3 is changed
+ when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
+
+- assert:
+ that:
+ - configs_1 is failed
+ - "'Minimum version required' in configs_1.msg"
+ when: docker_api_version is version('1.30', '<') or docker_py_version is version('2.6.0', '<')
+
+####################################################################
+####################################################################
+####################################################################
+
+- name: Delete configs
+ docker_config:
+ name: "{{ config_name }}"
+ state: absent
+ force: yes
+ loop:
+ - "{{ config_name_1 }}"
+ - "{{ config_name_2 }}"
+ loop_control:
+ loop_var: config_name
+ ignore_errors: yes
+ when: docker_api_version is version('1.30', '>=') and docker_py_version is version('2.6.0', '>=')
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/logging.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/logging.yml
new file mode 100644
index 00000000..938b8a4f
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/logging.yml
@@ -0,0 +1,135 @@
+---
+
+- name: Registering service name
+ set_fact:
+ service_name: "{{ name_prefix ~ '-logging' }}"
+
+- name: Registering service name
+ set_fact:
+ service_names: "{{ service_names + [service_name] }}"
+
+####################################################################
+## logging.driver ##################################################
+####################################################################
+
+- name: logging.driver
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ logging:
+ driver: json-file
+ register: logging_driver_1
+
+- name: logging.driver (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ logging:
+ driver: json-file
+ register: logging_driver_2
+
+- name: logging.driver (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ logging:
+ driver: syslog
+ register: logging_driver_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - logging_driver_1 is changed
+ - logging_driver_2 is not changed
+ - logging_driver_3 is changed
+
+####################################################################
+## logging.options #################################################
+####################################################################
+
+- name: logging_options
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ logging:
+ driver: json-file
+ options:
+ labels: production_status
+ env: os,customer
+ register: logging_options_1
+
+- name: logging_options (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ logging:
+ driver: json-file
+ options:
+ env: os,customer
+ labels: production_status
+ register: logging_options_2
+
+- name: logging_options (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ logging:
+ driver: json-file
+ options:
+ env: os,customer
+ labels: production_status
+ max-file: "1"
+ register: logging_options_3
+
+- name: logging_options (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ logging:
+ driver: json-file
+ options: {}
+ register: logging_options_4
+
+- name: logging_options (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ logging:
+ driver: json-file
+ options: {}
+ register: logging_options_5
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - logging_options_1 is changed
+ - logging_options_2 is not changed
+ - logging_options_3 is changed
+ - logging_options_4 is changed
+ - logging_options_5 is not changed
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/misc.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/misc.yml
new file mode 100644
index 00000000..7d24e089
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/misc.yml
@@ -0,0 +1,113 @@
+---
+- block:
+ - name: Create a swarm service without name
+ register: output
+ docker_swarm_service:
+ state: present
+ ignore_errors: yes
+
+ - name: assert failure when name not set
+ assert:
+ that:
+ - output is failed
+ - 'output.msg == "missing required arguments: name"'
+
+ - name: Remove an non-existing service
+ register: output
+ docker_swarm_service:
+ state: absent
+ name: non_existing_service
+
+ - name: assert output not changed when deleting non-existing service
+ assert:
+ that:
+ - output is not changed
+
+ - name: create sample service
+ register: output
+ docker_swarm_service:
+ name: test_service
+ endpoint_mode: dnsrr
+ image: "{{ docker_test_image_busybox }}"
+ resolve_image: no
+ args:
+ - sleep
+ - "3600"
+
+ - name: assert sample service is created
+ assert:
+ that:
+ - output is changed
+
+ - name: change service args
+ register: output
+ docker_swarm_service:
+ name: test_service
+ image: "{{ docker_test_image_busybox }}"
+ resolve_image: no
+ args:
+ - sleep
+ - "1800"
+
+ - name: assert service args are correct
+ assert:
+ that:
+ - output.swarm_service.args == ['sleep', '1800']
+
+ - name: set service mode to global
+ register: output
+ docker_swarm_service:
+ name: test_service
+ image: "{{ docker_test_image_busybox }}"
+ resolve_image: no
+ endpoint_mode: vip
+ mode: global
+ args:
+ - sleep
+ - "1800"
+
+ - name: assert service mode changed caused service rebuild
+ assert:
+ that:
+ - output.rebuilt
+
+ - name: add published ports to service
+ register: output
+ docker_swarm_service:
+ name: test_service
+ image: "{{ docker_test_image_busybox }}"
+ resolve_image: no
+ mode: global
+ args:
+ - sleep
+ - "1800"
+ endpoint_mode: vip
+ publish:
+ - protocol: tcp
+ published_port: 60001
+ target_port: 60001
+ - protocol: udp
+ published_port: 60001
+ target_port: 60001
+
+ - name: fake image key as it is not predictable
+ set_fact:
+ ansible_docker_service_output: "{{ output.swarm_service|combine({'image': docker_test_image_busybox}) }}"
+
+ - name: assert service matches expectations
+ assert:
+ that:
+ - ansible_docker_service_output == service_expected_output
+
+ - name: delete sample service
+ register: output
+ docker_swarm_service:
+ name: test_service
+ state: absent
+
+ - name: assert service deletion returns changed
+ assert:
+ that:
+ - output is success
+ - output is changed
+ when: docker_api_version is version('1.24', '>=') and docker_py_version is version('3.0.0', '>=')
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/mounts.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/mounts.yml
new file mode 100644
index 00000000..441547d9
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/mounts.yml
@@ -0,0 +1,601 @@
+- name: Registering service name
+ set_fact:
+ service_name: "{{ name_prefix ~ '-mounts' }}"
+ volume_name_1: "{{ name_prefix ~ '-volume-1' }}"
+ volume_name_2: "{{ name_prefix ~ '-volume-2' }}"
+
+- name: Registering service name
+ set_fact:
+ service_names: "{{ service_names + [service_name] }}"
+ volume_names: "{{ volume_names + [volume_name_1, volume_name_2] }}"
+
+- docker_volume:
+ name: "{{ volume_name }}"
+ state: present
+ loop:
+ - "{{ volume_name_1 }}"
+ - "{{ volume_name_2 }}"
+ loop_control:
+ loop_var: volume_name
+
+####################################################################
+## mounts ##########################################################
+####################################################################
+
+- name: mounts
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "volume"
+ register: mounts_1
+
+- name: mounts (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "volume"
+ register: mounts_2
+
+- name: mounts (add)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "volume"
+ - source: "/tmp/"
+ target: "/tmp/{{ volume_name_2 }}"
+ type: "bind"
+ register: mounts_3
+
+- name: mounts (order idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "/tmp/"
+ target: "/tmp/{{ volume_name_2 }}"
+ type: "bind"
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "volume"
+ register: mounts_4
+
+- name: mounts (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts: []
+ register: mounts_5
+
+- name: mounts (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts: []
+ register: mounts_6
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - mounts_1 is changed
+ - mounts_2 is not changed
+ - mounts_3 is changed
+ - mounts_4 is not changed
+ - mounts_5 is changed
+ - mounts_6 is not changed
+
+####################################################################
+## mounts.readonly #################################################
+####################################################################
+
+- name: mounts.readonly
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ readonly: true
+ register: mounts_readonly_1
+
+
+- name: mounts.readonly (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ readonly: true
+ register: mounts_readonly_2
+
+- name: mounts.readonly (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ readonly: false
+ register: mounts_readonly_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - mounts_readonly_1 is changed
+ - mounts_readonly_2 is not changed
+ - mounts_readonly_3 is changed
+
+####################################################################
+## mounts.propagation ##############################################
+####################################################################
+
+- name: mounts.propagation
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "/tmp"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "bind"
+ propagation: "slave"
+ register: mounts_propagation_1
+
+
+- name: mounts.propagation (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "/tmp"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "bind"
+ propagation: "slave"
+ register: mounts_propagation_2
+
+- name: mounts.propagation (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "/tmp"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "bind"
+ propagation: "rprivate"
+ register: mounts_propagation_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - mounts_propagation_1 is changed
+ - mounts_propagation_2 is not changed
+ - mounts_propagation_3 is changed
+
+####################################################################
+## mounts.labels ##################################################
+####################################################################
+
+- name: mounts.labels
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "volume"
+ labels:
+ mylabel: hello-world
+ my-other-label: hello-mars
+ register: mounts_labels_1
+
+
+- name: mounts.labels (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "volume"
+ labels:
+ mylabel: hello-world
+ my-other-label: hello-mars
+ register: mounts_labels_2
+
+- name: mounts.labels (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "volume"
+ labels:
+ mylabel: hello-world
+ register: mounts_labels_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - mounts_labels_1 is changed
+ - mounts_labels_2 is not changed
+ - mounts_labels_3 is changed
+
+####################################################################
+## mounts.no_copy ##################################################
+####################################################################
+
+- name: mounts.no_copy
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "volume"
+ no_copy: true
+ register: mounts_no_copy_1
+
+
+- name: mounts.no_copy (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "volume"
+ no_copy: true
+ register: mounts_no_copy_2
+
+- name: mounts.no_copy (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "volume"
+ no_copy: false
+ register: mounts_no_copy_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - mounts_no_copy_1 is changed
+ - mounts_no_copy_2 is not changed
+ - mounts_no_copy_3 is changed
+
+####################################################################
+## mounts.driver_config ############################################
+####################################################################
+
+- name: mounts.driver_config
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "volume"
+ driver_config:
+ name: "nfs"
+ options:
+ addr: "127.0.0.1"
+ register: mounts_driver_config_1
+
+- name: mounts.driver_config
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "volume"
+ driver_config:
+ name: "nfs"
+ options:
+ addr: "127.0.0.1"
+ register: mounts_driver_config_2
+
+- name: mounts.driver_config
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "volume"
+ driver_config:
+ name: "local"
+ register: mounts_driver_config_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - mounts_driver_config_1 is changed
+ - mounts_driver_config_2 is not changed
+ - mounts_driver_config_3 is changed
+
+####################################################################
+## mounts.tmpfs_size ###############################################
+####################################################################
+
+- name: mounts.tmpfs_size
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "tmpfs"
+ tmpfs_size: "50M"
+ register: mounts_tmpfs_size_1
+ ignore_errors: yes
+
+- name: mounts.tmpfs_size (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "tmpfs"
+ tmpfs_size: "50M"
+ register: mounts_tmpfs_size_2
+ ignore_errors: yes
+
+- name: mounts.tmpfs_size (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "tmpfs"
+ tmpfs_size: "25M"
+ register: mounts_tmpfs_size_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - mounts_tmpfs_size_1 is changed
+ - mounts_tmpfs_size_2 is not changed
+ - mounts_tmpfs_size_3 is changed
+ when: docker_py_version is version('2.6.0', '>=')
+- assert:
+ that:
+ - mounts_tmpfs_size_1 is failed
+ - "'Minimum version required' in mounts_tmpfs_size_1.msg"
+ when: docker_py_version is version('2.6.0', '<')
+
+####################################################################
+## mounts.tmpfs_mode ###############################################
+####################################################################
+
+- name: mounts.tmpfs_mode
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "tmpfs"
+ tmpfs_mode: 0444
+ register: mounts_tmpfs_mode_1
+ ignore_errors: yes
+
+- name: mounts.tmpfs_mode (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "tmpfs"
+ tmpfs_mode: 0444
+ register: mounts_tmpfs_mode_2
+ ignore_errors: yes
+
+- name: mounts.tmpfs_mode (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: "{{ volume_name_1 }}"
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "tmpfs"
+ tmpfs_mode: 0777
+ register: mounts_tmpfs_mode_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - mounts_tmpfs_mode_1 is changed
+ - mounts_tmpfs_mode_2 is not changed
+ - mounts_tmpfs_mode_3 is changed
+ when: docker_py_version is version('2.6.0', '>=')
+- assert:
+ that:
+ - mounts_tmpfs_size_1 is failed
+ - "'Minimum version required' in mounts_tmpfs_size_1.msg"
+ when: docker_py_version is version('2.6.0', '<')
+
+####################################################################
+## mounts.source ###################################################
+####################################################################
+
+- name: mounts.source (empty for tmpfs)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: ""
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "tmpfs"
+ register: mounts_tmpfs_source_1
+ ignore_errors: yes
+
+- name: mounts.source (empty for tmpfs idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - source: ""
+ target: "/tmp/{{ volume_name_1 }}"
+ type: "tmpfs"
+ register: mounts_tmpfs_source_2
+ ignore_errors: yes
+
+- name: mounts.source (not specified for tmpfs idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mounts:
+ - target: "/tmp/{{ volume_name_1 }}"
+ type: "tmpfs"
+ register: mounts_tmpfs_source_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - mounts_tmpfs_source_1 is changed
+ - mounts_tmpfs_source_2 is not changed
+ - mounts_tmpfs_source_3 is not changed
+ when: docker_py_version is version('2.6.0', '>=')
+- assert:
+ that:
+ - mounts_tmpfs_source_1 is failed
+ - "'Minimum version required' in mounts_tmpfs_source_1.msg"
+ when: docker_py_version is version('2.6.0', '<')
+
+####################################################################
+####################################################################
+####################################################################
+
+- name: Delete volumes
+ docker_volume:
+ name: "{{ volume_name }}"
+ state: absent
+ loop:
+ - "{{ volume_name_1 }}"
+ - "{{ volume_name_2 }}"
+ loop_control:
+ loop_var: volume_name
+ ignore_errors: yes
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/networks.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/networks.yml
new file mode 100644
index 00000000..26a822b6
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/networks.yml
@@ -0,0 +1,450 @@
+---
+
+- name: Registering service name
+ set_fact:
+ service_name: "{{ name_prefix ~ '-networks' }}"
+ network_name_1: "{{ name_prefix ~ '-network-1' }}"
+ network_name_2: "{{ name_prefix ~ '-network-2' }}"
+
+- name: Registering service name
+ set_fact:
+ service_names: "{{ service_names + [service_name] }}"
+ network_names: "{{ network_names + [network_name_1, network_name_2] }}"
+
+- docker_network:
+ name: "{{ network_name }}"
+ driver: "overlay"
+ state: present
+ loop:
+ - "{{ network_name_1 }}"
+ - "{{ network_name_2 }}"
+ loop_control:
+ loop_var: network_name
+
+#####################################################################
+## networks #########################################################
+#####################################################################
+
+- name: networks
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - "{{ network_name_1 }}"
+ register: networks_1
+
+- name: networks (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - "{{ network_name_1 }}"
+ register: networks_2
+
+- name: networks (dict idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ register: networks_3
+
+- name: networks (change more)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - "{{ network_name_1 }}"
+ - "{{ network_name_2 }}"
+ register: networks_4
+
+- name: networks (change more idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - "{{ network_name_1 }}"
+ - "{{ network_name_2 }}"
+ register: networks_5
+
+- name: networks (change more dict idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ - name: "{{ network_name_2 }}"
+ register: networks_6
+
+- name: networks (change more mixed idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ - "{{ network_name_2 }}"
+ register: networks_7
+
+- name: networks (order idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - "{{ network_name_2 }}"
+ - name: "{{ network_name_1 }}"
+ register: networks_8
+
+- name: networks (change less)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - "{{ network_name_2 }}"
+ register: networks_9
+
+- name: networks (change less idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - "{{ network_name_2 }}"
+ register: networks_10
+
+- name: networks (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks: []
+ register: networks_11
+
+- name: networks (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks: []
+ register: networks_12
+
+- name: networks (unknown network)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - "idonotexist"
+ register: networks_13
+ ignore_errors: yes
+
+- name: networks (missing dict key name)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - foo: "bar"
+ register: networks_14
+ ignore_errors: yes
+
+- name: networks (invalid list type)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - [1, 2, 3]
+ register: networks_15
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - networks_1 is changed
+ - networks_2 is not changed
+ - networks_3 is not changed
+ - networks_4 is changed
+ - networks_5 is not changed
+ - networks_6 is not changed
+ - networks_7 is not changed
+ - networks_8 is not changed
+ - networks_9 is changed
+ - networks_10 is not changed
+ - networks_11 is changed
+ - networks_12 is not changed
+ - networks_13 is failed
+ - '"Could not find a network named: ''idonotexist''" in networks_13.msg'
+ - networks_14 is failed
+ - "'\"name\" is required when networks are passed as dictionaries.' in networks_14.msg"
+ - networks_15 is failed
+ - "'Only a list of strings or dictionaries are allowed to be passed as networks' in networks_15.msg"
+
+- assert:
+ that:
+ - networks_4.rebuilt == false
+ - networks_7.rebuilt == false
+ when: docker_api_version is version('1.29', '>=') and docker_py_version is version('2.7.0', '>=')
+
+- assert:
+ that:
+ - networks_4.rebuilt == true
+ - networks_7.rebuilt == true
+ when: docker_api_version is version('1.29', '<') or docker_py_version is version('2.7.0', '<')
+
+####################################################################
+## networks.aliases ################################################
+####################################################################
+
+- name: networks.aliases
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ aliases:
+ - "alias1"
+ - "alias2"
+ register: networks_aliases_1
+
+- name: networks.aliases (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ aliases:
+ - "alias1"
+ - "alias2"
+ register: networks_aliases_2
+
+- name: networks.aliases (order idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ aliases:
+ - "alias2"
+ - "alias1"
+ register: networks_aliases_3
+
+- name: networks.aliases (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ aliases:
+ - "alias1"
+ register: networks_aliases_4
+
+- name: networks.aliases (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ aliases: []
+ register: networks_aliases_5
+
+- name: networks.aliases (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ aliases: []
+ register: networks_aliases_6
+
+- name: networks.aliases (invalid type)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ aliases:
+ - [1, 2, 3]
+ register: networks_aliases_7
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - networks_aliases_1 is changed
+ - networks_aliases_2 is not changed
+ - networks_aliases_3 is not changed
+ - networks_aliases_4 is changed
+ - networks_aliases_5 is changed
+ - networks_aliases_6 is not changed
+ - networks_aliases_7 is failed
+ - "'Only strings are allowed as network aliases' in networks_aliases_7.msg"
+
+####################################################################
+## networks.options ################################################
+####################################################################
+
+- name: networks.options
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ options:
+ foo: bar
+ test: hello
+ register: networks_options_1
+
+- name: networks.options (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ options:
+ foo: bar
+ test: hello
+ register: networks_options_2
+
+- name: networks.options (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ options:
+ foo: bar
+ test: hej
+ register: networks_options_3
+
+- name: networks.options (change less)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ options:
+ foo: bar
+ register: networks_options_4
+
+- name: networks.options (invalid type)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ options: [1, 2, 3]
+ register: networks_options_5
+ ignore_errors: yes
+
+- name: networks.options (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ options: {}
+ register: networks_options_6
+
+- name: networks.options (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ networks:
+ - name: "{{ network_name_1 }}"
+ options: {}
+ register: networks_options_7
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - networks_options_1 is changed
+ - networks_options_2 is not changed
+ - networks_options_3 is changed
+ - networks_options_4 is changed
+ - networks_options_5 is failed
+ - "'Only dict is allowed as network options' in networks_options_5.msg"
+ - networks_options_6 is changed
+ - networks_options_7 is not changed
+
+####################################################################
+####################################################################
+####################################################################
+
+- name: Delete networks
+ docker_network:
+ name: "{{ network_name }}"
+ state: absent
+ force: yes
+ loop:
+ - "{{ network_name_1 }}"
+ - "{{ network_name_2 }}"
+ loop_control:
+ loop_var: network_name
+ ignore_errors: yes
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/options.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/options.yml
new file mode 100644
index 00000000..df0a5938
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/options.yml
@@ -0,0 +1,1878 @@
+---
+
+- name: Registering service name
+ set_fact:
+ service_name: "{{ name_prefix ~ '-options' }}"
+
+- name: Registering service name
+ set_fact:
+ service_names: "{{ service_names + [service_name] }}"
+
+####################################################################
+## args ############################################################
+####################################################################
+
+- name: args
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ args:
+ - sleep
+ - "3600"
+ register: args_1
+
+- name: args (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ args:
+ - sleep
+ - "3600"
+ register: args_2
+
+- name: args (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ args:
+ - sleep
+ - "3400"
+ register: args_3
+
+- name: args (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ args: []
+ register: args_4
+
+- name: args (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ args: []
+ register: args_5
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - args_1 is changed
+ - args_2 is not changed
+ - args_3 is changed
+ - args_4 is changed
+ - args_5 is not changed
+
+####################################################################
+## command #########################################################
+####################################################################
+
+- name: command
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ register: command_1
+
+- name: command (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ register: command_2
+
+- name: command (less parameters)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -c "sleep 10m"'
+ register: command_3
+
+- name: command (as list)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command:
+ - "/bin/sh"
+ - "-c"
+ - "sleep 10m"
+ register: command_4
+
+- name: command (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: []
+ register: command_5
+
+- name: command (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: []
+ register: command_6
+
+- name: command (string failure)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: yes
+ register: command_7
+ ignore_errors: yes
+
+- name: command (list failure)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command:
+ - "/bin/sh"
+ - yes
+ register: command_8
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - command_1 is changed
+ - command_2 is not changed
+ - command_3 is changed
+ - command_4 is not changed
+ - command_5 is changed
+ - command_6 is not changed
+ - command_7 is failed
+ - command_8 is failed
+
+####################################################################
+## container_labels ################################################
+####################################################################
+
+- name: container_labels
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ container_labels:
+ test_1: "1"
+ test_2: "2"
+ register: container_labels_1
+
+- name: container_labels (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ container_labels:
+ test_1: "1"
+ test_2: "2"
+ register: container_labels_2
+
+- name: container_labels (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ container_labels:
+ test_1: "1"
+ test_2: "3"
+ register: container_labels_3
+
+- name: container_labels (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ container_labels: {}
+ register: container_labels_4
+
+- name: container_labels (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ container_labels: {}
+ register: container_labels_5
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - container_labels_1 is changed
+ - container_labels_2 is not changed
+ - container_labels_3 is changed
+ - container_labels_4 is changed
+ - container_labels_5 is not changed
+
+####################################################################
+## dns #############################################################
+####################################################################
+
+- name: dns
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns:
+ - 1.1.1.1
+ - 8.8.8.8
+ register: dns_1
+ ignore_errors: yes
+
+- name: dns (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns:
+ - 1.1.1.1
+ - 8.8.8.8
+ register: dns_2
+ ignore_errors: yes
+
+- name: dns_servers (changed order)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns:
+ - 8.8.8.8
+ - 1.1.1.1
+ register: dns_3
+ ignore_errors: yes
+
+- name: dns_servers (changed elements)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns:
+ - 8.8.8.8
+ - 9.9.9.9
+ register: dns_4
+ ignore_errors: yes
+
+- name: dns_servers (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns: []
+ register: dns_5
+ ignore_errors: yes
+
+- name: dns_servers (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns: []
+ register: dns_6
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - dns_1 is changed
+ - dns_2 is not changed
+ - dns_3 is changed
+ - dns_4 is changed
+ - dns_5 is changed
+ - dns_6 is not changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.6.0', '>=')
+- assert:
+ that:
+ - dns_1 is failed
+ - "'Minimum version required' in dns_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.6.0', '<')
+
+####################################################################
+## dns_options #####################################################
+####################################################################
+
+- name: dns_options
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns_options:
+ - "timeout:10"
+ - rotate
+ register: dns_options_1
+ ignore_errors: yes
+
+- name: dns_options (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns_options:
+ - "timeout:10"
+ - rotate
+ register: dns_options_2
+ ignore_errors: yes
+
+- name: dns_options (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns_options:
+ - "timeout:10"
+ - no-check-names
+ register: dns_options_3
+ ignore_errors: yes
+
+- name: dns_options (order idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns_options:
+ - no-check-names
+ - "timeout:10"
+ register: dns_options_4
+ ignore_errors: yes
+
+- name: dns_options (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns_options: []
+ register: dns_options_5
+ ignore_errors: yes
+
+- name: dns_options (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns_options: []
+ register: dns_options_6
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - dns_options_1 is changed
+ - dns_options_2 is not changed
+ - dns_options_3 is changed
+ - dns_options_4 is not changed
+ - dns_options_5 is changed
+ - dns_options_6 is not changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.6.0', '>=')
+- assert:
+ that:
+ - dns_options_1 is failed
+ - "'Minimum version required' in dns_options_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.6.0', '<')
+
+####################################################################
+## dns_search ######################################################
+####################################################################
+
+- name: dns_search
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns_search:
+ - example.com
+ - example.org
+ register: dns_search_1
+ ignore_errors: yes
+
+- name: dns_search (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns_search:
+ - example.com
+ - example.org
+ register: dns_search_2
+ ignore_errors: yes
+
+- name: dns_search (different order)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns_search:
+ - example.org
+ - example.com
+ register: dns_search_3
+ ignore_errors: yes
+
+- name: dns_search (changed elements)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns_search:
+ - ansible.com
+ - example.com
+ register: dns_search_4
+ ignore_errors: yes
+
+- name: dns_search (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns_search: []
+ register: dns_search_5
+ ignore_errors: yes
+
+- name: dns_search (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ dns_search: []
+ register: dns_search_6
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - dns_search_1 is changed
+ - dns_search_2 is not changed
+ - dns_search_3 is changed
+ - dns_search_4 is changed
+ - dns_search_5 is changed
+ - dns_search_6 is not changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.6.0', '>=')
+- assert:
+ that:
+ - dns_search_1 is failed
+ - "'Minimum version required' in dns_search_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.6.0', '<')
+
+####################################################################
+## endpoint_mode ###################################################
+####################################################################
+
+- name: endpoint_mode
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ endpoint_mode: "dnsrr"
+ register: endpoint_mode_1
+ ignore_errors: yes
+
+- name: endpoint_mode (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ endpoint_mode: "dnsrr"
+ register: endpoint_mode_2
+ ignore_errors: yes
+
+- name: endpoint_mode (changes)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ endpoint_mode: "vip"
+ register: endpoint_mode_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - endpoint_mode_1 is changed
+ - endpoint_mode_2 is not changed
+ - endpoint_mode_3 is changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('3.0.0', '>=')
+- assert:
+ that:
+ - endpoint_mode_1 is failed
+ - "'Minimum version required' in endpoint_mode_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('3.0.0', '<')
+
+####################################################################
+## env #############################################################
+####################################################################
+
+- name: env
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ env:
+ - "TEST1=val1"
+ - "TEST2=val2"
+ register: env_1
+
+- name: env (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ env:
+ TEST1: val1
+ TEST2: val2
+ register: env_2
+
+- name: env (changes)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ env:
+ - "TEST1=val1"
+ - "TEST2=val3"
+ register: env_3
+
+- name: env (order idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ env:
+ - "TEST2=val3"
+ - "TEST1=val1"
+ register: env_4
+
+- name: env (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ env: []
+ register: env_5
+
+- name: env (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ env: []
+ register: env_6
+
+- name: env (fail unwrapped values)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ env:
+ TEST1: true
+ register: env_7
+ ignore_errors: yes
+
+- name: env (fail invalid formatted string)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ env:
+ - "TEST1=val3"
+ - "TEST2"
+ register: env_8
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - env_1 is changed
+ - env_2 is not changed
+ - env_3 is changed
+ - env_4 is not changed
+ - env_5 is changed
+ - env_6 is not changed
+ - env_7 is failed
+ - env_8 is failed
+
+####################################################################
+## env_files #######################################################
+####################################################################
+
+- name: env_files
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ env_files:
+ - "{{ role_path }}/files/env-file-1"
+ register: env_file_1
+
+- name: env_files (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ env_files:
+ - "{{ role_path }}/files/env-file-1"
+ register: env_file_2
+
+- name: env_files (more items)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ env_files:
+ - "{{ role_path }}/files/env-file-1"
+ - "{{ role_path }}/files/env-file-2"
+ register: env_file_3
+
+- name: env_files (order)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ env_files:
+ - "{{ role_path }}/files/env-file-2"
+ - "{{ role_path }}/files/env-file-1"
+ register: env_file_4
+
+- name: env_files (multiple idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ env_files:
+ - "{{ role_path }}/files/env-file-2"
+ - "{{ role_path }}/files/env-file-1"
+ register: env_file_5
+
+- name: env_files (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ env_files: []
+ register: env_file_6
+
+- name: env_files (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ env_files: []
+ register: env_file_7
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - env_file_1 is changed
+ - env_file_2 is not changed
+ - env_file_3 is changed
+ - env_file_4 is changed
+ - env_file_5 is not changed
+ - env_file_6 is changed
+ - env_file_7 is not changed
+
+###################################################################
+## force_update ###################################################
+###################################################################
+
+- name: force_update
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ args:
+ - sleep
+ - "3600"
+ force_update: yes
+ register: force_update_1
+ ignore_errors: yes
+
+- name: force_update (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ args:
+ - sleep
+ - "3600"
+ force_update: yes
+ register: force_update_2
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - force_update_1 is changed
+ - force_update_2 is changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.1.0', '>=')
+- assert:
+ that:
+ - force_update_1 is failed
+ - "'Minimum version required' in force_update_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.1.0', '<')
+
+####################################################################
+## groups ##########################################################
+####################################################################
+
+- name: groups
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ groups:
+ - "1234"
+ - "5678"
+ register: groups_1
+ ignore_errors: yes
+
+- name: groups (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ groups:
+ - "1234"
+ - "5678"
+ register: groups_2
+ ignore_errors: yes
+
+- name: groups (order idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ groups:
+ - "5678"
+ - "1234"
+ register: groups_3
+ ignore_errors: yes
+
+- name: groups (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ groups:
+ - "1234"
+ register: groups_4
+ ignore_errors: yes
+
+- name: groups (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ groups: []
+ register: groups_5
+ ignore_errors: yes
+
+- name: groups (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ groups: []
+ register: groups_6
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - groups_1 is changed
+ - groups_2 is not changed
+ - groups_3 is not changed
+ - groups_4 is changed
+ - groups_5 is changed
+ - groups_6 is not changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.6.0', '>=')
+- assert:
+ that:
+ - groups_1 is failed
+ - "'Minimum version required' in groups_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.6.0', '<')
+
+####################################################################
+## healthcheck #####################################################
+####################################################################
+
+- name: healthcheck
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ healthcheck:
+ test:
+ - CMD
+ - sleep
+ - "1"
+ timeout: 2s
+ interval: 0h0m2s3ms4us
+ retries: 2
+ start_period: 20s
+ register: healthcheck_1
+ ignore_errors: yes
+
+- name: healthcheck (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ healthcheck:
+ test:
+ - CMD
+ - sleep
+ - 1
+ timeout: 2s
+ interval: 0h0m2s3ms4us
+ retries: 2
+ start_period: 20s
+ register: healthcheck_2
+ ignore_errors: yes
+
+- name: healthcheck (changed)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ healthcheck:
+ test:
+ - CMD
+ - sleep
+ - "1"
+ timeout: 3s
+ interval: 0h1m2s3ms4us
+ retries: 3
+ register: healthcheck_3
+ ignore_errors: yes
+
+- name: healthcheck (disabled)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ healthcheck:
+ test:
+ - NONE
+ register: healthcheck_4
+ ignore_errors: yes
+
+- name: healthcheck (disabled, idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ healthcheck:
+ test:
+ - NONE
+ register: healthcheck_5
+ ignore_errors: yes
+
+- name: healthcheck (string in healthcheck test, changed)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ healthcheck:
+ test: "sleep 1"
+ register: healthcheck_6
+ ignore_errors: yes
+
+- name: healthcheck (string in healthcheck test, idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ healthcheck:
+ test: "sleep 1"
+ register: healthcheck_7
+ ignore_errors: yes
+
+- name: healthcheck (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ healthcheck: {}
+ register: healthcheck_8
+ ignore_errors: yes
+
+- name: healthcheck (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ healthcheck: {}
+ register: healthcheck_9
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - healthcheck_1 is changed
+ - healthcheck_2 is not changed
+ - healthcheck_3 is changed
+ - healthcheck_4 is changed
+ - healthcheck_5 is not changed
+ - healthcheck_6 is changed
+ - healthcheck_7 is not changed
+ - healthcheck_8 is changed
+ - healthcheck_9 is not changed
+ when: docker_api_version is version('1.29', '>=') and docker_py_version is version('2.6.0', '>=')
+- assert:
+ that:
+ - healthcheck_1 is failed
+ - "'Minimum version required' in healthcheck_1.msg"
+ when: docker_api_version is version('1.29', '<') or docker_py_version is version('2.6.0', '<')
+
+###################################################################
+## hostname #######################################################
+###################################################################
+
+- name: hostname
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ hostname: me.example.com
+ register: hostname_1
+ ignore_errors: yes
+
+- name: hostname (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ hostname: me.example.com
+ register: hostname_2
+ ignore_errors: yes
+
+- name: hostname (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ hostname: me.example.org
+ register: hostname_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - hostname_1 is changed
+ - hostname_2 is not changed
+ - hostname_3 is changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.2.0', '>=')
+- assert:
+ that:
+ - hostname_1 is failed
+ - "'Minimum version required' in hostname_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.2.0', '<')
+
+###################################################################
+## hosts ##########################################################
+###################################################################
+
+- name: hosts
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ hosts:
+ example.com: 1.2.3.4
+ example.org: 4.3.2.1
+ register: hosts_1
+ ignore_errors: yes
+
+- name: hosts (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ hosts:
+ example.com: 1.2.3.4
+ example.org: 4.3.2.1
+ register: hosts_2
+ ignore_errors: yes
+
+- name: hosts (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ hosts:
+ example.com: 1.2.3.4
+ register: hosts_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - hosts_1 is changed
+ - hosts_2 is not changed
+ - hosts_3 is changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.6.0', '>=')
+- assert:
+ that:
+ - hosts_1 is failed
+ - "'Minimum version required' in hosts_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.6.0', '<')
+
+
+###################################################################
+## image ##########################################################
+###################################################################
+
+- name: image
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ register: image_1
+
+- name: image (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ register: image_2
+
+- name: image (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine_different }}"
+ register: image_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - image_1 is changed
+ - image_2 is not changed
+ - image_3 is changed
+
+####################################################################
+## labels ##########################################################
+####################################################################
+
+- name: labels
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ labels:
+ test_1: "1"
+ test_2: "2"
+ register: labels_1
+
+- name: labels (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ labels:
+ test_1: "1"
+ test_2: "2"
+ register: labels_2
+
+- name: labels (changes)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ labels:
+ test_1: "1"
+ test_2: "2"
+ test_3: "3"
+ register: labels_3
+
+- name: labels (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ labels: {}
+ register: labels_4
+
+- name: labels (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ labels: {}
+ register: labels_5
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - labels_1 is changed
+ - labels_2 is not changed
+ - labels_3 is changed
+ - labels_4 is changed
+ - labels_5 is not changed
+
+###################################################################
+## mode ###########################################################
+###################################################################
+
+- name: mode
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mode: "replicated"
+ replicas: 1
+ register: mode_1
+
+- name: mode (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mode: "replicated"
+ replicas: 1
+ register: mode_2
+
+- name: mode (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ mode: "global"
+ replicas: 1
+ register: mode_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - mode_1 is changed
+ - mode_2 is not changed
+ - mode_3 is changed
+
+####################################################################
+## stop_grace_period ###############################################
+####################################################################
+
+- name: stop_grace_period
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ stop_grace_period: 60s
+ register: stop_grace_period_1
+
+- name: stop_grace_period (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ stop_grace_period: 60s
+ register: stop_grace_period_2
+
+- name: stop_grace_period (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ stop_grace_period: 1m30s
+ register: stop_grace_period_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - stop_grace_period_1 is changed
+ - stop_grace_period_2 is not changed
+ - stop_grace_period_3 is changed
+
+####################################################################
+## stop_signal #####################################################
+####################################################################
+
+- name: stop_signal
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ stop_signal: "30"
+ register: stop_signal_1
+ ignore_errors: yes
+
+- name: stop_signal (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ stop_signal: "30"
+ register: stop_signal_2
+ ignore_errors: yes
+
+- name: stop_signal (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ stop_signal: "9"
+ register: stop_signal_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - stop_signal_1 is changed
+ - stop_signal_2 is not changed
+ - stop_signal_3 is changed
+ when: docker_api_version is version('1.28', '>=') and docker_py_version is version('2.6.0', '>=')
+- assert:
+ that:
+ - stop_signal_1 is failed
+ - "'Minimum version required' in stop_signal_1.msg"
+ when: docker_api_version is version('1.28', '<') or docker_py_version is version('2.6.0', '<')
+
+####################################################################
+## publish #########################################################
+####################################################################
+
+- name: publish
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ publish:
+ - protocol: tcp
+ published_port: 60001
+ target_port: 60001
+ - protocol: udp
+ published_port: 60002
+ target_port: 60002
+ register: publish_1
+ ignore_errors: yes
+
+- name: publish (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ publish:
+ - protocol: udp
+ published_port: 60002
+ target_port: 60002
+ - published_port: 60001
+ target_port: 60001
+ register: publish_2
+ ignore_errors: yes
+
+- name: publish (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ publish:
+ - protocol: tcp
+ published_port: 60002
+ target_port: 60003
+ - protocol: udp
+ published_port: 60001
+ target_port: 60001
+ register: publish_3
+ ignore_errors: yes
+
+- name: publish (mode)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ publish:
+ - protocol: tcp
+ published_port: 60002
+ target_port: 60003
+ mode: host
+ - protocol: udp
+ published_port: 60001
+ target_port: 60001
+ mode: host
+ register: publish_4
+ ignore_errors: yes
+
+- name: publish (mode idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ publish:
+ - protocol: udp
+ published_port: 60001
+ target_port: 60001
+ mode: host
+ - protocol: tcp
+ published_port: 60002
+ target_port: 60003
+ mode: host
+ register: publish_5
+ ignore_errors: yes
+
+- name: publish (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ publish: []
+ register: publish_6
+ ignore_errors: yes
+
+- name: publish (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ publish: []
+ register: publish_7
+ ignore_errors: yes
+
+- name: publish (publishes the same port with both protocols)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ publish:
+ - protocol: udp
+ published_port: 60001
+ target_port: 60001
+ mode: host
+ - protocol: tcp
+ published_port: 60001
+ target_port: 60001
+ mode: host
+ register: publish_8
+ ignore_errors: yes
+- name: gather service info
+ docker_swarm_service_info:
+ name: "{{ service_name }}"
+ register: publish_8_info
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - publish_1 is changed
+ - publish_2 is not changed
+ - publish_3 is changed
+ - publish_4 is changed
+ - publish_5 is not changed
+ - publish_6 is changed
+ - publish_7 is not changed
+ - publish_8 is changed
+ - (publish_8_info.service.Endpoint.Ports | length) == 2
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('3.0.0', '>=')
+- assert:
+ that:
+ - publish_1 is failed
+ - "'Minimum version required' in publish_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('3.0.0', '<')
+
+###################################################################
+## read_only ######################################################
+###################################################################
+
+- name: read_only
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ read_only: true
+ register: read_only_1
+ ignore_errors: yes
+
+- name: read_only (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ read_only: true
+ register: read_only_2
+ ignore_errors: yes
+
+- name: read_only (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ read_only: false
+ register: read_only_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - read_only_1 is changed
+ - read_only_2 is not changed
+ - read_only_3 is changed
+ when: docker_api_version is version('1.28', '>=') and docker_py_version is version('2.6.0', '>=')
+- assert:
+ that:
+ - read_only_1 is failed
+ - "'Minimum version required' in read_only_1.msg"
+ when: docker_api_version is version('1.28', '<') or docker_py_version is version('2.6.0', '<')
+
+###################################################################
+## replicas #######################################################
+###################################################################
+
+- name: replicas
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ replicas: 2
+ register: replicas_1
+
+- name: replicas (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ replicas: 2
+ register: replicas_2
+
+- name: replicas (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ replicas: 3
+ register: replicas_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - replicas_1 is changed
+ - replicas_2 is not changed
+ - replicas_3 is changed
+
+###################################################################
+# resolve_image ###################################################
+###################################################################
+
+- name: resolve_image (false)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -v -c "sleep 10m"'
+ resolve_image: false
+ register: resolve_image_1
+
+- name: resolve_image (false idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -v -c "sleep 10m"'
+ resolve_image: false
+ register: resolve_image_2
+
+- name: resolve_image (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ command: '/bin/sh -v -c "sleep 10m"'
+ resolve_image: true
+ register: resolve_image_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - resolve_image_1 is changed
+ - resolve_image_2 is not changed
+ - resolve_image_3 is changed
+ when: docker_api_version is version('1.30', '>=') and docker_py_version is version('3.2.0', '>=')
+- assert:
+ that:
+ - resolve_image_1 is changed
+ - resolve_image_2 is not changed
+ - resolve_image_3 is failed
+ - "('version is ' ~ docker_py_version ~ ' ') in resolve_image_3.msg"
+ - "'Minimum version required is 3.2.0 ' in resolve_image_3.msg"
+ when: docker_api_version is version('1.30', '<') or docker_py_version is version('3.2.0', '<')
+
+###################################################################
+# tty #############################################################
+###################################################################
+
+- name: tty
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ tty: yes
+ register: tty_1
+ ignore_errors: yes
+
+- name: tty (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ tty: yes
+ register: tty_2
+ ignore_errors: yes
+
+- name: tty (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ tty: no
+ register: tty_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - tty_1 is changed
+ - tty_2 is not changed
+ - tty_3 is changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.4.0', '>=')
+- assert:
+ that:
+ - tty_1 is failed
+ - "'Minimum version required' in tty_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.4.0', '<')
+
+###################################################################
+## user ###########################################################
+###################################################################
+
+- name: user
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ user: "operator"
+ register: user_1
+
+- name: user (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ user: "operator"
+ register: user_2
+
+- name: user (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ user: "root"
+ register: user_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - user_1 is changed
+ - user_2 is not changed
+ - user_3 is changed
+
+####################################################################
+## working_dir #####################################################
+####################################################################
+
+- name: working_dir
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ working_dir: /tmp
+ register: working_dir_1
+
+- name: working_dir (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ working_dir: /tmp
+ register: working_dir_2
+
+- name: working_dir (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ working_dir: /
+ register: working_dir_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - working_dir_1 is changed
+ - working_dir_2 is not changed
+ - working_dir_3 is changed
+
+####################################################################
+## init ############################################################
+####################################################################
+
+- name: init
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ init: true
+ register: init_1
+
+- name: init (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ init: true
+ register: init_2
+
+- name: init (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ init: false
+ register: init_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - init_1 is changed
+ - init_2 is not changed
+ - init_3 is changed
+ when: docker_api_version is version('1.37', '>=')
+
+- assert:
+ that:
+ - init_1 is failed
+ - "('version is ' ~ docker_api_version ~'. Minimum version required is 1.37') in hosts_1.msg"
+ when: docker_api_version is version('1.37', '<')
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/placement.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/placement.yml
new file mode 100644
index 00000000..71873b20
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/placement.yml
@@ -0,0 +1,202 @@
+---
+
+- name: Registering service name
+ set_fact:
+ service_name: "{{ name_prefix ~ '-placement' }}"
+
+- name: Registering service name
+ set_fact:
+ service_names: "{{ service_names + [service_name] }}"
+
+
+####################################################################
+## placement.preferences ###########################################
+####################################################################
+
+- name: placement.preferences
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ placement:
+ preferences:
+ - spread: "node.labels.test"
+ register: placement_preferences_1
+ ignore_errors: yes
+
+- name: placement.preferences (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ placement:
+ preferences:
+ - spread: "node.labels.test"
+ register: placement_preferences_2
+ ignore_errors: yes
+
+- name: placement.preferences (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ placement:
+ preferences:
+ - spread: "node.labels.test2"
+ register: placement_preferences_3
+ ignore_errors: yes
+
+- name: placement.preferences (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ placement:
+ preferences: []
+ register: placement_preferences_4
+ ignore_errors: yes
+
+- name: placement.preferences (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ placement:
+ preferences: []
+ register: placement_preferences_5
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - placement_preferences_1 is changed
+ - placement_preferences_2 is not changed
+ - placement_preferences_3 is changed
+ - placement_preferences_4 is changed
+ - placement_preferences_5 is not changed
+ when: docker_api_version is version('1.27', '>=') and docker_py_version is version('2.4.0', '>=')
+- assert:
+ that:
+ - placement_preferences_1 is failed
+ - "'Minimum version required' in placement_preferences_1.msg"
+ when: docker_api_version is version('1.27', '<') or docker_py_version is version('2.4.0', '<')
+
+####################################################################
+## placement.constraints #####################################################
+####################################################################
+
+- name: placement.constraints
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ placement:
+ constraints:
+ - "node.role == manager"
+ register: constraints_1
+ ignore_errors: yes
+
+- name: placement.constraints (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ placement:
+ constraints:
+ - "node.role == manager"
+ register: constraints_2
+ ignore_errors: yes
+
+- name: placement.constraints (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ placement:
+ constraints:
+ - "node.role == worker"
+ register: constraints_3
+ ignore_errors: yes
+
+- name: placement.constraints (add)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ placement:
+ constraints:
+ - "node.role == worker"
+ - "node.label != non_existent_label"
+ register: constraints_4
+ ignore_errors: yes
+
+- name: placement.constraints (order idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ placement:
+ constraints:
+ - "node.label != non_existent_label"
+ - "node.role == worker"
+ register: constraints_5
+ ignore_errors: yes
+
+- name: placement.constraints (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ placement:
+ constraints: []
+ register: constraints_6
+ ignore_errors: yes
+
+- name: placement.constraints (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ placement:
+ constraints: []
+ register: constraints_7
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - constraints_1 is changed
+ - constraints_2 is not changed
+ - constraints_3 is changed
+ - constraints_4 is changed
+ - constraints_5 is not changed
+ - constraints_6 is changed
+ - constraints_7 is not changed
+ when: docker_api_version is version('1.27', '>=') and docker_py_version is version('2.4.0', '>=')
+- assert:
+ that:
+ - constraints_1 is failed
+ - "'Minimum version required' in constraints_1.msg"
+ when: docker_api_version is version('1.27', '<') or docker_py_version is version('2.4.0', '<')
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/resources.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/resources.yml
new file mode 100644
index 00000000..8a481067
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/resources.yml
@@ -0,0 +1,193 @@
+---
+
+- name: Registering service name
+ set_fact:
+ service_name: "{{ name_prefix ~ '-resources' }}"
+
+- name: Registering service name
+ set_fact:
+ service_names: "{{ service_names + [service_name] }}"
+
+####################################################################
+## limits.cpus #####################################################
+####################################################################
+
+- name: limits.cpus
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ limits:
+ cpus: 1
+ register: limit_cpu_1
+
+- name: limits.cpus (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ limits:
+ cpus: 1
+ register: limit_cpu_2
+
+- name: limits.cpus (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ limits:
+ cpus: 0.5
+ register: limit_cpu_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - limit_cpu_1 is changed
+ - limit_cpu_2 is not changed
+ - limit_cpu_3 is changed
+
+###################################################################
+## limits.memory ##################################################
+###################################################################
+
+- name: limits.memory
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ limits:
+ memory: 64M
+ register: limit_memory_1
+
+- name: limits.memory (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ limits:
+ memory: 64M
+ register: limit_memory_2
+
+- name: limits.memory (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ limits:
+ memory: 32M
+ register: limit_memory_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - limit_memory_1 is changed
+ - limit_memory_2 is not changed
+ - limit_memory_3 is changed
+
+###################################################################
+## reservations.cpus ##############################################
+###################################################################
+
+- name: reserve_cpu
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ reservations:
+ cpus: 1
+ register: reserve_cpu_1
+
+- name: reserve_cpu (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ reservations:
+ cpus: 1
+ register: reserve_cpu_2
+
+- name: reserve_cpu (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ reservations:
+ cpus: 0.5
+ register: reserve_cpu_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - reserve_cpu_1 is changed
+ - reserve_cpu_2 is not changed
+ - reserve_cpu_3 is changed
+
+###################################################################
+## reservations.memory ############################################
+###################################################################
+
+- name: reservations.memory
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ reservations:
+ memory: 64M
+ register: reserve_memory_1
+
+- name: reservations.memory (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ reservations:
+ memory: 64M
+ register: reserve_memory_2
+
+- name: reservations.memory (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ reservations:
+ memory: 32M
+ register: reserve_memory_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - reserve_memory_1 is changed
+ - reserve_memory_2 is not changed
+ - reserve_memory_3 is changed
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/restart_config.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/restart_config.yml
new file mode 100644
index 00000000..cf7e1668
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/restart_config.yml
@@ -0,0 +1,193 @@
+---
+
+- name: Registering service name
+ set_fact:
+ service_name: "{{ name_prefix ~ '-restart_config' }}"
+
+- name: Registering service name
+ set_fact:
+ service_names: "{{ service_names + [service_name] }}"
+
+###################################################################
+## restart_config.condition #######################################
+###################################################################
+
+- name: restart_config.condition
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ restart_config:
+ condition: "on-failure"
+ register: restart_policy_1
+
+- name: restart_config.condition (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ restart_config:
+ condition: "on-failure"
+ register: restart_policy_2
+
+- name: restart_config.condition (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ restart_config:
+ condition: "any"
+ register: restart_policy_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - restart_policy_1 is changed
+ - restart_policy_2 is not changed
+ - restart_policy_3 is changed
+
+###################################################################
+## restart_config.max_attempts ####################################
+###################################################################
+
+- name: restart_config.max_attempts
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ restart_config:
+ max_attempts: 1
+ register: restart_policy_attempts_1
+
+- name: restart_config.max_attempts (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ restart_config:
+ max_attempts: 1
+ register: restart_policy_attempts_2
+
+- name: restart_config.max_attempts (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ restart_config:
+ max_attempts: 2
+ register: restart_policy_attempts_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - restart_policy_attempts_1 is changed
+ - restart_policy_attempts_2 is not changed
+ - restart_policy_attempts_3 is changed
+
+###################################################################
+## restart_config.delay ###########################################
+###################################################################
+
+- name: restart_config.delay
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ restart_config:
+ delay: 5s
+ register: restart_policy_delay_1
+
+- name: restart_config.delay (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ restart_config:
+ delay: 5s
+ register: restart_policy_delay_2
+
+- name: restart_config.delay (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ restart_config:
+ delay: 10s
+ register: restart_policy_delay_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - restart_policy_delay_1 is changed
+ - restart_policy_delay_2 is not changed
+ - restart_policy_delay_3 is changed
+
+###################################################################
+## restart_config.window ##########################################
+###################################################################
+
+- name: restart_config.window
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ restart_config:
+ window: 10s
+ register: restart_policy_window_1
+
+- name: restart_config.window (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ restart_config:
+ window: 10s
+ register: restart_policy_window_2
+
+- name: restart_config.window (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ restart_config:
+ window: 20s
+ register: restart_policy_window_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - restart_policy_window_1 is changed
+ - restart_policy_window_2 is not changed
+ - restart_policy_window_3 is changed
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/rollback_config.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/rollback_config.yml
new file mode 100644
index 00000000..8d97d7e9
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/rollback_config.yml
@@ -0,0 +1,339 @@
+---
+
+- name: Registering service name
+ set_fact:
+ service_name: "{{ name_prefix ~ '-rollback_config' }}"
+
+- name: Registering service name
+ set_fact:
+ service_names: "{{ service_names + [service_name] }}"
+
+###################################################################
+## rollback_config.delay ############################################
+###################################################################
+
+- name: rollback_config.delay
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ delay: 5s
+ register: rollback_config_delay_1
+ ignore_errors: yes
+
+- name: rollback_config.delay (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ delay: 5s
+ register: rollback_config_delay_2
+ ignore_errors: yes
+
+- name: rollback_config.delay (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ delay: 12s
+ register: rollback_config_delay_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - rollback_config_delay_1 is changed
+ - rollback_config_delay_2 is not changed
+ - rollback_config_delay_3 is changed
+ when: docker_api_version is version('1.28', '>=') and docker_py_version is version('3.5.0', '>=')
+- assert:
+ that:
+ - rollback_config_delay_1 is failed
+ - "'Minimum version required' in rollback_config_delay_1.msg"
+ when: docker_api_version is version('1.28', '<') or docker_py_version is version('3.5.0', '<')
+
+###################################################################
+## rollback_config.failure_action ###################################
+###################################################################
+
+- name: rollback_config.failure_action
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ failure_action: "pause"
+ register: rollback_config_failure_action_1
+ ignore_errors: yes
+
+- name: rollback_config.failure_action (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ failure_action: "pause"
+ register: rollback_config_failure_action_2
+ ignore_errors: yes
+
+- name: rollback_config.failure_action (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ failure_action: "continue"
+ register: rollback_config_failure_action_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - rollback_config_failure_action_1 is changed
+ - rollback_config_failure_action_2 is not changed
+ - rollback_config_failure_action_3 is changed
+ when: docker_api_version is version('1.28', '>=') and docker_py_version is version('3.5.0', '>=')
+- assert:
+ that:
+ - rollback_config_failure_action_1 is failed
+ - "'Minimum version required' in rollback_config_failure_action_1.msg"
+ when: docker_api_version is version('1.28', '<') or docker_py_version is version('3.5.0', '<')
+
+###################################################################
+## rollback_config.max_failure_ratio ################################
+###################################################################
+
+- name: rollback_config.max_failure_ratio
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ max_failure_ratio: 0.25
+ register: rollback_config_max_failure_ratio_1
+ ignore_errors: yes
+
+- name: rollback_config.max_failure_ratio (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ max_failure_ratio: 0.25
+ register: rollback_config_max_failure_ratio_2
+ ignore_errors: yes
+
+- name: rollback_config.max_failure_ratio (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ max_failure_ratio: 0.50
+ register: rollback_config_max_failure_ratio_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - rollback_config_max_failure_ratio_1 is changed
+ - rollback_config_max_failure_ratio_2 is not changed
+ - rollback_config_max_failure_ratio_3 is changed
+ when: docker_api_version is version('1.28', '>=') and docker_py_version is version('3.5.0', '>=')
+- assert:
+ that:
+ - rollback_config_max_failure_ratio_1 is failed
+ - "'Minimum version required' in rollback_config_max_failure_ratio_1.msg"
+ when: docker_api_version is version('1.28', '<') or docker_py_version is version('3.5.0', '<')
+
+###################################################################
+# rollback_config.monitor ###########################################
+###################################################################
+
+- name: rollback_config.monitor
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ monitor: 10s
+ register: rollback_config_monitor_1
+ ignore_errors: yes
+
+- name: rollback_config.monitor (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ monitor: 10s
+ register: rollback_config_monitor_2
+ ignore_errors: yes
+
+- name: rollback_config.monitor (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ monitor: 60s
+ register: rollback_config_monitor_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - rollback_config_monitor_1 is changed
+ - rollback_config_monitor_2 is not changed
+ - rollback_config_monitor_3 is changed
+ when: docker_api_version is version('1.28', '>=') and docker_py_version is version('3.5.0', '>=')
+- assert:
+ that:
+ - rollback_config_monitor_1 is failed
+ - "'Minimum version required' in rollback_config_monitor_1.msg"
+ when: docker_api_version is version('1.28', '<') or docker_py_version is version('3.5.0', '<')
+
+###################################################################
+# rollback_config.order #############################################
+###################################################################
+
+- name: rollback_config.order
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ order: "start-first"
+ register: rollback_config_order_1
+ ignore_errors: yes
+
+- name: rollback_config.order (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ order: "start-first"
+ register: rollback_config_order_2
+ ignore_errors: yes
+
+- name: rollback_config.order (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ order: "stop-first"
+ register: rollback_config_order_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - rollback_config_order_1 is changed
+ - rollback_config_order_2 is not changed
+ - rollback_config_order_3 is changed
+ when: docker_api_version is version('1.29', '>=') and docker_py_version is version('3.5.0', '>=')
+- assert:
+ that:
+ - rollback_config_order_1 is failed
+ - "'Minimum version required' in rollback_config_order_1.msg"
+ when: docker_api_version is version('1.29', '<') or docker_py_version is version('3.5.0', '<')
+
+###################################################################
+## rollback_config.parallelism ######################################
+###################################################################
+
+- name: rollback_config.parallelism
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ parallelism: 2
+ register: rollback_config_parallelism_1
+ ignore_errors: yes
+
+- name: rollback_config.parallelism (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ parallelism: 2
+ register: rollback_config_parallelism_2
+ ignore_errors: yes
+
+- name: rollback_config.parallelism (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ rollback_config:
+ parallelism: 1
+ register: rollback_config_parallelism_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - rollback_config_parallelism_1 is changed
+ - rollback_config_parallelism_2 is not changed
+ - rollback_config_parallelism_3 is changed
+ when: docker_api_version is version('1.28', '>=') and docker_py_version is version('3.5.0', '>=')
+- assert:
+ that:
+ - rollback_config_parallelism_1 is failed
+ - "'Minimum version required' in rollback_config_parallelism_1.msg"
+ when: docker_api_version is version('1.28', '<') or docker_py_version is version('3.5.0', '<')
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/secrets.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/secrets.yml
new file mode 100644
index 00000000..bcd1f269
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/secrets.yml
@@ -0,0 +1,411 @@
+---
+
+- name: Registering container name
+ set_fact:
+ service_name: "{{ name_prefix ~ '-secrets' }}"
+ secret_name_1: "{{ name_prefix ~ '-secret-1' }}"
+ secret_name_2: "{{ name_prefix ~ '-secret-2' }}"
+
+- name: Registering container name
+ set_fact:
+ secret_names: "{{ secret_names + [secret_name_1, secret_name_2] }}"
+
+- docker_secret:
+ name: "{{ secret_name_1 }}"
+ data: "secret1"
+ state: "present"
+ register: "secret_result_1"
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.1.0', '>=')
+
+- docker_secret:
+ name: "{{ secret_name_2 }}"
+ data: "secret2"
+ state: "present"
+ register: "secret_result_2"
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.1.0', '>=')
+
+####################################################################
+## secrets #########################################################
+####################################################################
+
+- name: secrets
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ filename: "/run/secrets/{{ secret_name_1 }}.txt"
+ register: secrets_1
+ ignore_errors: yes
+
+- name: secrets (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_name: "{{ secret_name_1 }}"
+ filename: "/run/secrets/{{ secret_name_1 }}.txt"
+ register: secrets_2
+ ignore_errors: yes
+
+- name: secrets (add)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ filename: "/run/secrets/{{ secret_name_1 }}.txt"
+ - secret_name: "{{ secret_name_2 }}"
+ filename: "/run/secrets/{{ secret_name_2 }}.txt"
+ register: secrets_3
+ ignore_errors: yes
+
+- name: secrets (add idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_name: "{{ secret_name_1 }}"
+ filename: "/run/secrets/{{ secret_name_1 }}.txt"
+ - secret_id: "{{ secret_result_2.secret_id|default('') }}"
+ secret_name: "{{ secret_name_2 }}"
+ filename: "/run/secrets/{{ secret_name_2 }}.txt"
+ register: secrets_4
+ ignore_errors: yes
+
+- name: secrets (add idempotency no id)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_name: "{{ secret_name_1 }}"
+ filename: "/run/secrets/{{ secret_name_1 }}.txt"
+ - secret_name: "{{ secret_name_2 }}"
+ filename: "/run/secrets/{{ secret_name_2 }}.txt"
+ register: secrets_5
+ ignore_errors: yes
+
+- name: secrets (order idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_name: "{{ secret_name_2 }}"
+ filename: "/run/secrets/{{ secret_name_2 }}.txt"
+ - secret_name: "{{ secret_name_1 }}"
+ filename: "/run/secrets/{{ secret_name_1 }}.txt"
+ register: secrets_6
+ ignore_errors: yes
+
+- name: secrets (empty)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets: []
+ register: secrets_7
+ ignore_errors: yes
+
+- name: secrets (empty idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets: []
+ register: secrets_8
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - secrets_1 is changed
+ - secrets_2 is not changed
+ - secrets_3 is changed
+ - secrets_4 is not changed
+ - secrets_5 is not changed
+ - secrets_6 is not changed
+ - secrets_7 is changed
+ - secrets_8 is not changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.4.0', '>=')
+- assert:
+ that:
+ - secrets_1 is failed
+ - "'Minimum version required' in secrets_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.4.0', '<')
+
+####################################################################
+## secrets (uid) ###################################################
+####################################################################
+
+- name: secrets (uid int)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ uid: 1000
+ register: secrets_1
+ ignore_errors: yes
+
+- name: secrets (uid int idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ uid: 1000
+ register: secrets_2
+ ignore_errors: yes
+
+- name: secrets (uid int change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ uid: 1002
+ register: secrets_3
+ ignore_errors: yes
+
+- name: secrets (uid str)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ uid: "1001"
+ register: secrets_4
+ ignore_errors: yes
+
+- name: secrets (uid str idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ uid: "1001"
+ register: secrets_5
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - secrets_1 is changed
+ - secrets_2 is not changed
+ - secrets_3 is changed
+ - secrets_4 is changed
+ - secrets_5 is not changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.4.0', '>=')
+- assert:
+ that:
+ - secrets_1 is failed
+ - "'Minimum version required' in secrets_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.4.0', '<')
+
+####################################################################
+## secrets (gid) ###################################################
+####################################################################
+
+- name: secrets (gid int)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ gid: 1001
+ register: secrets_1
+ ignore_errors: yes
+
+- name: secrets (gid int idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ gid: 1001
+ register: secrets_2
+ ignore_errors: yes
+
+- name: secrets (gid int change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ gid: 1002
+ register: secrets_3
+ ignore_errors: yes
+
+- name: secrets (gid str)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ gid: "1003"
+ register: secrets_4
+ ignore_errors: yes
+
+- name: secrets (gid str idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ gid: "1003"
+ register: secrets_5
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - secrets_1 is changed
+ - secrets_2 is not changed
+ - secrets_3 is changed
+ - secrets_4 is changed
+ - secrets_5 is not changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.4.0', '>=')
+- assert:
+ that:
+ - secrets_1 is failed
+ - "'Minimum version required' in secrets_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.4.0', '<')
+
+####################################################################
+## secrets (mode) ##################################################
+####################################################################
+
+- name: secrets (mode)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ mode: 0600
+ register: secrets_1
+ ignore_errors: yes
+
+- name: secrets (mode idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ mode: 0600
+ register: secrets_2
+ ignore_errors: yes
+
+- name: secrets (mode change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ secrets:
+ - secret_id: "{{ secret_result_1.secret_id|default('') }}"
+ secret_name: "{{ secret_name_1 }}"
+ mode: 0777
+ register: secrets_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - secrets_1 is changed
+ - secrets_2 is not changed
+ - secrets_3 is changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.4.0', '>=')
+- assert:
+ that:
+ - secrets_1 is failed
+ - "'Minimum version required' in secrets_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.4.0', '<')
+
+####################################################################
+####################################################################
+####################################################################
+
+- name: Delete secrets
+ docker_secret:
+ name: "{{ secret_name }}"
+ state: absent
+ force: yes
+ loop:
+ - "{{ secret_name_1 }}"
+ - "{{ secret_name_2 }}"
+ loop_control:
+ loop_var: secret_name
+ ignore_errors: yes
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.1.0', '>=')
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/update_config.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/update_config.yml
new file mode 100644
index 00000000..5eccde28
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/tasks/tests/update_config.yml
@@ -0,0 +1,345 @@
+---
+
+- name: Registering service name
+ set_fact:
+ service_name: "{{ name_prefix ~ '-update_config' }}"
+
+- name: Registering service name
+ set_fact:
+ service_names: "{{ service_names + [service_name] }}"
+
+###################################################################
+## update_config.delay ############################################
+###################################################################
+
+- name: update_config.delay
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ delay: 5s
+ register: update_delay_1
+
+- name: update_config.delay (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ delay: 5s
+ register: update_delay_2
+
+- name: update_config.delay (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ delay: 12s
+ register: update_delay_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - update_delay_1 is changed
+ - update_delay_2 is not changed
+ - update_delay_3 is changed
+
+###################################################################
+## update_config.failure_action ###################################
+###################################################################
+
+- name: update_config.failure_action
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ failure_action: "pause"
+ register: update_failure_action_1
+
+- name: update_config.failure_action (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ failure_action: "pause"
+ register: update_failure_action_2
+
+- name: update_config.failure_action (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ failure_action: "continue"
+ register: update_failure_action_3
+
+- name: update_config.failure_action (rollback)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ failure_action: "rollback"
+ register: update_failure_action_4
+ ignore_errors: yes
+
+- name: update_config.failure_action (rollback idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_failure_action: "rollback"
+ register: update_failure_action_5
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - update_failure_action_1 is changed
+ - update_failure_action_2 is not changed
+ - update_failure_action_3 is changed
+
+- assert:
+ that:
+ - update_failure_action_4 is changed
+ - update_failure_action_5 is not changed
+ when: docker_api_version is version('1.28', '>=') and docker_py_version is version('3.5.0', '>=')
+
+- assert:
+ that:
+ - update_failure_action_4 is failed
+ - "'Minimum version required' in update_failure_action_4.msg"
+ when: docker_api_version is version('1.28', '<') or docker_py_version is version('3.5.0', '<')
+
+###################################################################
+## update_config.max_failure_ratio ################################
+###################################################################
+
+- name: update_config.max_failure_ratio
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ max_failure_ratio: 0.25
+ register: update_max_failure_ratio_1
+ ignore_errors: yes
+
+- name: update_config.max_failure_ratio (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ max_failure_ratio: 0.25
+ register: update_max_failure_ratio_2
+ ignore_errors: yes
+
+- name: update_config.max_failure_ratio (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ max_failure_ratio: 0.50
+ register: update_max_failure_ratio_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - update_max_failure_ratio_1 is changed
+ - update_max_failure_ratio_2 is not changed
+ - update_max_failure_ratio_3 is changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.1.0', '>=')
+- assert:
+ that:
+ - update_max_failure_ratio_1 is failed
+ - "'Minimum version required' in update_max_failure_ratio_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.1.0', '<')
+
+###################################################################
+# update_config.monitor ###########################################
+###################################################################
+
+- name: update_config.monitor
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ monitor: 10s
+ register: update_monitor_1
+ ignore_errors: yes
+
+- name: update_config.monitor (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ monitor: 10s
+ register: update_monitor_2
+ ignore_errors: yes
+
+- name: update_config.monitor (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ monitor: 60s
+ register: update_monitor_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - update_monitor_1 is changed
+ - update_monitor_2 is not changed
+ - update_monitor_3 is changed
+ when: docker_api_version is version('1.25', '>=') and docker_py_version is version('2.1.0', '>=')
+- assert:
+ that:
+ - update_monitor_1 is failed
+ - "'Minimum version required' in update_monitor_1.msg"
+ when: docker_api_version is version('1.25', '<') or docker_py_version is version('2.1.0', '<')
+
+###################################################################
+# update_config.order #############################################
+###################################################################
+
+- name: update_config.order
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ order: "start-first"
+ register: update_order_1
+ ignore_errors: yes
+
+- name: update_config.order (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ order: "start-first"
+ register: update_order_2
+ ignore_errors: yes
+
+- name: update_config.order (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ order: "stop-first"
+ register: update_order_3
+ ignore_errors: yes
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - update_order_1 is changed
+ - update_order_2 is not changed
+ - update_order_3 is changed
+ when: docker_api_version is version('1.29', '>=') and docker_py_version is version('2.7.0', '>=')
+- assert:
+ that:
+ - update_order_1 is failed
+ - "'Minimum version required' in update_order_1.msg"
+ when: docker_api_version is version('1.29', '<') or docker_py_version is version('2.7.0', '<')
+
+###################################################################
+## update_config.parallelism ######################################
+###################################################################
+
+- name: update_config.parallelism
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ parallelism: 2
+ register: update_parallelism_1
+
+- name: update_config.parallelism (idempotency)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ parallelism: 2
+ register: update_parallelism_2
+
+- name: update_config.parallelism (change)
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+ resolve_image: no
+ command: '/bin/sh -v -c "sleep 10m"'
+ update_config:
+ parallelism: 1
+ register: update_parallelism_3
+
+- name: cleanup
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ diff: no
+
+- assert:
+ that:
+ - update_parallelism_1 is changed
+ - update_parallelism_2 is not changed
+ - update_parallelism_3 is changed
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/vars/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/vars/main.yml
new file mode 100644
index 00000000..8ec7ffeb
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service/vars/main.yml
@@ -0,0 +1,54 @@
+---
+
+service_expected_output:
+ args: [sleep, '1800']
+ configs: null
+ constraints: null
+ container_labels: null
+ command: null
+ dns: null
+ dns_options: null
+ dns_search: null
+ endpoint_mode: vip
+ env: null
+ force_update: null
+ groups: null
+ healthcheck: null
+ healthcheck_disabled: null
+ hostname: null
+ hosts: null
+ image: "{{ docker_test_image_busybox }}"
+ labels: null
+ limit_cpu: null
+ limit_memory: null
+ log_driver: null
+ log_driver_options: null
+ mode: global
+ mounts: null
+ networks: null
+ secrets: null
+ stop_grace_period: null
+ stop_signal: null
+ placement_preferences: null
+ publish:
+ - {mode: null, protocol: tcp, published_port: 60001, target_port: 60001}
+ - {mode: null, protocol: udp, published_port: 60001, target_port: 60001}
+ read_only: null
+ replicas: null
+ reserve_cpu: null
+ reserve_memory: null
+ restart_policy: null
+ restart_policy_attempts: null
+ restart_policy_delay: null
+ restart_policy_window: null
+ rollback_config: null
+ tty: null
+ update_delay: null
+ update_failure_action: null
+ update_max_failure_ratio: null
+ update_monitor: null
+ update_order: null
+ update_parallelism: null
+ user: null
+ working_dir: null
+ init: null
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/aliases
new file mode 100644
index 00000000..cdf1b9b1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group3
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/tasks/main.yml
new file mode 100644
index 00000000..8350e901
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/tasks/main.yml
@@ -0,0 +1,11 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- include_tasks: test_docker_swarm_service_info.yml
+ when: docker_py_version is version('2.0.0', '>=') and docker_api_version is version('1.24', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_swarm_service_info tests!"
+ when: not(docker_py_version is version('2.0.0', '>=') and docker_api_version is version('1.24', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/tasks/test_docker_swarm_service_info.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/tasks/test_docker_swarm_service_info.yml
new file mode 100644
index 00000000..2b5b882c
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_swarm_service_info/tasks/test_docker_swarm_service_info.yml
@@ -0,0 +1,83 @@
+---
+
+- name: Generate service base name
+ set_fact:
+ service_base_name: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
+
+- name: Registering service names
+ set_fact:
+ service_name: "{{ service_base_name ~ '-1' }}"
+
+- block:
+ - name: Make sure we're not already using Docker swarm
+ docker_swarm:
+ state: absent
+ force: true
+
+ - name: Try to get docker_swarm_service_info when docker is not running in swarm mode
+ docker_swarm_service_info:
+ name: "{{ service_name }}"
+ ignore_errors: yes
+ register: output
+
+ - name: assert failure when called when swarm is not in use or not run on manager node
+ assert:
+ that:
+ - 'output is failed'
+ - 'output.msg == "Error running docker swarm module: must run on swarm manager node"'
+
+ - name: Create a Swarm cluster
+ docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
+ register: output
+
+ - name: Create services
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ image: "{{ docker_test_image_alpine }}"
+
+ - name: Try to get docker_swarm_service_info for a single service
+ docker_swarm_service_info:
+ name: "{{ service_name }}"
+ register: output
+
+ - name: assert reading reading service info
+ assert:
+ that:
+ - 'output.exists == true'
+ - 'output.service.ID is string'
+ - 'output.service.Spec.Name == service_name'
+
+ - name: Create random name
+ set_fact:
+ random_service_name: "{{ 'random-service-%0x' % ((2**32) | random) }}"
+
+ - name: Try to get docker_swarm_service_info using random service name as parameter
+ docker_swarm_service_info:
+ name: "{{ random_service_name }}"
+ register: output
+
+ - name: assert reading reading service info
+ assert:
+ that:
+ - 'output.service is none'
+ - 'output.exists == false'
+
+ always:
+ - name: Remove services
+ docker_swarm_service:
+ name: "{{ service_name }}"
+ state: absent
+ ignore_errors: yes
+
+ - name: Remove swarm
+ docker_swarm:
+ state: absent
+ force: true
+
+ # Maximum of 1.24 (docker API version for docker_swarm_service_info) and 1.25 (docker API version for docker_swarm) is 1.25
+ when: docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_swarm_service_info tests!"
+ when: not(docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/aliases
new file mode 100644
index 00000000..02b78723
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group4
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/tasks/main.yml
new file mode 100644
index 00000000..04baaadb
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/tasks/main.yml
@@ -0,0 +1,30 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- name: Create random name prefix
+ set_fact:
+ name_prefix: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
+ vnames: []
+
+- debug:
+ msg: "Using name prefix {{ name_prefix }}"
+
+- block:
+ - include_tasks: run-test.yml
+ with_fileglob:
+ - "tests/*.yml"
+
+ always:
+ - name: "Make sure all volumes are removed"
+ docker_volume:
+ name: "{{ item }}"
+ state: absent
+ with_items: "{{ vnames }}"
+
+ when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.20', '>=') # FIXME: find out API version!
+
+- fail: msg="Too old docker / docker-py version to run docker_volume tests!"
+ when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/tasks/run-test.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/tasks/run-test.yml
new file mode 100644
index 00000000..a2999370
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/tasks/run-test.yml
@@ -0,0 +1,3 @@
+---
+- name: "Loading tasks from {{ item }}"
+ include_tasks: "{{ item }}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/tasks/tests/basic.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/tasks/tests/basic.yml
new file mode 100644
index 00000000..7ee56261
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume/tasks/tests/basic.yml
@@ -0,0 +1,177 @@
+---
+- name: Registering volume name
+ set_fact:
+ vname: "{{ name_prefix ~ '-basic' }}"
+- name: Registering container name
+ set_fact:
+ vnames: "{{ vnames + [vname] }}"
+
+####################################################################
+## basic ###########################################################
+####################################################################
+
+- name: Create a volume
+ docker_volume:
+ name: "{{ vname }}"
+ register: create_1
+
+- name: Create a volume (idempotency)
+ docker_volume:
+ name: "{{ vname }}"
+ register: create_2
+
+- name: "Create a volume (recreate: options-changed)"
+ docker_volume:
+ name: "{{ vname }}"
+ recreate: options-changed
+ register: create_3
+
+- name: "Create a volume (recreate: always)"
+ docker_volume:
+ name: "{{ vname }}"
+ recreate: always
+ register: create_4
+
+- name: Remove a volume
+ docker_volume:
+ name: "{{ vname }}"
+ state: absent
+ register: absent_1
+
+- name: Remove a volume (idempotency)
+ docker_volume:
+ name: "{{ vname }}"
+ state: absent
+ register: absent_2
+
+- assert:
+ that:
+ - create_1 is changed
+ - create_2 is not changed
+ - create_3 is not changed
+ - create_4 is changed
+ - absent_1 is changed
+ - absent_2 is not changed
+
+####################################################################
+## driver_options ##################################################
+####################################################################
+
+- name: Create a volume with options
+ docker_volume:
+ name: "{{ vname }}"
+ driver: local
+ driver_options:
+ type: tempfs
+ device: tmpfs
+ o: size=100m,uid=1000
+ register: driver_options_1
+
+- name: Create a volume with options (idempotency)
+ docker_volume:
+ name: "{{ vname }}"
+ driver: local
+ driver_options:
+ type: tempfs
+ device: tmpfs
+ o: size=100m,uid=1000
+ register: driver_options_2
+
+- name: Create a volume with options (changed)
+ docker_volume:
+ name: "{{ vname }}"
+ driver: local
+ driver_options:
+ type: tempfs
+ device: tmpfs
+ o: size=200m,uid=1000
+ register: driver_options_3
+
+- name: "Create a volume with options (changed, recreate: options-changed)"
+ docker_volume:
+ name: "{{ vname }}"
+ driver: local
+ driver_options:
+ type: tempfs
+ device: tmpfs
+ o: size=200m,uid=1000
+ recreate: options-changed
+ register: driver_options_4
+
+- name: Cleanup
+ docker_volume:
+ name: "{{ vname }}"
+ state: absent
+
+- assert:
+ that:
+ - driver_options_1 is changed
+ - driver_options_2 is not changed
+ - driver_options_3 is not changed
+ - driver_options_4 is changed
+
+####################################################################
+## labels ##########################################################
+####################################################################
+
+- name: Create a volume with labels
+ docker_volume:
+ name: "{{ vname }}"
+ labels:
+ ansible.test.1: hello
+ ansible.test.2: world
+ register: driver_labels_1
+
+- name: Create a volume with labels (idempotency)
+ docker_volume:
+ name: "{{ vname }}"
+ labels:
+ ansible.test.2: world
+ ansible.test.1: hello
+ register: driver_labels_2
+
+- name: Create a volume with labels (less)
+ docker_volume:
+ name: "{{ vname }}"
+ labels:
+ ansible.test.1: hello
+ register: driver_labels_3
+
+- name: "Create a volume with labels (less, recreate: options-changed)"
+ docker_volume:
+ name: "{{ vname }}"
+ labels:
+ ansible.test.1: hello
+ recreate: options-changed
+ register: driver_labels_4
+
+- name: Create a volume with labels (more)
+ docker_volume:
+ name: "{{ vname }}"
+ labels:
+ ansible.test.1: hello
+ ansible.test.3: ansible
+ register: driver_labels_5
+
+- name: "Create a volume with labels (more, recreate: options-changed)"
+ docker_volume:
+ name: "{{ vname }}"
+ labels:
+ ansible.test.1: hello
+ ansible.test.3: ansible
+ recreate: options-changed
+ register: driver_labels_6
+
+- name: Cleanup
+ docker_volume:
+ name: "{{ vname }}"
+ state: absent
+
+- assert:
+ that:
+ - driver_labels_1 is changed
+ - driver_labels_2 is not changed
+ - driver_labels_3 is not changed
+ - driver_labels_4 is not changed
+ - driver_labels_5 is not changed
+ - driver_labels_6 is changed
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume_info/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume_info/aliases
new file mode 100644
index 00000000..02b78723
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume_info/aliases
@@ -0,0 +1,2 @@
+shippable/posix/group4
+destructive
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume_info/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume_info/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume_info/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume_info/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume_info/tasks/main.yml
new file mode 100644
index 00000000..30f71e32
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/docker_volume_info/tasks/main.yml
@@ -0,0 +1,74 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- block:
+ - name: Create random volume name
+ set_fact:
+ cname: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
+
+ - name: Make sure volume is not there
+ docker_volume:
+ name: "{{ cname }}"
+ state: absent
+
+ - name: Inspect a non-present volume
+ docker_volume_info:
+ name: "{{ cname }}"
+ register: result
+
+ - assert:
+ that:
+ - "not result.exists"
+ - "'volume' in result"
+ - "result.volume is none"
+
+ - name: Make sure volume exists
+ docker_volume:
+ name: "{{ cname }}"
+
+ - name: Inspect a present volume
+ docker_volume_info:
+ name: "{{ cname }}"
+ register: result
+ - name: Dump docker_volume_info result
+ debug: var=result
+
+ - name: "Comparison: use 'docker volume inspect'"
+ command: docker volume inspect "{{ cname }}"
+ register: docker_volume_inspect
+ ignore_errors: yes
+ - block:
+ - set_fact:
+ docker_volume_inspect_result: "{{ docker_volume_inspect.stdout | from_json }}"
+ - name: Dump docker volume inspect result
+ debug: var=docker_volume_inspect_result
+ when: docker_volume_inspect is not failed
+
+ - name: Cleanup
+ docker_volume:
+ name: "{{ cname }}"
+ state: absent
+
+ - assert:
+ that:
+ - result.exists
+ - "'volume' in result"
+ - "result.volume"
+
+ - assert:
+ that:
+ - "result.volume == docker_volume_inspect_result[0]"
+ when: docker_volume_inspect is not failed
+ - assert:
+ that:
+ - "'is too new. Maximum supported API version is' in docker_volume_inspect.stderr"
+ when: docker_volume_inspect is failed
+
+ # Requirements for docker_volume
+ when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.24', '>=')
+
+- fail: msg="Too old docker / docker-py version to run docker_volume_info tests!"
+ when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.24', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/aliases
new file mode 100644
index 00000000..d4bad10d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/aliases
@@ -0,0 +1,3 @@
+shippable/posix/group4
+destructive
+needs/root
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/inventory_1.docker.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/inventory_1.docker.yml
new file mode 100644
index 00000000..60a5b056
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/inventory_1.docker.yml
@@ -0,0 +1,2 @@
+plugin: community.docker.docker_containers
+docker_host: unix://var/run/docker.sock
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/inventory_2.docker.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/inventory_2.docker.yml
new file mode 100644
index 00000000..ec8db12e
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/inventory_2.docker.yml
@@ -0,0 +1,6 @@
+plugin: community.docker.docker_containers
+docker_host: unix://var/run/docker.sock
+connection_type: ssh
+verbose_output: true
+add_legacy_groups: true
+default_ip: 1.2.3.4
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/docker_cleanup.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/docker_cleanup.yml
new file mode 100644
index 00000000..ef0ac9e9
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/docker_cleanup.yml
@@ -0,0 +1,22 @@
+---
+- hosts: 127.0.0.1
+ connection: local
+ gather_facts: yes
+ tasks:
+ - name: remove docker containers
+ docker_container:
+ name: "{{ item }}"
+ state: absent
+ force_kill: yes
+ loop:
+ - ansible-test-docker-inventory-container-1
+ - ansible-test-docker-inventory-container-2
+
+ - name: remove docker pagkages
+ action: "{{ ansible_facts.pkg_mgr }}"
+ args:
+ name:
+ - docker
+ - docker-ce
+ - docker-ce-cli
+ state: absent
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/docker_setup.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/docker_setup.yml
new file mode 100644
index 00000000..89ebdb4f
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/docker_setup.yml
@@ -0,0 +1,22 @@
+---
+- hosts: 127.0.0.1
+ connection: local
+ vars:
+ docker_skip_cleanup: yes
+
+ tasks:
+ - name: Setup docker
+ import_role:
+ name: setup_docker
+
+ - name: Start containers
+ docker_container:
+ name: "{{ item.name }}"
+ image: "{{ docker_test_image_alpine }}"
+ state: started
+ command: '/bin/sh -c "sleep 10m"'
+ published_ports:
+ - 22/tcp
+ loop:
+ - name: ansible-test-docker-inventory-container-1
+ - name: ansible-test-docker-inventory-container-2
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/test_inventory_1.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/test_inventory_1.yml
new file mode 100644
index 00000000..aa18e19c
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/test_inventory_1.yml
@@ -0,0 +1,36 @@
+---
+- hosts: 127.0.0.1
+ connection: local # otherwise Ansible will complain that it cannot connect via ssh to 127.0.0.1:22
+ gather_facts: no
+ tasks:
+ - name: Show all groups
+ debug:
+ var: groups
+ - name: Make sure that the default groups are there, but no others
+ assert:
+ that:
+ - groups.all | length >= 2
+ - groups.ungrouped | length >= 2
+ - groups | length == 2
+
+- hosts: all
+ gather_facts: false
+ tasks:
+ - when:
+ # When the integration tests are run inside a docker container, there
+ # will be other containers.
+ - inventory_hostname.startswith('ansible-test-docker-inventory-container-')
+ block:
+
+ - name: Run raw command
+ raw: ls /
+ register: output
+
+ - name: Check whether we have some directories we expect in the output
+ assert:
+ that:
+ - "'bin' in output.stdout_lines"
+ - "'dev' in output.stdout_lines"
+ - "'lib' in output.stdout_lines"
+ - "'proc' in output.stdout_lines"
+ - "'sys' in output.stdout_lines"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/test_inventory_2.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/test_inventory_2.yml
new file mode 100644
index 00000000..c17d2840
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/playbooks/test_inventory_2.yml
@@ -0,0 +1,45 @@
+---
+- hosts: 127.0.0.1
+ connection: local # otherwise Ansible will complain that it cannot connect via ssh to 127.0.0.1:22
+ gather_facts: no
+ tasks:
+ - name: Show all groups
+ debug:
+ var: groups
+ - name: Load variables
+ include_vars: ../../setup_docker/vars/main.yml
+ - name: Make sure that the expected groups are there
+ assert:
+ that:
+ - groups.all | length >= 2
+ - groups.ungrouped | length >= 0
+ - groups.running | length >= 2
+ - groups.stopped | length >= 0
+ - groups['image_' ~ docker_test_image_alpine] | length == 2
+ - groups['ansible-test-docker-inventory-container-1'] | length == 1
+ - groups['ansible-test-docker-inventory-container-2'] | length == 1
+ - groups['unix://var/run/docker.sock'] | length >= 2
+ - groups | length >= 12
+ # The four additional groups are IDs and short IDs of the containers.
+ # When the integration tests are run inside a docker container, there
+ # will be more groups (for the additional container(s)).
+
+- hosts: all
+ # We don't really want to connect to the nodes, since we have no SSH daemon running on them
+ connection: local
+ vars:
+ ansible_python_interpreter: "{{ ansible_playbook_python }}"
+ gather_facts: no
+ tasks:
+ - name: Show all variables
+ debug:
+ var: hostvars[inventory_hostname]
+ - name: Make sure SSH is set up
+ assert:
+ that:
+ - ansible_ssh_host == '1.2.3.4'
+ - ansible_ssh_port == docker_networksettings.Ports['22/tcp'][0].HostPort
+ when:
+ # When the integration tests are run inside a docker container, there
+ # will be other containers.
+ - inventory_hostname.startswith('ansible-test-docker-inventory-container-')
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/runme.sh b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/runme.sh
new file mode 100755
index 00000000..0ea425b8
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_containers/runme.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+[[ -n "$DEBUG" || -n "$ANSIBLE_DEBUG" ]] && set -x
+
+set -euo pipefail
+
+cleanup() {
+ echo "Cleanup"
+ ansible-playbook playbooks/docker_cleanup.yml
+ echo "Done"
+}
+
+trap cleanup INT TERM EXIT
+
+echo "Setup"
+ANSIBLE_ROLES_PATH=.. ansible-playbook playbooks/docker_setup.yml
+
+echo "Test docker_containers inventory 1"
+ansible-playbook -i inventory_1.docker.yml playbooks/test_inventory_1.yml
+
+echo "Test docker_containers inventory 2"
+ansible-playbook -i inventory_2.docker.yml playbooks/test_inventory_2.yml
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/aliases
new file mode 100644
index 00000000..1a7a54b4
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/aliases
@@ -0,0 +1,4 @@
+disabled
+shippable/posix/group2
+destructive
+needs/root
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/docker-machine b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/docker-machine
new file mode 100644
index 00000000..be5d00c5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/docker-machine
@@ -0,0 +1,20 @@
+#!/usr/bin/env bash
+# Mock Docker Machine wrapper for testing purposes
+
+[ "$MOCK_ERROR_IN" == "$1" ] && echo >&2 "Mock Docker Machine error" && exit 1
+case $1 in
+ env)
+ cat <<'EOF'
+export DOCKER_TLS_VERIFY="1"
+export DOCKER_HOST="tcp://134.209.204.160:2376"
+export DOCKER_CERT_PATH="/root/.docker/machine/machines/routinator"
+export DOCKER_MACHINE_NAME="routinator"
+# Run this command to configure your shell:
+# eval $(docker-machine env --shell=bash routinator)
+EOF
+ ;;
+
+ *)
+ /usr/bin/docker-machine $*
+ ;;
+esac
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/inventory_1.docker_machine.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/inventory_1.docker_machine.yml
new file mode 100644
index 00000000..caf34787
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/inventory_1.docker_machine.yml
@@ -0,0 +1 @@
+plugin: community.docker.docker_machine
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/inventory_2.docker_machine.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/inventory_2.docker_machine.yml
new file mode 100644
index 00000000..00efaec9
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/inventory_2.docker_machine.yml
@@ -0,0 +1,2 @@
+plugin: community.docker.docker_machine
+daemon_env: require
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/inventory_3.docker_machine.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/inventory_3.docker_machine.yml
new file mode 100644
index 00000000..0fe42019
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/inventory_3.docker_machine.yml
@@ -0,0 +1,2 @@
+plugin: community.docker.docker_machine
+daemon_env: optional
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/pre-setup.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/pre-setup.yml
new file mode 100644
index 00000000..9f526fb4
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/pre-setup.yml
@@ -0,0 +1,18 @@
+---
+- hosts: 127.0.0.1
+ connection: local
+ tasks:
+ - name: Setup docker
+ include_role:
+ name: setup_docker
+
+ # There seems to be no better way to install docker-machine. At least I couldn't find any packages for RHEL7/8.
+ - name: Download docker-machine binary
+ vars:
+ docker_machine_version: "0.16.1"
+ get_url:
+ url: "https://github.com/docker/machine/releases/download/v{{ docker_machine_version }}/docker-machine-{{ ansible_system }}-{{ ansible_userspace_architecture }}"
+ dest: /tmp/docker-machine
+ - name: Install docker-machine binary
+ command: install /tmp/docker-machine /usr/bin/docker-machine
+ become: yes
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/setup.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/setup.yml
new file mode 100644
index 00000000..78042b62
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/setup.yml
@@ -0,0 +1,11 @@
+---
+- hosts: 127.0.0.1
+ connection: local
+ tasks:
+ - name: Request Docker Machine to use this machine as a generic VM
+ command: "docker-machine --debug create \
+ --driver generic \
+ --generic-ip-address=localhost \
+ --generic-ssh-key {{ lookup('env', 'HOME') }}/.ssh/id_rsa \
+ --generic-ssh-user root \
+ vm"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/teardown.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/teardown.yml
new file mode 100644
index 00000000..b272c094
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/teardown.yml
@@ -0,0 +1,6 @@
+---
+- hosts: 127.0.0.1
+ connection: local
+ tasks:
+ - name: Request Docker Machine to remove this machine as a generic VM
+ command: "docker-machine rm vm -f"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/test_inventory_1.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/test_inventory_1.yml
new file mode 100644
index 00000000..d75c69b2
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/playbooks/test_inventory_1.yml
@@ -0,0 +1,50 @@
+- hosts: 127.0.0.1
+ gather_facts: no
+ tasks:
+ - name: sanity check Docker Machine output
+ vars:
+ dm_ls_format: !unsafe '{{.Name}} | {{.DriverName}} | {{.State}} | {{.URL}} | {{.Error}}'
+ success_regex: "^vm | [^|]+ | Running | tcp://.+ |$"
+ command: docker-machine ls --format '{{ dm_ls_format }}'
+ register: result
+ failed_when: result.rc != 0 or result.stdout is not match(success_regex)
+
+ - name: verify Docker Machine ip
+ command: docker-machine ip vm
+ register: result
+ failed_when: result.rc != 0 or result.stdout != hostvars['vm'].ansible_host
+
+ - name: verify Docker Machine env
+ command: docker-machine env --shell=sh vm
+ register: result
+
+ - debug: var=result.stdout
+
+ - assert:
+ that:
+ - "'DOCKER_TLS_VERIFY=\"{{ hostvars['vm'].dm_DOCKER_TLS_VERIFY }}\"' in result.stdout"
+ - "'DOCKER_HOST=\"{{ hostvars['vm'].dm_DOCKER_HOST }}\"' in result.stdout"
+ - "'DOCKER_CERT_PATH=\"{{ hostvars['vm'].dm_DOCKER_CERT_PATH }}\"' in result.stdout"
+ - "'DOCKER_MACHINE_NAME=\"{{ hostvars['vm'].dm_DOCKER_MACHINE_NAME }}\"' in result.stdout"
+
+- hosts: vm
+ gather_facts: no
+ tasks:
+ - name: do something to verify that accept-new ssh setting was applied by the docker-machine inventory plugin
+ raw: uname -a
+ register: result
+
+ - debug: var=result.stdout
+
+- hosts: 127.0.0.1
+ gather_facts: no
+ environment:
+ DOCKER_CERT_PATH: "{{ hostvars['vm'].dm_DOCKER_CERT_PATH }}"
+ DOCKER_HOST: "{{ hostvars['vm'].dm_DOCKER_HOST }}"
+ DOCKER_MACHINE_NAME: "{{ hostvars['vm'].dm_DOCKER_MACHINE_NAME }}"
+ DOCKER_TLS_VERIFY: "{{ hostvars['vm'].dm_DOCKER_TLS_VERIFY }}"
+ tasks:
+ - name: run a Docker container on the target Docker Machine host to verify that Docker daemon connection settings from the docker-machine inventory plugin work as expected
+ docker_container:
+ name: test
+ image: "{{ docker_test_image_hello_world }}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/runme.sh b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/runme.sh
new file mode 100755
index 00000000..074e64fc
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/runme.sh
@@ -0,0 +1,68 @@
+#!/usr/bin/env bash
+
+SCRIPT_DIR=$(dirname "$0")
+
+echo "Who am I: $(whoami)"
+echo "Home: ${HOME}"
+echo "PWD: $(pwd)"
+echo "Script dir: ${SCRIPT_DIR}"
+
+# restrict Ansible just to our inventory plugin, to prevent inventory data being matched by the test but being provided
+# by some other dynamic inventory provider
+export ANSIBLE_INVENTORY_ENABLED=docker_machine
+
+[[ -n "$DEBUG" || -n "$ANSIBLE_DEBUG" ]] && set -x
+
+set -euo pipefail
+
+SAVED_PATH="$PATH"
+
+cleanup() {
+ PATH="${SAVED_PATH}"
+ echo "Cleanup"
+ ansible-playbook -i teardown.docker_machine.yml playbooks/teardown.yml
+ echo "Done"
+}
+
+trap cleanup INT TERM EXIT
+
+echo "Pre-setup (install docker, docker-machine)"
+ANSIBLE_ROLES_PATH=.. ansible-playbook playbooks/pre-setup.yml
+
+echo "Print docker-machine version"
+docker-machine --version
+
+echo "Check preconditions"
+# Host should NOT be known to Ansible before the test starts
+ansible-inventory -i inventory_1.docker_machine.yml --host vm >/dev/null && exit 1
+
+echo "Test that the docker_machine inventory plugin is being loaded"
+ANSIBLE_DEBUG=yes ansible-inventory -i inventory_1.docker_machine.yml --list | grep -F "Loading InventoryModule 'docker_machine'"
+
+echo "Setup"
+ansible-playbook playbooks/setup.yml
+
+echo "Test docker_machine inventory 1"
+ansible-playbook -i inventory_1.docker_machine.yml playbooks/test_inventory_1.yml
+
+echo "Activate Docker Machine mock"
+PATH=${SCRIPT_DIR}:$PATH
+
+echo "Test docker_machine inventory 2: daemon_env=require daemon env success=yes"
+ansible-inventory -i inventory_2.docker_machine.yml --list
+
+echo "Test docker_machine inventory 2: daemon_env=require daemon env success=no"
+export MOCK_ERROR_IN=env
+ansible-inventory -i inventory_2.docker_machine.yml --list
+unset MOCK_ERROR_IN
+
+echo "Test docker_machine inventory 3: daemon_env=optional daemon env success=yes"
+ansible-inventory -i inventory_3.docker_machine.yml --list
+
+echo "Test docker_machine inventory 3: daemon_env=optional daemon env success=no"
+export MOCK_ERROR_IN=env
+ansible-inventory -i inventory_2.docker_machine.yml --list
+unset MOCK_ERROR_IN
+
+echo "Deactivate Docker Machine mock"
+PATH="${SAVED_PATH}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/teardown.docker_machine.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/teardown.docker_machine.yml
new file mode 100644
index 00000000..046f4782
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_machine/teardown.docker_machine.yml
@@ -0,0 +1,3 @@
+plugin: community.docker.docker_machine
+daemon_env: skip
+running_required: false
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/aliases
new file mode 100644
index 00000000..f225f586
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/aliases
@@ -0,0 +1,3 @@
+shippable/posix/group2
+destructive
+needs/root
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/inventory_1.docker_swarm.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/inventory_1.docker_swarm.yml
new file mode 100644
index 00000000..03e11820
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/inventory_1.docker_swarm.yml
@@ -0,0 +1,2 @@
+plugin: community.docker.docker_swarm
+docker_host: unix://var/run/docker.sock
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/inventory_2.docker_swarm.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/inventory_2.docker_swarm.yml
new file mode 100644
index 00000000..03d3c554
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/inventory_2.docker_swarm.yml
@@ -0,0 +1,4 @@
+plugin: community.docker.docker_swarm
+docker_host: unix://var/run/docker.sock
+verbose_output: false
+include_host_uri: true
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/meta/main.yml
new file mode 100644
index 00000000..07da8c6d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/meta/main.yml
@@ -0,0 +1,3 @@
+---
+dependencies:
+ - setup_docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/swarm_cleanup.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/swarm_cleanup.yml
new file mode 100644
index 00000000..9cf87159
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/swarm_cleanup.yml
@@ -0,0 +1,18 @@
+---
+- hosts: 127.0.0.1
+ connection: local
+ gather_facts: yes
+ tasks:
+ - name: Make sure swarm is removed
+ docker_swarm:
+ state: absent
+ force: yes
+
+ - name: remove docker pagkages
+ action: "{{ ansible_facts.pkg_mgr }}"
+ args:
+ name:
+ - docker
+ - docker-ce
+ - docker-ce-cli
+ state: absent
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/swarm_setup.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/swarm_setup.yml
new file mode 100644
index 00000000..6fe0f874
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/swarm_setup.yml
@@ -0,0 +1,15 @@
+---
+- hosts: 127.0.0.1
+ connection: local
+ vars:
+ docker_skip_cleanup: yes
+
+ tasks:
+ - name: Setup docker
+ import_role:
+ name: setup_docker
+
+ - name: Create a Swarm cluster
+ community.docker.docker_swarm:
+ state: present
+ advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/test_inventory_1.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/test_inventory_1.yml
new file mode 100644
index 00000000..600a89b1
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/test_inventory_1.yml
@@ -0,0 +1,58 @@
+---
+- hosts: 127.0.0.1
+ connection: local # otherwise Ansible will complain that it cannot connect via ssh to 127.0.0.1:22
+ gather_facts: no
+ tasks:
+ - name: Show all groups
+ debug:
+ var: groups
+ - name: Make sure docker_swarm groups are there
+ assert:
+ that:
+ - groups.all | length > 0
+ - groups.leader | length == 1
+ - groups.manager | length > 0
+ - groups.worker | length >= 0
+ - groups.nonleaders | length >= 0
+
+- hosts: all
+ connection: local # otherwise Ansible will complain that it cannot connect via ssh to 127.0.0.1:22
+ vars:
+ # for some reason, Ansible can't find the Python interpreter when connecting to the nodes,
+ # which is in fact just localhost in disguise. That's why we use ansible_playbook_python.
+ ansible_python_interpreter: "{{ ansible_playbook_python }}"
+ tasks:
+ - name: Check for groups
+ assert:
+ that:
+ - "groups.manager | length > 0"
+ - "groups.worker | length >= 0"
+ - "groups.leader | length == 1"
+ run_once: yes
+
+ - name: List manager group
+ debug:
+ var: groups.manager
+ run_once: yes
+
+ - name: List worker group
+ debug:
+ var: groups.worker
+ run_once: yes
+
+ - name: List leader group
+ debug:
+ var: groups.leader
+ run_once: yes
+
+ - name: Print ansible_host per host
+ debug:
+ var: ansible_host
+
+ - name: Make sure docker_swarm_node_attributes is available
+ assert:
+ that:
+ - docker_swarm_node_attributes is not undefined
+ - name: Print docker_swarm_node_attributes per host
+ debug:
+ var: docker_swarm_node_attributes
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/test_inventory_2.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/test_inventory_2.yml
new file mode 100644
index 00000000..b2a794d3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/playbooks/test_inventory_2.yml
@@ -0,0 +1,35 @@
+---
+- hosts: 127.0.0.1
+ connection: local # otherwise Ansible will complain that it cannot connect via ssh to 127.0.0.1:22
+ gather_facts: no
+ tasks:
+ - name: Show all groups
+ debug:
+ var: groups
+ - name: Make sure docker_swarm groups are there
+ assert:
+ that:
+ - groups.all | length > 0
+ - groups.leader | length == 1
+ - groups.manager | length > 0
+ - groups.worker | length >= 0
+ - groups.nonleaders | length >= 0
+
+- hosts: all
+ connection: local # otherwise Ansible will complain that it cannot connect via ssh to 127.0.0.1:22
+ vars:
+ # for some reason, Ansible can't find the Python interpreter when connecting to the nodes,
+ # which is in fact just localhost in disguise. That's why we use ansible_playbook_python.
+ ansible_python_interpreter: "{{ ansible_playbook_python }}"
+ tasks:
+ - name: Make sure docker_swarm_node_attributes is not available
+ assert:
+ that:
+ - docker_swarm_node_attributes is undefined
+ - name: Make sure ansible_host_uri is available
+ assert:
+ that:
+ - ansible_host_uri is defined
+ - name: Print ansible_host_uri
+ debug:
+ var: ansible_host_uri
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/runme.sh b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/runme.sh
new file mode 100755
index 00000000..b93d386a
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/inventory_docker_swarm/runme.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+[[ -n "$DEBUG" || -n "$ANSIBLE_DEBUG" ]] && set -x
+
+set -euo pipefail
+
+cleanup() {
+ echo "Cleanup"
+ ansible-playbook playbooks/swarm_cleanup.yml
+ echo "Done"
+}
+
+trap cleanup INT TERM EXIT
+
+echo "Setup"
+ANSIBLE_ROLES_PATH=.. ansible-playbook playbooks/swarm_setup.yml
+
+echo "Test docker_swarm inventory 1"
+ansible-playbook -i inventory_1.docker_swarm.yml playbooks/test_inventory_1.yml
+
+echo "Test docker_swarm inventory 2"
+ansible-playbook -i inventory_2.docker_swarm.yml playbooks/test_inventory_2.yml
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/aliases
new file mode 100644
index 00000000..65e83152
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/aliases
@@ -0,0 +1 @@
+needs/target/setup_epel
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/defaults/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/defaults/main.yml
new file mode 100644
index 00000000..661a309e
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/defaults/main.yml
@@ -0,0 +1,19 @@
+---
+docker_cli_version: '0.0'
+docker_api_version: '0.0'
+docker_py_version: '0.0'
+docker_skip_cleanup: yes
+docker_prereq_packages: []
+docker_packages:
+ - docker-ce
+docker_cli_packages:
+ - docker-ce-cli
+
+docker_pip_extra_packages: []
+docker_pip_package: docker
+docker_pip_package_limit: ''
+
+docker_cleanup_packages:
+ - docker
+ - docker-ce
+ - docker-ce-cli
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/handlers/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/handlers/main.yml
new file mode 100644
index 00000000..a389f91d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/handlers/main.yml
@@ -0,0 +1,14 @@
+- name: Remove pip packages
+ pip:
+ state: present
+ name: "{{ [docker_pip_package] | union(docker_pip_extra_packages) }}"
+ listen: cleanup docker
+ when: not docker_skip_cleanup | bool
+
+- name: Remove docker pagkages
+ action: "{{ ansible_facts.pkg_mgr }}"
+ args:
+ name: "{{ docker_cleanup_packages }}"
+ state: absent
+ listen: cleanup docker
+ when: not docker_skip_cleanup | bool
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/meta/main.yml
new file mode 100644
index 00000000..2be15776
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/meta/main.yml
@@ -0,0 +1,3 @@
+dependencies:
+ - setup_remote_constraints
+ - setup_pkg_mgr
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/Debian.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/Debian.yml
new file mode 100644
index 00000000..84a1428b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/Debian.yml
@@ -0,0 +1,45 @@
+---
+- name: Get OS version
+ shell: uname -r
+ register: os_version
+
+- name: Install pre-reqs
+ apt:
+ name: '{{ docker_prereq_packages }}'
+ state: present
+ update_cache: true
+ notify: cleanup docker
+
+- name: Add gpg key
+ shell: curl -fsSL https://download.docker.com/linux/ubuntu/gpg >key && apt-key add key
+
+- name: Add Docker repo
+ shell: add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable"
+
+- block:
+ - name: Prevent service restart
+ copy:
+ content: exit 101
+ dest: /usr/sbin/policy-rc.d
+ backup: true
+ mode: '0755'
+ register: policy_rc_d
+
+ - name: Install Docker CE
+ apt:
+ name: '{{ docker_packages if needs_docker_daemon else docker_cli_packages }}'
+ state: present
+ update_cache: true
+
+ always:
+ - name: Restore /usr/sbin/policy-rc.d (if needed)
+ command: mv {{ policy_rc_d.backup_file }} /usr/sbin/policy-rc.d
+ when:
+ - '''backup_file'' in policy_rc_d'
+
+ - name: Remove /usr/sbin/policy-rc.d (if needed)
+ file:
+ path: /usr/sbin/policy-rc.d
+ state: absent
+ when:
+ - '''backup_file'' not in policy_rc_d'
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/Fedora.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/Fedora.yml
new file mode 100644
index 00000000..f50cc2c8
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/Fedora.yml
@@ -0,0 +1,26 @@
+---
+- name: Import GPG key
+ rpm_key:
+ key: https://download.docker.com/linux/fedora/gpg
+ state: present
+
+- name: Add repository
+ yum_repository:
+ file: docker-ce
+ name: docker-ce-stable
+ description: Docker CE Stable - $basearch
+ baseurl: https://download.docker.com/linux/fedora/{{ 31 if ansible_facts.distribution_major_version|int > 31 else '$releasever' }}/$basearch/stable
+ enabled: yes
+ gpgcheck: yes
+
+- name: Update cache
+ command: dnf makecache
+ args:
+ warn: no
+
+- name: Install docker
+ dnf:
+ name: "{{ docker_packages if needs_docker_daemon else docker_cli_packages }}"
+ state: present
+ enablerepo: docker-ce-test
+ notify: cleanup docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/RedHat-7.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/RedHat-7.yml
new file mode 100644
index 00000000..abcc2b8a
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/RedHat-7.yml
@@ -0,0 +1,46 @@
+---
+# The RHEL extras repository must be enabled to provide the container-selinux package.
+# See: https://docs.docker.com/engine/installation/linux/docker-ee/rhel/#install-using-the-repository
+
+- name: Install Docker pre-reqs
+ yum:
+ name: "{{ docker_prereq_packages }}"
+ state: present
+ notify: cleanup docker
+
+- name: Install epel repo which is missing on rhel-7 and is needed for pigz (needed for docker-ce 18)
+ include_role:
+ name: setup_epel
+
+- name: Enable extras repository for RHEL on AWS
+ # RHEL 7.6 uses REGION-rhel-server-extras and RHEL 7.7+ use rhel-7-server-rhui-extras-rpms
+ command: yum-config-manager --enable REGION-rhel-server-extras rhel-7-server-rhui-extras-rpms
+ args:
+ warn: no
+
+# Docker broke their .repo file, so we set it up ourselves
+- name: Set-up repository
+ yum_repository:
+ name: docker-ce
+ description: docker-ce
+ baseurl: https://download.docker.com/linux/centos/{{ ansible_facts.distribution_major_version }}/$basearch/stable
+ gpgcheck: true
+ gpgkey: https://download.docker.com/linux/centos/gpg
+
+- name: Update cache
+ command: yum -y makecache fast
+ args:
+ warn: no
+
+- name: Install docker
+ yum:
+ name: "{{ docker_packages if needs_docker_daemon else docker_cli_packages }}"
+ state: present
+ notify: cleanup docker
+
+- name: Make sure the docker daemon is running (failure expected inside docker container)
+ service:
+ name: docker
+ state: started
+ ignore_errors: "{{ ansible_virtualization_type in ['docker', 'container', 'containerd'] }}"
+ when: needs_docker_daemon
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/RedHat-8.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/RedHat-8.yml
new file mode 100644
index 00000000..a7c7d586
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/RedHat-8.yml
@@ -0,0 +1,35 @@
+---
+# The RHEL extras repository must be enabled to provide the container-selinux package.
+# See: https://docs.docker.com/engine/installation/linux/docker-ee/rhel/#install-using-the-repository
+
+- name: Install Docker pre-reqs
+ dnf:
+ name: "{{ docker_prereq_packages }}"
+ state: present
+ notify: cleanup docker
+ register: result
+ until: result is success
+ retries: 10
+ delay: 2
+
+# Docker broke their .repo file, so we set it up ourselves
+- name: Set-up repository
+ yum_repository:
+ name: docker-ce
+ description: docker-ce
+ baseurl: https://download.docker.com/linux/centos/{{ ansible_facts.distribution_major_version }}/$basearch/stable
+ gpgcheck: true
+ gpgkey: https://download.docker.com/linux/centos/gpg
+
+- name: Install docker
+ dnf:
+ name: "{{ docker_packages if needs_docker_daemon else docker_cli_packages }}"
+ state: present
+ notify: cleanup docker
+
+- name: Make sure the docker daemon is running (failure expected inside docker container)
+ service:
+ name: docker
+ state: started
+ ignore_errors: "{{ ansible_virtualization_type in ['docker', 'container', 'containerd'] }}"
+ when: needs_docker_daemon
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/Suse.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/Suse.yml
new file mode 100644
index 00000000..52cdc1ba
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/Suse.yml
@@ -0,0 +1,8 @@
+---
+- name: Install docker 17
+ community.general.zypper:
+ name: "{{ docker_packages if needs_docker_daemon else docker_cli_packages }}"
+ force: yes
+ disable_gpg_check: yes
+ update_cache: yes
+ notify: cleanup docker
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/main.yml
new file mode 100644
index 00000000..ed54a6da
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/tasks/main.yml
@@ -0,0 +1,154 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- name: Setup Docker
+ when: ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['CentOS6', 'RedHat6']
+ block:
+ - name: Detect whether we are running inside a container
+ current_container_facts:
+
+ - name: Determine whether Docker Daemon needs to be installed
+ set_fact:
+ needs_docker_daemon: '{{ not ansible_module_running_in_container }}'
+
+ - name: Include distribution specific variables
+ include_vars: "{{ lookup('first_found', params) }}"
+ vars:
+ params:
+ files:
+ - "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
+ - "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml"
+ - "{{ ansible_facts.distribution }}.yml"
+ - "{{ ansible_facts.os_family }}.yml"
+ - default.yml
+ paths:
+ - "{{ role_path }}/vars"
+
+ - name: Include distribution specific tasks
+ include_tasks: "{{ lookup('first_found', params) }}"
+ vars:
+ params:
+ files:
+ - "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml"
+ - "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml"
+ - "{{ ansible_facts.distribution }}.yml"
+ - "{{ ansible_facts.os_family }}.yml"
+ paths:
+ - "{{ role_path }}/tasks"
+
+ # Detect docker API version
+ - name: Check Docker API version
+ command: "docker version -f {% raw %}'{{(index .Server.Components 0).Details.ApiVersion}}'{% endraw %}"
+ register: docker_api_version_stdout
+ ignore_errors: yes
+
+ - name: Limit docker pypi package version to < 4.3.0
+ set_fact:
+ docker_pip_package_limit: '<4.3.0'
+ when: (docker_api_version_stdout.stdout | default('0.0')) is version('1.39', '<')
+
+ - name: Install Python requirements
+ pip:
+ state: present
+ name: "{{ [docker_pip_package ~ docker_pip_package_limit] + docker_pip_extra_packages }}"
+ extra_args: "-c {{ remote_constraints }}"
+ notify: cleanup docker
+
+ # Detect docker CLI, API and docker-py versions
+ - name: Check Docker CLI version
+ command: "docker version -f {% raw %}'{{.Client.Version}}'{% endraw %}"
+ register: docker_cli_version_stdout
+ ignore_errors: yes
+
+ - name: Check Docker API version
+ command: "{{ ansible_python.executable }} -c 'import docker; print(docker.from_env().version()[\"ApiVersion\"])'"
+ register: docker_api_version_stdout
+ ignore_errors: yes
+
+ - name: Check docker-py API version
+ command: "{{ ansible_python.executable }} -c 'import docker; print(docker.__version__)'"
+ register: docker_py_version_stdout
+ ignore_errors: yes
+
+ - set_fact:
+ docker_cli_version: "{{ docker_cli_version_stdout.stdout | default('0.0') }}"
+ docker_api_version: "{{ docker_api_version_stdout.stdout | default('0.0') }}"
+ docker_py_version: "{{ docker_py_version_stdout.stdout | default('0.0') }}"
+
+ - debug:
+ msg: "Docker CLI version: {{ docker_cli_version }}; Docker API version: {{ docker_api_version }}; docker-py library version: {{ docker_py_version }}"
+
+ - block:
+ # Cleanup docker daemon
+ - name: "Remove all ansible-test-* docker containers"
+ shell: 'docker ps --no-trunc --format {% raw %}"{{.Names}}"{% endraw %} | grep "^ansible-test-" | xargs -r docker rm -f'
+ register: docker_containers
+ retries: 3
+ delay: 3
+ until: docker_containers is success
+ ignore_errors: yes
+
+ - name: "Remove all ansible-test-* docker volumes"
+ shell: 'docker volume ls --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-test-" | xargs -r docker volume rm -f'
+ register: docker_volumes
+ ignore_errors: yes
+
+ - name: "Remove all ansible-test-* docker networks"
+ shell: 'docker network ls --no-trunc --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-test-" | xargs -r docker network rm'
+ register: docker_networks
+ ignore_errors: yes
+
+ - name: Cleaned docker resources
+ debug:
+ var: docker_resources
+ vars:
+ docker_resources:
+ containers: "{{ docker_containers.stdout_lines | default([]) }}"
+ volumes: "{{ docker_volumes.stdout_lines | default([]) }}"
+ networks: "{{ docker_networks.stdout_lines | default([]) }}"
+
+ # List all existing docker resources
+ - name: List all docker containers
+ command: docker ps --no-trunc -a
+ register: docker_containers
+ ignore_errors: yes
+
+ - name: List all docker volumes
+ command: docker volume ls
+ register: docker_volumes
+ ignore_errors: yes
+
+ - name: List all docker networks
+ command: docker network ls --no-trunc
+ register: docker_networks
+ ignore_errors: yes
+
+ - name: List all docker images
+ command: docker images --no-trunc -a
+ register: docker_images
+ ignore_errors: yes
+
+ - name: Still existing docker resources
+ debug:
+ var: docker_resources
+ vars:
+ docker_resources:
+ containers: "{{ docker_containers.stdout_lines | default([]) }}"
+ volumes: "{{ docker_volumes.stdout_lines | default([]) }}"
+ networks: "{{ docker_networks.stdout_lines | default([]) }}"
+ images: "{{ docker_images.stdout_lines | default([]) }}"
+
+ when: docker_cli_version is version('0.0', '>')
+
+ - name: Inspect current container
+ docker_container_info:
+ name: "{{ ansible_module_container_id }}"
+ register: current_container_info
+ when: ansible_module_running_in_container
+
+ - name: Determine network name
+ set_fact:
+ current_container_network_ip: "{{ (current_container_info.container.NetworkSettings.Networks | dictsort)[0].0 | default('') if ansible_module_running_in_container else '' }}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Debian.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Debian.yml
new file mode 100644
index 00000000..66f3ac9f
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Debian.yml
@@ -0,0 +1,6 @@
+---
+docker_prereq_packages:
+ - apt-transport-https
+ - ca-certificates
+ - curl
+ - software-properties-common
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Fedora.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Fedora.yml
new file mode 100644
index 00000000..ed97d539
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Fedora.yml
@@ -0,0 +1 @@
+---
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/RedHat-7.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/RedHat-7.yml
new file mode 100644
index 00000000..100a878d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/RedHat-7.yml
@@ -0,0 +1,9 @@
+---
+docker_prereq_packages:
+ - yum-utils
+ - device-mapper-persistent-data
+ - lvm2
+ - libseccomp
+
+docker_pip_extra_packages:
+ - requests==2.6.0
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/RedHat-8.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/RedHat-8.yml
new file mode 100644
index 00000000..99af35f4
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/RedHat-8.yml
@@ -0,0 +1,12 @@
+---
+docker_prereq_packages:
+ - yum-utils
+ - device-mapper-persistent-data
+ - lvm2
+ - libseccomp
+
+docker_packages:
+ - docker-ce-19.03.13
+ - docker-ce-cli-19.03.13
+docker_cli_packages:
+ - docker-ce-cli-19.03.13
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Suse.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Suse.yml
new file mode 100644
index 00000000..1974462a
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Suse.yml
@@ -0,0 +1,8 @@
+---
+docker_packages:
+ - docker>=17
+
+# OpenSUSE 15 does not seem to have docker-client (https://software.opensuse.org/package/docker-client)
+# or any other Docker CLI-only package
+docker_cli_packages:
+ - docker>=17
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Ubuntu-14.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Ubuntu-14.yml
new file mode 100644
index 00000000..84130934
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/Ubuntu-14.yml
@@ -0,0 +1,6 @@
+---
+docker_pip_extra_packages:
+ # Installing requests >=2.12.0 on Ubuntu 14.04 breaks certificate validation. We restrict to an older version
+ # to ensure out get_url tests work out fine. This is only an issue if pyOpenSSL is also installed.
+ # Not sure why RHEL7 needs this specific version
+ - requests==2.6.0
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/default.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/default.yml
new file mode 100644
index 00000000..ed97d539
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/default.yml
@@ -0,0 +1 @@
+---
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/main.env b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/main.env
new file mode 100644
index 00000000..0fd37705
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/main.env
@@ -0,0 +1,2 @@
+# Docker images for runme.sh based tests
+DOCKER_TEST_IMAGE_PYTHON3=python:3-alpine
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/main.yml
new file mode 100644
index 00000000..8d4b74c5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker/vars/main.yml
@@ -0,0 +1,11 @@
+---
+docker_test_image_digest_v1: e004c2cc521c95383aebb1fb5893719aa7a8eae2e7a71f316a4410784edb00a9
+docker_test_image_digest_v2: ee44b399df993016003bf5466bd3eeb221305e9d0fa831606bc7902d149c775b
+docker_test_image_digest_base: quay.io/ansible/docker-test-containers
+docker_test_image_hello_world: quay.io/ansible/docker-test-containers:hello-world
+docker_test_image_hello_world_base: quay.io/ansible/docker-test-containers
+docker_test_image_busybox: quay.io/ansible/docker-test-containers:busybox
+docker_test_image_alpine: quay.io/ansible/docker-test-containers:alpine3.8
+docker_test_image_alpine_different: quay.io/ansible/docker-test-containers:alpine3.7
+docker_test_image_registry_nginx: quay.io/ansible/docker-test-containers:nginx-alpine
+docker_test_image_registry: registry:2.6.1
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/aliases
new file mode 100644
index 00000000..688c8884
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/aliases
@@ -0,0 +1,2 @@
+needs/target/setup_docker
+needs/target/setup_openssl
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/files/nginx.conf b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/files/nginx.conf
new file mode 100644
index 00000000..bfba5204
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/files/nginx.conf
@@ -0,0 +1,46 @@
+events {
+ worker_connections 16;
+}
+
+http {
+ include /etc/nginx/mime.types;
+ default_type application/octet-stream;
+
+ error_log /dev/stdout info;
+ access_log /dev/stdout;
+
+ server {
+ listen *:5000 ssl;
+ server_name test-registry.ansible.com;
+ server_name_in_redirect on;
+
+ ssl_protocols TLSv1.2;
+ ssl_ciphers 'ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384:DHE-DSS-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-RSA-AES128-SHA256';
+ ssl_ecdh_curve X25519:secp521r1:secp384r1;
+ ssl_prefer_server_ciphers on;
+ ssl_certificate /etc/nginx/cert.pem;
+ ssl_certificate_key /etc/nginx/cert.key;
+
+ location / {
+ return 401;
+ }
+
+ location /v2/ {
+ proxy_pass http://real-registry:5000;
+ proxy_http_version 1.1;
+ proxy_set_header Upgrade $http_upgrade;
+ proxy_set_header Connection "upgrade";
+ proxy_set_header Host $http_host;
+ proxy_set_header X-Forwarded-Proto $scheme;
+ proxy_set_header X-Forwarded-For $remote_addr;
+ proxy_set_header X-Forwarded-Port $server_port;
+ proxy_set_header X-Request-Start $msec;
+
+ client_max_body_size 0;
+ chunked_transfer_encoding on;
+
+ auth_basic "Ansible Test Docker Registry";
+ auth_basic_user_file /etc/nginx/nginx.htpasswd;
+ }
+ }
+}
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/files/nginx.htpasswd b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/files/nginx.htpasswd
new file mode 100644
index 00000000..1291ae77
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/files/nginx.htpasswd
@@ -0,0 +1 @@
+testuser:{PLAIN}hunter2
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/handlers/cleanup.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/handlers/cleanup.yml
new file mode 100644
index 00000000..f9d2c9e5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/handlers/cleanup.yml
@@ -0,0 +1,55 @@
+---
+- name: "Make sure all images are removed"
+ docker_image:
+ name: "{{ item }}"
+ state: absent
+ with_items: "{{ docker_registry_setup_inames }}"
+
+- name: "Get registry logs"
+ command: "docker logs {{ docker_registry_container_name_registry }}"
+ register: registry_logs
+ no_log: yes
+ ignore_errors: yes
+
+- name: "Printing registry logs"
+ debug:
+ var: registry_logs.stdout_lines
+ when: registry_logs is not failed
+
+- name: "Get nginx logs for first instance"
+ command: "docker logs {{ docker_registry_container_name_nginx }}"
+ register: nginx_logs
+ no_log: yes
+ ignore_errors: yes
+
+- name: "Get nginx logs for second instance"
+ command: "docker logs {{ docker_registry_container_name_nginx2 }}"
+ register: nginx2_logs
+ no_log: yes
+ ignore_errors: yes
+
+- name: "Printing nginx logs for first instance"
+ debug:
+ var: nginx_logs.stdout_lines
+ when: nginx_logs is not failed
+
+- name: "Printing nginx logs for second instance"
+ debug:
+ var: nginx2_logs.stdout_lines
+ when: nginx_logs is not failed
+
+- name: "Make sure all containers are removed"
+ docker_container:
+ name: "{{ item }}"
+ state: absent
+ force_kill: yes
+ with_items: "{{ docker_registry_setup_cnames }}"
+ register: result
+ retries: 3
+ delay: 3
+ until: result is success
+
+- name: "Make sure all volumes are removed"
+ command: "docker rm -f {{ item }}"
+ with_items: "{{ docker_registry_setup_vnames }}"
+ ignore_errors: yes
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/handlers/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/handlers/main.yml
new file mode 100644
index 00000000..23030182
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/handlers/main.yml
@@ -0,0 +1,3 @@
+---
+- name: Remove test registry
+ include_tasks: ../handlers/cleanup.yml
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/meta/main.yml
new file mode 100644
index 00000000..b252b0e7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/meta/main.yml
@@ -0,0 +1,3 @@
+dependencies:
+ #- setup_docker -- done in setup.yml, to work around cleanup problems!
+ - setup_openssl
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/tasks/main.yml
new file mode 100644
index 00000000..320df246
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/tasks/main.yml
@@ -0,0 +1,9 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- when: ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['CentOS6', 'RedHat6']
+ include_tasks:
+ file: setup.yml
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/tasks/setup-frontend.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/tasks/setup-frontend.yml
new file mode 100644
index 00000000..f1055ea3
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/tasks/setup-frontend.yml
@@ -0,0 +1,97 @@
+---
+# Set up first nginx frontend for registry
+- name: Start nginx frontend for registry
+ docker_volume:
+ name: '{{ docker_registry_container_name_frontend }}'
+ state: present
+
+- name: Create container for nginx frontend for registry
+ docker_container:
+ state: stopped
+ name: '{{ docker_registry_container_name_frontend }}'
+ image: "{{ docker_test_image_registry_nginx }}"
+ ports: 5000
+ # `links` does not work when using a network. That's why the docker_container task
+ # in setup.yml specifies `aliases` so we get the same effect.
+ links:
+ - '{{ docker_registry_container_name_registry }}:real-registry'
+ volumes:
+ - '{{ docker_registry_container_name_frontend }}:/etc/nginx/'
+ network_mode: '{{ current_container_network_ip | default(omit, true) }}'
+ networks: >-
+ {{
+ [dict([['name', current_container_network_ip]])]
+ if current_container_network_ip not in ['', 'bridge'] else omit
+ }}
+ register: nginx_container
+
+- name: Copy static files into volume
+ command: docker cp {{ role_path }}/files/{{ item }} {{ docker_registry_container_name_frontend }}:/etc/nginx/{{ item }}
+ loop:
+ - nginx.conf
+ - nginx.htpasswd
+ register: can_copy_files
+ ignore_errors: yes
+
+- when: can_copy_files is not failed
+ block:
+
+ - name: Create private key for frontend certificate
+ community.crypto.openssl_privatekey:
+ path: '{{ output_dir }}/cert.key'
+ type: ECC
+ curve: secp256r1
+ force: yes
+
+ - name: Create CSR for frontend certificate
+ community.crypto.openssl_csr:
+ path: '{{ output_dir }}/cert.csr'
+ privatekey_path: '{{ output_dir }}/cert.key'
+ subject_alt_name:
+ - DNS:test-registry.ansible.com
+
+ - name: Create frontend certificate
+ community.crypto.openssl_certificate:
+ path: '{{ output_dir }}/cert.pem'
+ csr_path: '{{ output_dir }}/cert.csr'
+ privatekey_path: '{{ output_dir }}/cert.key'
+ provider: selfsigned
+
+ - name: Copy dynamic files into volume
+ command: docker cp {{ output_dir }}/{{ item }} {{ docker_registry_container_name_frontend }}:/etc/nginx/{{ item }}
+ loop:
+ - cert.pem
+ - cert.key
+
+ - name: Start nginx frontend for registry
+ docker_container:
+ name: '{{ docker_registry_container_name_frontend }}'
+ state: started
+ register: nginx_container
+
+ - name: Output nginx container network settings
+ debug:
+ var: nginx_container.container.NetworkSettings
+
+ - name: Get registry URL
+ set_fact:
+ # Note that this host/port combination is used by the Docker daemon, that's why `localhost` is appropriate!
+ # This host/port combination cannot be used if the tests are running inside a docker container.
+ docker_registry_frontend_address: localhost:{{ nginx_container.container.NetworkSettings.Ports['5000/tcp'].0.HostPort }}
+ # The following host/port combination can be used from inside the docker container.
+ docker_registry_frontend_address_internal: "{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:5000"
+
+ - name: Wait for registry frontend
+ uri:
+ url: https://{{ docker_registry_frontend_address_internal }}/v2/
+ url_username: testuser
+ url_password: hunter2
+ validate_certs: false
+ register: result
+ until: result is success
+ retries: 5
+ delay: 1
+
+- set_fact:
+ docker_registry_frontend_address: 'n/a'
+ when: can_copy_files is failed
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/tasks/setup.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/tasks/setup.yml
new file mode 100644
index 00000000..6782da9d
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/tasks/setup.yml
@@ -0,0 +1,80 @@
+---
+- name: Register registry cleanup
+ # This must be done **before** docker is set up (see next task), to ensure that the
+ # registry is removed **before** docker itself is removed. This is necessary as the
+ # registry and its frontends run as docker containers.
+ command: 'true'
+ notify: Remove test registry
+
+- name: Setup Docker
+ # Please note that we do setup_docker here and not via meta/main.yml to avoid the problem that
+ # our cleanup is called **after** setup_docker's cleanup has been called!
+ include_role:
+ name: setup_docker
+
+- name: Create random name prefix and test registry name
+ set_fact:
+ docker_registry_container_name_registry: '{{ ''ansible-test-registry-%0x'' % ((2**32) | random) }}'
+ docker_registry_container_name_nginx: '{{ ''ansible-test-registry-frontend-%0x'' % ((2**32) | random) }}'
+ docker_registry_container_name_nginx2: '{{ ''ansible-test-registry-frontend2-%0x'' % ((2**32) | random) }}'
+
+- name: Create image and container list
+ set_fact:
+ docker_registry_setup_inames: []
+ docker_registry_setup_cnames:
+ - '{{ docker_registry_container_name_registry }}'
+ - '{{ docker_registry_container_name_nginx }}'
+ - '{{ docker_registry_container_name_nginx2 }}'
+ docker_registry_setup_vnames:
+ - '{{ docker_registry_container_name_nginx }}'
+ - '{{ docker_registry_container_name_nginx2 }}'
+
+- debug:
+ msg: Using test registry name {{ docker_registry_container_name_registry }} and nginx frontend names {{ docker_registry_container_name_nginx }} and {{ docker_registry_container_name_nginx2 }}
+
+- fail: msg="Too old docker / docker-py version to set up docker registry!"
+ when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
+
+- when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.20', '>=')
+ block:
+
+ # Set up registry container
+ - name: Start test registry
+ docker_container:
+ name: '{{ docker_registry_container_name_registry }}'
+ image: "{{ docker_test_image_registry }}"
+ ports: 5000
+ network_mode: '{{ current_container_network_ip | default(omit, true) }}'
+ # We need to define the alias `real-registry` here because the global `links`
+ # option for the NGINX containers (see setup-frontend.yml) does not work when
+ # using networks.
+ networks: >-
+ {{
+ [dict([['name', current_container_network_ip], ['aliases', ['real-registry']]])]
+ if current_container_network_ip not in ['', 'bridge'] else omit
+ }}
+ register: registry_container
+
+ - name: Get registry URL
+ set_fact:
+ registry_address: localhost:{{ registry_container.container.NetworkSettings.Ports['5000/tcp'].0.HostPort }}
+
+ # Set up first nginx frontend for registry
+ - include_tasks: setup-frontend.yml
+ vars:
+ docker_registry_container_name_frontend: '{{ docker_registry_container_name_nginx }}'
+
+ - set_fact:
+ registry_frontend_address: '{{ docker_registry_frontend_address }}'
+
+ # Set up second nginx frontend for registry
+ - include_tasks: setup-frontend.yml
+ vars:
+ docker_registry_container_name_frontend: '{{ docker_registry_container_name_nginx2 }}'
+
+ - set_fact:
+ registry_frontend2_address: '{{ docker_registry_frontend_address }}'
+
+ # Print addresses for registry and frontends
+ - debug:
+ msg: "Registry available under {{ registry_address }}, NGINX frontends available under {{ registry_frontend_address }} and {{ registry_frontend2_address }}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/vars/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/vars/main.yml
new file mode 100644
index 00000000..8d4b74c5
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_docker_registry/vars/main.yml
@@ -0,0 +1,11 @@
+---
+docker_test_image_digest_v1: e004c2cc521c95383aebb1fb5893719aa7a8eae2e7a71f316a4410784edb00a9
+docker_test_image_digest_v2: ee44b399df993016003bf5466bd3eeb221305e9d0fa831606bc7902d149c775b
+docker_test_image_digest_base: quay.io/ansible/docker-test-containers
+docker_test_image_hello_world: quay.io/ansible/docker-test-containers:hello-world
+docker_test_image_hello_world_base: quay.io/ansible/docker-test-containers
+docker_test_image_busybox: quay.io/ansible/docker-test-containers:busybox
+docker_test_image_alpine: quay.io/ansible/docker-test-containers:alpine3.8
+docker_test_image_alpine_different: quay.io/ansible/docker-test-containers:alpine3.7
+docker_test_image_registry_nginx: quay.io/ansible/docker-test-containers:nginx-alpine
+docker_test_image_registry: registry:2.6.1
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_epel/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_epel/tasks/main.yml
new file mode 100644
index 00000000..21627cfa
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_epel/tasks/main.yml
@@ -0,0 +1,10 @@
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- name: Install EPEL
+ yum:
+ name: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/setup_epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm
+ disable_gpg_check: true
+ when: ansible_facts.distribution in ['RedHat', 'CentOS']
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/meta/main.yml
new file mode 100644
index 00000000..2be15776
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/meta/main.yml
@@ -0,0 +1,3 @@
+dependencies:
+ - setup_remote_constraints
+ - setup_pkg_mgr
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/tasks/main.yml
new file mode 100644
index 00000000..33030ab7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/tasks/main.yml
@@ -0,0 +1,31 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- name: Include OS-specific variables
+ include_vars: '{{ ansible_os_family }}.yml'
+ when: not ansible_os_family == "Darwin"
+
+- name: Install cryptography (Python 3)
+ become: true
+ package:
+ name: '{{ cryptography_package_name_python3 }}'
+ when: ansible_os_family != 'Darwin' and ansible_python_version is version('3.0', '>=')
+
+- name: Install cryptography (Python 2)
+ become: true
+ package:
+ name: '{{ cryptography_package_name }}'
+ when: ansible_os_family != 'Darwin' and ansible_python_version is version('3.0', '<')
+
+- name: Install cryptography (Darwin, and potentially upgrade for other OSes)
+ become: true
+ pip:
+ name: cryptography>=1.3.0
+ extra_args: "-c {{ remote_constraints }}"
+
+- name: Register cryptography version
+ command: "{{ ansible_python.executable }} -c 'import cryptography; print(cryptography.__version__)'"
+ register: cryptography_version
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/Debian.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/Debian.yml
new file mode 100644
index 00000000..5ddc85e4
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/Debian.yml
@@ -0,0 +1,3 @@
+---
+cryptography_package_name: python-cryptography
+cryptography_package_name_python3: python3-cryptography
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/FreeBSD.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/FreeBSD.yml
new file mode 100644
index 00000000..cd7f36a7
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/FreeBSD.yml
@@ -0,0 +1,3 @@
+---
+cryptography_package_name: py27-cryptography
+cryptography_package_name_python3: py36-cryptography
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/RedHat.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/RedHat.yml
new file mode 100644
index 00000000..5ddc85e4
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/RedHat.yml
@@ -0,0 +1,3 @@
+---
+cryptography_package_name: python-cryptography
+cryptography_package_name_python3: python3-cryptography
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/Suse.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/Suse.yml
new file mode 100644
index 00000000..5ddc85e4
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_openssl/vars/Suse.yml
@@ -0,0 +1,3 @@
+---
+cryptography_package_name: python-cryptography
+cryptography_package_name_python3: python3-cryptography
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_pkg_mgr/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_pkg_mgr/tasks/main.yml
new file mode 100644
index 00000000..24d02228
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_pkg_mgr/tasks/main.yml
@@ -0,0 +1,17 @@
+---
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- set_fact:
+ pkg_mgr: community.general.pkgng
+ ansible_pkg_mgr: community.general.pkgng
+ cacheable: yes
+ when: ansible_os_family == "FreeBSD"
+
+- set_fact:
+ pkg_mgr: community.general.zypper
+ ansible_pkg_mgr: community.general.zypper
+ cacheable: yes
+ when: ansible_os_family == "Suse"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_constraints/aliases b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_constraints/aliases
new file mode 100644
index 00000000..1ad133ba
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_constraints/aliases
@@ -0,0 +1 @@
+needs/file/tests/utils/constraints.txt
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_constraints/meta/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_constraints/meta/main.yml
new file mode 100644
index 00000000..1810d4be
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_constraints/meta/main.yml
@@ -0,0 +1,2 @@
+dependencies:
+ - setup_remote_tmp_dir
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_constraints/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_constraints/tasks/main.yml
new file mode 100644
index 00000000..d4f8148c
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_constraints/tasks/main.yml
@@ -0,0 +1,13 @@
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- name: record constraints.txt path on remote host
+ set_fact:
+ remote_constraints: "{{ remote_tmp_dir }}/constraints.txt"
+
+- name: copy constraints.txt to remote host
+ copy:
+ src: "{{ role_path }}/../../../utils/constraints.txt"
+ dest: "{{ remote_constraints }}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/handlers/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/handlers/main.yml
new file mode 100644
index 00000000..229037c8
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/handlers/main.yml
@@ -0,0 +1,5 @@
+- name: delete temporary directory
+ include_tasks: default-cleanup.yml
+
+- name: delete temporary directory (windows)
+ include_tasks: windows-cleanup.yml
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/tasks/default-cleanup.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/tasks/default-cleanup.yml
new file mode 100644
index 00000000..39872d74
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/tasks/default-cleanup.yml
@@ -0,0 +1,5 @@
+- name: delete temporary directory
+ file:
+ path: "{{ remote_tmp_dir }}"
+ state: absent
+ no_log: yes
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/tasks/default.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/tasks/default.yml
new file mode 100644
index 00000000..1e0f51b8
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/tasks/default.yml
@@ -0,0 +1,11 @@
+- name: create temporary directory
+ tempfile:
+ state: directory
+ suffix: .test
+ register: remote_tmp_dir
+ notify:
+ - delete temporary directory
+
+- name: record temporary directory
+ set_fact:
+ remote_tmp_dir: "{{ remote_tmp_dir.path }}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/tasks/main.yml b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/tasks/main.yml
new file mode 100644
index 00000000..93d786f0
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/integration/targets/setup_remote_tmp_dir/tasks/main.yml
@@ -0,0 +1,15 @@
+####################################################################
+# WARNING: These are designed specifically for Ansible tests #
+# and should not be used as examples of how to write Ansible roles #
+####################################################################
+
+- name: make sure we have the ansible_os_family and ansible_distribution_version facts
+ setup:
+ gather_subset: distribution
+ when: ansible_facts == {}
+
+- include_tasks: "{{ lookup('first_found', files)}}"
+ vars:
+ files:
+ - "{{ ansible_os_family | lower }}.yml"
+ - "default.yml"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/requirements.yml b/collections-debian-merged/ansible_collections/community/docker/tests/requirements.yml
new file mode 100644
index 00000000..a242e324
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/requirements.yml
@@ -0,0 +1,7 @@
+integration_tests_dependencies:
+- ansible.posix
+- community.internal_test_tools
+- community.crypto
+- community.general
+unit_tests_dependencies:
+- community.internal_test_tools
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/sanity/extra/no-unwanted-files.json b/collections-debian-merged/ansible_collections/community/docker/tests/sanity/extra/no-unwanted-files.json
new file mode 100644
index 00000000..c789a7fd
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/sanity/extra/no-unwanted-files.json
@@ -0,0 +1,7 @@
+{
+ "include_symlinks": true,
+ "prefixes": [
+ "plugins/"
+ ],
+ "output": "path-message"
+}
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/sanity/extra/no-unwanted-files.py b/collections-debian-merged/ansible_collections/community/docker/tests/sanity/extra/no-unwanted-files.py
new file mode 100755
index 00000000..49806f2e
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/sanity/extra/no-unwanted-files.py
@@ -0,0 +1,43 @@
+#!/usr/bin/env python
+# Copyright (c) Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+"""Prevent unwanted files from being added to the source tree."""
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import os
+import sys
+
+
+def main():
+ """Main entry point."""
+ paths = sys.argv[1:] or sys.stdin.read().splitlines()
+
+ allowed_extensions = (
+ '.cs',
+ '.ps1',
+ '.psm1',
+ '.py',
+ )
+
+ skip_paths = set([
+ ])
+
+ skip_directories = (
+ )
+
+ for path in paths:
+ if path in skip_paths:
+ continue
+
+ if any(path.startswith(skip_directory) for skip_directory in skip_directories):
+ continue
+
+ ext = os.path.splitext(path)[1]
+
+ if ext not in allowed_extensions:
+ print('%s: extension must be one of: %s' % (path, ', '.join(allowed_extensions)))
+
+
+if __name__ == '__main__':
+ main()
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/sanity/ignore-2.10.txt b/collections-debian-merged/ansible_collections/community/docker/tests/sanity/ignore-2.10.txt
new file mode 100644
index 00000000..e678db7a
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/sanity/ignore-2.10.txt
@@ -0,0 +1,3 @@
+plugins/modules/docker_container.py use-argspec-type-path # uses colon-separated paths, can't use type=path
+tests/utils/shippable/check_matrix.py replace-urlopen
+tests/utils/shippable/timing.py shebang
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/sanity/ignore-2.11.txt b/collections-debian-merged/ansible_collections/community/docker/tests/sanity/ignore-2.11.txt
new file mode 100644
index 00000000..e678db7a
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/sanity/ignore-2.11.txt
@@ -0,0 +1,3 @@
+plugins/modules/docker_container.py use-argspec-type-path # uses colon-separated paths, can't use type=path
+tests/utils/shippable/check_matrix.py replace-urlopen
+tests/utils/shippable/timing.py shebang
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/sanity/ignore-2.9.txt b/collections-debian-merged/ansible_collections/community/docker/tests/sanity/ignore-2.9.txt
new file mode 100644
index 00000000..e678db7a
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/sanity/ignore-2.9.txt
@@ -0,0 +1,3 @@
+plugins/modules/docker_container.py use-argspec-type-path # uses colon-separated paths, can't use type=path
+tests/utils/shippable/check_matrix.py replace-urlopen
+tests/utils/shippable/timing.py shebang
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/__init__.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/__init__.py
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/builtins.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/builtins.py
new file mode 100644
index 00000000..f60ee678
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/builtins.py
@@ -0,0 +1,33 @@
+# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+# Make coding more python3-ish
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+#
+# Compat for python2.7
+#
+
+# One unittest needs to import builtins via __import__() so we need to have
+# the string that represents it
+try:
+ import __builtin__
+except ImportError:
+ BUILTINS = 'builtins'
+else:
+ BUILTINS = '__builtin__'
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/mock.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/mock.py
new file mode 100644
index 00000000..0972cd2e
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/mock.py
@@ -0,0 +1,122 @@
+# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+# Make coding more python3-ish
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+'''
+Compat module for Python3.x's unittest.mock module
+'''
+import sys
+
+# Python 2.7
+
+# Note: Could use the pypi mock library on python3.x as well as python2.x. It
+# is the same as the python3 stdlib mock library
+
+try:
+ # Allow wildcard import because we really do want to import all of mock's
+ # symbols into this compat shim
+ # pylint: disable=wildcard-import,unused-wildcard-import
+ from unittest.mock import *
+except ImportError:
+ # Python 2
+ # pylint: disable=wildcard-import,unused-wildcard-import
+ try:
+ from mock import *
+ except ImportError:
+ print('You need the mock library installed on python2.x to run tests')
+
+
+# Prior to 3.4.4, mock_open cannot handle binary read_data
+if sys.version_info >= (3,) and sys.version_info < (3, 4, 4):
+ file_spec = None
+
+ def _iterate_read_data(read_data):
+ # Helper for mock_open:
+ # Retrieve lines from read_data via a generator so that separate calls to
+ # readline, read, and readlines are properly interleaved
+ sep = b'\n' if isinstance(read_data, bytes) else '\n'
+ data_as_list = [l + sep for l in read_data.split(sep)]
+
+ if data_as_list[-1] == sep:
+ # If the last line ended in a newline, the list comprehension will have an
+ # extra entry that's just a newline. Remove this.
+ data_as_list = data_as_list[:-1]
+ else:
+ # If there wasn't an extra newline by itself, then the file being
+ # emulated doesn't have a newline to end the last line remove the
+ # newline that our naive format() added
+ data_as_list[-1] = data_as_list[-1][:-1]
+
+ for line in data_as_list:
+ yield line
+
+ def mock_open(mock=None, read_data=''):
+ """
+ A helper function to create a mock to replace the use of `open`. It works
+ for `open` called directly or used as a context manager.
+
+ The `mock` argument is the mock object to configure. If `None` (the
+ default) then a `MagicMock` will be created for you, with the API limited
+ to methods or attributes available on standard file handles.
+
+ `read_data` is a string for the `read` methoddline`, and `readlines` of the
+ file handle to return. This is an empty string by default.
+ """
+ def _readlines_side_effect(*args, **kwargs):
+ if handle.readlines.return_value is not None:
+ return handle.readlines.return_value
+ return list(_data)
+
+ def _read_side_effect(*args, **kwargs):
+ if handle.read.return_value is not None:
+ return handle.read.return_value
+ return type(read_data)().join(_data)
+
+ def _readline_side_effect():
+ if handle.readline.return_value is not None:
+ while True:
+ yield handle.readline.return_value
+ for line in _data:
+ yield line
+
+ global file_spec
+ if file_spec is None:
+ import _io
+ file_spec = list(set(dir(_io.TextIOWrapper)).union(set(dir(_io.BytesIO))))
+
+ if mock is None:
+ mock = MagicMock(name='open', spec=open)
+
+ handle = MagicMock(spec=file_spec)
+ handle.__enter__.return_value = handle
+
+ _data = _iterate_read_data(read_data)
+
+ handle.write.return_value = None
+ handle.read.return_value = None
+ handle.readline.return_value = None
+ handle.readlines.return_value = None
+
+ handle.read.side_effect = _read_side_effect
+ handle.readline.side_effect = _readline_side_effect()
+ handle.readlines.side_effect = _readlines_side_effect
+
+ mock.return_value = handle
+ return mock
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/unittest.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/unittest.py
new file mode 100644
index 00000000..98f08ad6
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/compat/unittest.py
@@ -0,0 +1,38 @@
+# (c) 2014, Toshio Kuratomi <tkuratomi@ansible.com>
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+# Make coding more python3-ish
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+'''
+Compat module for Python2.7's unittest module
+'''
+
+import sys
+
+# Allow wildcard import because we really do want to import all of
+# unittests's symbols into this compat shim
+# pylint: disable=wildcard-import,unused-wildcard-import
+if sys.version_info < (2, 7):
+ try:
+ # Need unittest2 on python2.6
+ from unittest2 import *
+ except ImportError:
+ print('You need unittest2 installed on python2.6.x to run tests')
+else:
+ from unittest import *
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/connection/test_docker.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/connection/test_docker.py
new file mode 100644
index 00000000..885f676c
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/connection/test_docker.py
@@ -0,0 +1,67 @@
+# (c) 2020 Red Hat, Inc.
+#
+# This file is part of Ansible
+#
+# Ansible is free software: you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Ansible is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Ansible. If not, see <http://www.gnu.org/licenses/>.
+
+# Make coding more python3-ish
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+from io import StringIO
+import pytest
+
+from ansible_collections.community.docker.tests.unit.compat import mock
+from ansible_collections.community.docker.tests.unit.compat import unittest
+from ansible.errors import AnsibleError
+from ansible.playbook.play_context import PlayContext
+from ansible_collections.community.docker.plugins.connection.docker import Connection as DockerConnection
+
+
+class TestDockerConnectionClass(unittest.TestCase):
+
+ def setUp(self):
+ self.play_context = PlayContext()
+ self.play_context.prompt = (
+ '[sudo via ansible, key=ouzmdnewuhucvuaabtjmweasarviygqq] password: '
+ )
+ self.in_stream = StringIO()
+
+ def tearDown(self):
+ pass
+
+ @mock.patch('ansible_collections.community.docker.plugins.connection.docker.Connection._old_docker_version',
+ return_value=('false', 'garbage', '', 1))
+ @mock.patch('ansible_collections.community.docker.plugins.connection.docker.Connection._new_docker_version',
+ return_value=('docker version', '1.2.3', '', 0))
+ def test_docker_connection_module_too_old(self, mock_new_docker_verison, mock_old_docker_version):
+ self.assertRaisesRegexp(AnsibleError, '^docker connection type requires docker 1.3 or higher$',
+ DockerConnection, self.play_context, self.in_stream, docker_command='/fake/docker')
+
+ @mock.patch('ansible_collections.community.docker.plugins.connection.docker.Connection._old_docker_version',
+ return_value=('false', 'garbage', '', 1))
+ @mock.patch('ansible_collections.community.docker.plugins.connection.docker.Connection._new_docker_version',
+ return_value=('docker version', '1.3.4', '', 0))
+ def test_docker_connection_module(self, mock_new_docker_verison, mock_old_docker_version):
+ self.assertIsInstance(DockerConnection(self.play_context, self.in_stream, docker_command='/fake/docker'),
+ DockerConnection)
+
+ # old version and new version fail
+ @mock.patch('ansible_collections.community.docker.plugins.connection.docker.Connection._old_docker_version',
+ return_value=('false', 'garbage', '', 1))
+ @mock.patch('ansible_collections.community.docker.plugins.connection.docker.Connection._new_docker_version',
+ return_value=('false', 'garbage', '', 1))
+ def test_docker_connection_module_wrong_cmd(self, mock_new_docker_version, mock_old_docker_version):
+ self.assertRaisesRegexp(AnsibleError, '^Docker version check (.*?) failed: ',
+ DockerConnection, self.play_context, self.in_stream, docker_command='/fake/docker')
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/inventory/test_docker_containers.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/inventory/test_docker_containers.py
new file mode 100644
index 00000000..b729d9bd
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/inventory/test_docker_containers.py
@@ -0,0 +1,228 @@
+# Copyright (c), Felix Fontein <felix@fontein.de>, 2020
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+
+import json
+import textwrap
+
+import pytest
+
+from mock import MagicMock
+
+from ansible import constants as C
+from ansible.errors import AnsibleError
+from ansible.inventory.data import InventoryData
+from ansible.inventory.manager import InventoryManager
+
+from ansible_collections.community.docker.plugins.inventory.docker_containers import InventoryModule
+
+
+@pytest.fixture(scope="module")
+def inventory():
+ r = InventoryModule()
+ r.inventory = InventoryData()
+ return r
+
+
+LOVING_THARP = {
+ 'Id': '7bd547963679e3209cafd52aff21840b755c96fd37abcd7a6e19da8da6a7f49a',
+ 'Name': '/loving_tharp',
+ 'Image': 'sha256:349f492ff18add678364a62a67ce9a13487f14293ae0af1baf02398aa432f385',
+ 'State': {
+ 'Running': True,
+ },
+ 'Config': {
+ 'Image': 'quay.io/ansible/ubuntu1804-test-container:1.21.0',
+ },
+}
+
+
+LOVING_THARP_STACK = {
+ 'Id': '7bd547963679e3209cafd52aff21840b755c96fd37abcd7a6e19da8da6a7f49a',
+ 'Name': '/loving_tharp',
+ 'Image': 'sha256:349f492ff18add678364a62a67ce9a13487f14293ae0af1baf02398aa432f385',
+ 'State': {
+ 'Running': True,
+ },
+ 'Config': {
+ 'Image': 'quay.io/ansible/ubuntu1804-test-container:1.21.0',
+ 'Labels': {
+ 'com.docker.stack.namespace': 'my_stack',
+ },
+ },
+ 'NetworkSettings': {
+ 'Ports': {
+ '22/tcp': [
+ {
+ 'HostIp': '0.0.0.0',
+ 'HostPort': '32802'
+ }
+ ],
+ },
+ },
+}
+
+
+LOVING_THARP_SERVICE = {
+ 'Id': '7bd547963679e3209cafd52aff21840b755c96fd37abcd7a6e19da8da6a7f49a',
+ 'Name': '/loving_tharp',
+ 'Image': 'sha256:349f492ff18add678364a62a67ce9a13487f14293ae0af1baf02398aa432f385',
+ 'State': {
+ 'Running': True,
+ },
+ 'Config': {
+ 'Image': 'quay.io/ansible/ubuntu1804-test-container:1.21.0',
+ 'Labels': {
+ 'com.docker.swarm.service.name': 'my_service',
+ },
+ },
+}
+
+
+def create_get_option(options, default=False):
+ def get_option(option):
+ if option in options:
+ return options[option]
+ return default
+
+ return get_option
+
+
+class FakeClient(object):
+ def __init__(self, *hosts):
+ self.hosts = dict()
+ self.list_reply = []
+ for host in hosts:
+ self.list_reply.append({
+ 'Id': host['Id'],
+ 'Names': [host['Name']] if host['Name'] else [],
+ 'Image': host['Config']['Image'],
+ 'ImageId': host['Image'],
+ })
+ self.hosts[host['Name']] = host
+ self.hosts[host['Id']] = host
+
+ def containers(self, all=False):
+ return list(self.list_reply)
+
+ def inspect_container(self, id):
+ return self.hosts[id]
+
+ def port(self, container, port):
+ host = self.hosts[container['Id']]
+ network_settings = host.get('NetworkSettings') or dict()
+ ports = network_settings.get('Ports') or dict()
+ return ports.get('{0}/tcp'.format(port)) or []
+
+
+def test_populate(inventory, mocker):
+ client = FakeClient(LOVING_THARP)
+
+ inventory.get_option = mocker.MagicMock(side_effect=create_get_option({
+ 'verbose_output': True,
+ 'connection_type': 'docker-api',
+ 'add_legacy_groups': False,
+ 'compose': {},
+ 'groups': {},
+ 'keyed_groups': {},
+ }))
+ inventory._populate(client)
+
+ host_1 = inventory.inventory.get_host('loving_tharp')
+ host_1_vars = host_1.get_vars()
+
+ assert host_1_vars['ansible_host'] == 'loving_tharp'
+ assert host_1_vars['ansible_connection'] == 'community.docker.docker_api'
+ assert 'ansible_ssh_host' not in host_1_vars
+ assert 'ansible_ssh_port' not in host_1_vars
+ assert 'docker_state' in host_1_vars
+ assert 'docker_config' in host_1_vars
+ assert 'docker_image' in host_1_vars
+
+ assert len(inventory.inventory.groups['ungrouped'].hosts) == 0
+ assert len(inventory.inventory.groups['all'].hosts) == 0
+ assert len(inventory.inventory.groups) == 2
+ assert len(inventory.inventory.hosts) == 1
+
+
+def test_populate_service(inventory, mocker):
+ client = FakeClient(LOVING_THARP_SERVICE)
+
+ inventory.get_option = mocker.MagicMock(side_effect=create_get_option({
+ 'verbose_output': False,
+ 'connection_type': 'docker-cli',
+ 'add_legacy_groups': True,
+ 'compose': {},
+ 'groups': {},
+ 'keyed_groups': {},
+ 'docker_host': 'unix://var/run/docker.sock',
+ }))
+ inventory._populate(client)
+
+ host_1 = inventory.inventory.get_host('loving_tharp')
+ host_1_vars = host_1.get_vars()
+
+ assert host_1_vars['ansible_host'] == 'loving_tharp'
+ assert host_1_vars['ansible_connection'] == 'community.docker.docker'
+ assert 'ansible_ssh_host' not in host_1_vars
+ assert 'ansible_ssh_port' not in host_1_vars
+ assert 'docker_state' not in host_1_vars
+ assert 'docker_config' not in host_1_vars
+ assert 'docker_image' not in host_1_vars
+
+ assert len(inventory.inventory.groups['ungrouped'].hosts) == 0
+ assert len(inventory.inventory.groups['all'].hosts) == 0
+ assert len(inventory.inventory.groups['7bd547963679e'].hosts) == 1
+ assert len(inventory.inventory.groups['7bd547963679e3209cafd52aff21840b755c96fd37abcd7a6e19da8da6a7f49a'].hosts) == 1
+ assert len(inventory.inventory.groups['image_quay.io/ansible/ubuntu1804-test-container:1.21.0'].hosts) == 1
+ assert len(inventory.inventory.groups['loving_tharp'].hosts) == 1
+ assert len(inventory.inventory.groups['running'].hosts) == 1
+ assert len(inventory.inventory.groups['stopped'].hosts) == 0
+ assert len(inventory.inventory.groups['service_my_service'].hosts) == 1
+ assert len(inventory.inventory.groups['unix://var/run/docker.sock'].hosts) == 1
+ assert len(inventory.inventory.groups) == 10
+ assert len(inventory.inventory.hosts) == 1
+
+
+def test_populate_stack(inventory, mocker):
+ client = FakeClient(LOVING_THARP_STACK)
+
+ inventory.get_option = mocker.MagicMock(side_effect=create_get_option({
+ 'verbose_output': False,
+ 'connection_type': 'ssh',
+ 'add_legacy_groups': True,
+ 'compose': {},
+ 'groups': {},
+ 'keyed_groups': {},
+ 'docker_host': 'unix://var/run/docker.sock',
+ 'default_ip': '127.0.0.1',
+ 'private_ssh_port': 22,
+ }))
+ inventory._populate(client)
+
+ host_1 = inventory.inventory.get_host('loving_tharp')
+ host_1_vars = host_1.get_vars()
+
+ assert host_1_vars['ansible_ssh_host'] == '127.0.0.1'
+ assert host_1_vars['ansible_ssh_port'] == '32802'
+ assert 'ansible_host' not in host_1_vars
+ assert 'ansible_connection' not in host_1_vars
+ assert 'docker_state' not in host_1_vars
+ assert 'docker_config' not in host_1_vars
+ assert 'docker_image' not in host_1_vars
+
+ assert len(inventory.inventory.groups['ungrouped'].hosts) == 0
+ assert len(inventory.inventory.groups['all'].hosts) == 0
+ assert len(inventory.inventory.groups['7bd547963679e'].hosts) == 1
+ assert len(inventory.inventory.groups['7bd547963679e3209cafd52aff21840b755c96fd37abcd7a6e19da8da6a7f49a'].hosts) == 1
+ assert len(inventory.inventory.groups['image_quay.io/ansible/ubuntu1804-test-container:1.21.0'].hosts) == 1
+ assert len(inventory.inventory.groups['loving_tharp'].hosts) == 1
+ assert len(inventory.inventory.groups['running'].hosts) == 1
+ assert len(inventory.inventory.groups['stopped'].hosts) == 0
+ assert len(inventory.inventory.groups['stack_my_stack'].hosts) == 1
+ assert len(inventory.inventory.groups['unix://var/run/docker.sock'].hosts) == 1
+ assert len(inventory.inventory.groups) == 10
+ assert len(inventory.inventory.hosts) == 1
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/module_utils/__init__.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/module_utils/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/module_utils/__init__.py
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/module_utils/test_common.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/module_utils/test_common.py
new file mode 100644
index 00000000..b9f747db
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/module_utils/test_common.py
@@ -0,0 +1,518 @@
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import pytest
+
+from ansible_collections.community.docker.plugins.module_utils.common import (
+ compare_dict_allow_more_present,
+ compare_generic,
+ convert_duration_to_nanosecond,
+ parse_healthcheck
+)
+
+DICT_ALLOW_MORE_PRESENT = (
+ {
+ 'av': {},
+ 'bv': {'a': 1},
+ 'result': True
+ },
+ {
+ 'av': {'a': 1},
+ 'bv': {'a': 1, 'b': 2},
+ 'result': True
+ },
+ {
+ 'av': {'a': 1},
+ 'bv': {'b': 2},
+ 'result': False
+ },
+ {
+ 'av': {'a': 1},
+ 'bv': {'a': None, 'b': 1},
+ 'result': False
+ },
+ {
+ 'av': {'a': None},
+ 'bv': {'b': 1},
+ 'result': False
+ },
+)
+
+COMPARE_GENERIC = [
+ ########################################################################################
+ # value
+ {
+ 'a': 1,
+ 'b': 2,
+ 'method': 'strict',
+ 'type': 'value',
+ 'result': False
+ },
+ {
+ 'a': 'hello',
+ 'b': 'hello',
+ 'method': 'strict',
+ 'type': 'value',
+ 'result': True
+ },
+ {
+ 'a': None,
+ 'b': 'hello',
+ 'method': 'strict',
+ 'type': 'value',
+ 'result': False
+ },
+ {
+ 'a': None,
+ 'b': None,
+ 'method': 'strict',
+ 'type': 'value',
+ 'result': True
+ },
+ {
+ 'a': 1,
+ 'b': 2,
+ 'method': 'ignore',
+ 'type': 'value',
+ 'result': True
+ },
+ {
+ 'a': None,
+ 'b': 2,
+ 'method': 'ignore',
+ 'type': 'value',
+ 'result': True
+ },
+ ########################################################################################
+ # list
+ {
+ 'a': [
+ 'x',
+ ],
+ 'b': [
+ 'y',
+ ],
+ 'method': 'strict',
+ 'type': 'list',
+ 'result': False
+ },
+ {
+ 'a': [
+ 'x',
+ ],
+ 'b': [
+ 'x',
+ 'x',
+ ],
+ 'method': 'strict',
+ 'type': 'list',
+ 'result': False
+ },
+ {
+ 'a': [
+ 'x',
+ 'y',
+ ],
+ 'b': [
+ 'x',
+ 'y',
+ ],
+ 'method': 'strict',
+ 'type': 'list',
+ 'result': True
+ },
+ {
+ 'a': [
+ 'x',
+ 'y',
+ ],
+ 'b': [
+ 'y',
+ 'x',
+ ],
+ 'method': 'strict',
+ 'type': 'list',
+ 'result': False
+ },
+ {
+ 'a': [
+ 'x',
+ 'y',
+ ],
+ 'b': [
+ 'x',
+ ],
+ 'method': 'allow_more_present',
+ 'type': 'list',
+ 'result': False
+ },
+ {
+ 'a': [
+ 'x',
+ ],
+ 'b': [
+ 'x',
+ 'y',
+ ],
+ 'method': 'allow_more_present',
+ 'type': 'list',
+ 'result': True
+ },
+ {
+ 'a': [
+ 'x',
+ 'x',
+ 'y',
+ ],
+ 'b': [
+ 'x',
+ 'y',
+ ],
+ 'method': 'allow_more_present',
+ 'type': 'list',
+ 'result': False
+ },
+ {
+ 'a': [
+ 'x',
+ 'z',
+ ],
+ 'b': [
+ 'x',
+ 'y',
+ 'x',
+ 'z',
+ ],
+ 'method': 'allow_more_present',
+ 'type': 'list',
+ 'result': True
+ },
+ {
+ 'a': [
+ 'x',
+ 'y',
+ ],
+ 'b': [
+ 'y',
+ 'x',
+ ],
+ 'method': 'ignore',
+ 'type': 'list',
+ 'result': True
+ },
+ ########################################################################################
+ # set
+ {
+ 'a': [
+ 'x',
+ ],
+ 'b': [
+ 'y',
+ ],
+ 'method': 'strict',
+ 'type': 'set',
+ 'result': False
+ },
+ {
+ 'a': [
+ 'x',
+ ],
+ 'b': [
+ 'x',
+ 'x',
+ ],
+ 'method': 'strict',
+ 'type': 'set',
+ 'result': True
+ },
+ {
+ 'a': [
+ 'x',
+ 'y',
+ ],
+ 'b': [
+ 'x',
+ 'y',
+ ],
+ 'method': 'strict',
+ 'type': 'set',
+ 'result': True
+ },
+ {
+ 'a': [
+ 'x',
+ 'y',
+ ],
+ 'b': [
+ 'y',
+ 'x',
+ ],
+ 'method': 'strict',
+ 'type': 'set',
+ 'result': True
+ },
+ {
+ 'a': [
+ 'x',
+ 'y',
+ ],
+ 'b': [
+ 'x',
+ ],
+ 'method': 'allow_more_present',
+ 'type': 'set',
+ 'result': False
+ },
+ {
+ 'a': [
+ 'x',
+ ],
+ 'b': [
+ 'x',
+ 'y',
+ ],
+ 'method': 'allow_more_present',
+ 'type': 'set',
+ 'result': True
+ },
+ {
+ 'a': [
+ 'x',
+ 'x',
+ 'y',
+ ],
+ 'b': [
+ 'x',
+ 'y',
+ ],
+ 'method': 'allow_more_present',
+ 'type': 'set',
+ 'result': True
+ },
+ {
+ 'a': [
+ 'x',
+ 'z',
+ ],
+ 'b': [
+ 'x',
+ 'y',
+ 'x',
+ 'z',
+ ],
+ 'method': 'allow_more_present',
+ 'type': 'set',
+ 'result': True
+ },
+ {
+ 'a': [
+ 'x',
+ 'a',
+ ],
+ 'b': [
+ 'y',
+ 'z',
+ ],
+ 'method': 'ignore',
+ 'type': 'set',
+ 'result': True
+ },
+ ########################################################################################
+ # set(dict)
+ {
+ 'a': [
+ {'x': 1},
+ ],
+ 'b': [
+ {'y': 1},
+ ],
+ 'method': 'strict',
+ 'type': 'set(dict)',
+ 'result': False
+ },
+ {
+ 'a': [
+ {'x': 1},
+ ],
+ 'b': [
+ {'x': 1},
+ ],
+ 'method': 'strict',
+ 'type': 'set(dict)',
+ 'result': True
+ },
+ {
+ 'a': [
+ {'x': 1},
+ ],
+ 'b': [
+ {'x': 1, 'y': 2},
+ ],
+ 'method': 'strict',
+ 'type': 'set(dict)',
+ 'result': True
+ },
+ {
+ 'a': [
+ {'x': 1},
+ {'x': 2, 'y': 3},
+ ],
+ 'b': [
+ {'x': 1},
+ {'x': 2, 'y': 3},
+ ],
+ 'method': 'strict',
+ 'type': 'set(dict)',
+ 'result': True
+ },
+ {
+ 'a': [
+ {'x': 1},
+ ],
+ 'b': [
+ {'x': 1, 'z': 2},
+ {'x': 2, 'y': 3},
+ ],
+ 'method': 'allow_more_present',
+ 'type': 'set(dict)',
+ 'result': True
+ },
+ {
+ 'a': [
+ {'x': 1, 'y': 2},
+ ],
+ 'b': [
+ {'x': 1},
+ {'x': 2, 'y': 3},
+ ],
+ 'method': 'allow_more_present',
+ 'type': 'set(dict)',
+ 'result': False
+ },
+ {
+ 'a': [
+ {'x': 1, 'y': 3},
+ ],
+ 'b': [
+ {'x': 1},
+ {'x': 1, 'y': 3, 'z': 4},
+ ],
+ 'method': 'allow_more_present',
+ 'type': 'set(dict)',
+ 'result': True
+ },
+ {
+ 'a': [
+ {'x': 1},
+ {'x': 2, 'y': 3},
+ ],
+ 'b': [
+ {'x': 1},
+ ],
+ 'method': 'ignore',
+ 'type': 'set(dict)',
+ 'result': True
+ },
+ ########################################################################################
+ # dict
+ {
+ 'a': {'x': 1},
+ 'b': {'y': 1},
+ 'method': 'strict',
+ 'type': 'dict',
+ 'result': False
+ },
+ {
+ 'a': {'x': 1},
+ 'b': {'x': 1, 'y': 2},
+ 'method': 'strict',
+ 'type': 'dict',
+ 'result': False
+ },
+ {
+ 'a': {'x': 1},
+ 'b': {'x': 1},
+ 'method': 'strict',
+ 'type': 'dict',
+ 'result': True
+ },
+ {
+ 'a': {'x': 1, 'z': 2},
+ 'b': {'x': 1, 'y': 2},
+ 'method': 'strict',
+ 'type': 'dict',
+ 'result': False
+ },
+ {
+ 'a': {'x': 1, 'z': 2},
+ 'b': {'x': 1, 'y': 2},
+ 'method': 'ignore',
+ 'type': 'dict',
+ 'result': True
+ },
+] + [{
+ 'a': entry['av'],
+ 'b': entry['bv'],
+ 'method': 'allow_more_present',
+ 'type': 'dict',
+ 'result': entry['result']
+} for entry in DICT_ALLOW_MORE_PRESENT]
+
+
+@pytest.mark.parametrize("entry", DICT_ALLOW_MORE_PRESENT)
+def test_dict_allow_more_present(entry):
+ assert compare_dict_allow_more_present(entry['av'], entry['bv']) == entry['result']
+
+
+@pytest.mark.parametrize("entry", COMPARE_GENERIC)
+def test_compare_generic(entry):
+ assert compare_generic(entry['a'], entry['b'], entry['method'], entry['type']) == entry['result']
+
+
+def test_convert_duration_to_nanosecond():
+ nanoseconds = convert_duration_to_nanosecond('5s')
+ assert nanoseconds == 5000000000
+ nanoseconds = convert_duration_to_nanosecond('1m5s')
+ assert nanoseconds == 65000000000
+ with pytest.raises(ValueError):
+ convert_duration_to_nanosecond([1, 2, 3])
+ with pytest.raises(ValueError):
+ convert_duration_to_nanosecond('10x')
+
+
+def test_parse_healthcheck():
+ result, disabled = parse_healthcheck({
+ 'test': 'sleep 1',
+ 'interval': '1s',
+ })
+ assert disabled is False
+ assert result == {
+ 'test': ['CMD-SHELL', 'sleep 1'],
+ 'interval': 1000000000
+ }
+
+ result, disabled = parse_healthcheck({
+ 'test': ['NONE'],
+ })
+ assert result is None
+ assert disabled
+
+ result, disabled = parse_healthcheck({
+ 'test': 'sleep 1',
+ 'interval': '1s423ms'
+ })
+ assert result == {
+ 'test': ['CMD-SHELL', 'sleep 1'],
+ 'interval': 1423000000
+ }
+ assert disabled is False
+
+ result, disabled = parse_healthcheck({
+ 'test': 'sleep 1',
+ 'interval': '1h1m2s3ms4us'
+ })
+ assert result == {
+ 'test': ['CMD-SHELL', 'sleep 1'],
+ 'interval': 3662003004000
+ }
+ assert disabled is False
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/__init__.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/__init__.py
new file mode 100644
index 00000000..e69de29b
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/__init__.py
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/conftest.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/conftest.py
new file mode 100644
index 00000000..a7d1e047
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/conftest.py
@@ -0,0 +1,31 @@
+# Copyright (c) 2017 Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import json
+
+import pytest
+
+from ansible.module_utils.six import string_types
+from ansible.module_utils._text import to_bytes
+from ansible.module_utils.common._collections_compat import MutableMapping
+
+
+@pytest.fixture
+def patch_ansible_module(request, mocker):
+ if isinstance(request.param, string_types):
+ args = request.param
+ elif isinstance(request.param, MutableMapping):
+ if 'ANSIBLE_MODULE_ARGS' not in request.param:
+ request.param = {'ANSIBLE_MODULE_ARGS': request.param}
+ if '_ansible_remote_tmp' not in request.param['ANSIBLE_MODULE_ARGS']:
+ request.param['ANSIBLE_MODULE_ARGS']['_ansible_remote_tmp'] = '/tmp'
+ if '_ansible_keep_remote_files' not in request.param['ANSIBLE_MODULE_ARGS']:
+ request.param['ANSIBLE_MODULE_ARGS']['_ansible_keep_remote_files'] = False
+ args = json.dumps(request.param)
+ else:
+ raise Exception('Malformed data to the patch_ansible_module pytest fixture')
+
+ mocker.patch('ansible.module_utils.basic._ANSIBLE_ARGS', to_bytes(args))
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_container.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_container.py
new file mode 100644
index 00000000..00701961
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_container.py
@@ -0,0 +1,22 @@
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import unittest
+
+from ansible_collections.community.docker.plugins.modules.docker_container import TaskParameters
+
+
+class TestTaskParameters(unittest.TestCase):
+ """Unit tests for TaskParameters."""
+
+ def test_parse_exposed_ports_tcp_udp(self):
+ """
+ Ensure _parse_exposed_ports does not cancel ports with the same
+ number but different protocol.
+ """
+ task_params = TaskParameters.__new__(TaskParameters)
+ task_params.exposed_ports = None
+ result = task_params._parse_exposed_ports([80, '443', '443/udp'])
+ self.assertTrue((80, 'tcp') in result)
+ self.assertTrue((443, 'tcp') in result)
+ self.assertTrue((443, 'udp') in result)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_network.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_network.py
new file mode 100644
index 00000000..4b36a52c
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_network.py
@@ -0,0 +1,31 @@
+"""Unit tests for docker_network."""
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import pytest
+
+from ansible_collections.community.docker.plugins.modules.docker_network import validate_cidr
+
+
+@pytest.mark.parametrize("cidr,expected", [
+ ('192.168.0.1/16', 'ipv4'),
+ ('192.168.0.1/24', 'ipv4'),
+ ('192.168.0.1/32', 'ipv4'),
+ ('fdd1:ac8c:0557:7ce2::/64', 'ipv6'),
+ ('fdd1:ac8c:0557:7ce2::/128', 'ipv6'),
+])
+def test_validate_cidr_positives(cidr, expected):
+ assert validate_cidr(cidr) == expected
+
+
+@pytest.mark.parametrize("cidr", [
+ '192.168.0.1',
+ '192.168.0.1/34',
+ '192.168.0.1/asd',
+ 'fdd1:ac8c:0557:7ce2::',
+])
+def test_validate_cidr_negatives(cidr):
+ with pytest.raises(ValueError) as e:
+ validate_cidr(cidr)
+ assert '"{0}" is not a valid CIDR'.format(cidr) == str(e.value)
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_swarm_service.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_swarm_service.py
new file mode 100644
index 00000000..1fae8daf
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_swarm_service.py
@@ -0,0 +1,510 @@
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import pytest
+
+
+class APIErrorMock(Exception):
+ def __init__(self, message, response=None, explanation=None):
+ self.message = message
+ self.response = response
+ self.explanation = explanation
+
+
+@pytest.fixture(autouse=True)
+def docker_module_mock(mocker):
+ docker_module_mock = mocker.MagicMock()
+ docker_utils_module_mock = mocker.MagicMock()
+ docker_errors_module_mock = mocker.MagicMock()
+ docker_errors_module_mock.APIError = APIErrorMock
+ mock_modules = {
+ 'docker': docker_module_mock,
+ 'docker.utils': docker_utils_module_mock,
+ 'docker.errors': docker_errors_module_mock,
+ }
+ return mocker.patch.dict('sys.modules', **mock_modules)
+
+
+@pytest.fixture(autouse=True)
+def docker_swarm_service():
+ from ansible_collections.community.docker.plugins.modules import docker_swarm_service
+
+ return docker_swarm_service
+
+
+def test_retry_on_out_of_sequence_error(mocker, docker_swarm_service):
+ run_mock = mocker.MagicMock(
+ side_effect=APIErrorMock(
+ message='',
+ response=None,
+ explanation='rpc error: code = Unknown desc = update out of sequence',
+ )
+ )
+ manager = docker_swarm_service.DockerServiceManager(client=None)
+ manager.run = run_mock
+ with pytest.raises(APIErrorMock):
+ manager.run_safe()
+ assert run_mock.call_count == 3
+
+
+def test_no_retry_on_general_api_error(mocker, docker_swarm_service):
+ run_mock = mocker.MagicMock(
+ side_effect=APIErrorMock(message='', response=None, explanation='some error')
+ )
+ manager = docker_swarm_service.DockerServiceManager(client=None)
+ manager.run = run_mock
+ with pytest.raises(APIErrorMock):
+ manager.run_safe()
+ assert run_mock.call_count == 1
+
+
+def test_get_docker_environment(mocker, docker_swarm_service):
+ env_file_result = {'TEST1': 'A', 'TEST2': 'B', 'TEST3': 'C'}
+ env_dict = {'TEST3': 'CC', 'TEST4': 'D'}
+ env_string = "TEST3=CC,TEST4=D"
+
+ env_list = ['TEST3=CC', 'TEST4=D']
+ expected_result = sorted(['TEST1=A', 'TEST2=B', 'TEST3=CC', 'TEST4=D'])
+ mocker.patch.object(
+ docker_swarm_service, 'parse_env_file', return_value=env_file_result
+ )
+ mocker.patch.object(
+ docker_swarm_service,
+ 'format_environment',
+ side_effect=lambda d: ['{0}={1}'.format(key, value) for key, value in d.items()],
+ )
+ # Test with env dict and file
+ result = docker_swarm_service.get_docker_environment(
+ env_dict, env_files=['dummypath']
+ )
+ assert result == expected_result
+ # Test with env list and file
+ result = docker_swarm_service.get_docker_environment(
+ env_list,
+ env_files=['dummypath']
+ )
+ assert result == expected_result
+ # Test with env string and file
+ result = docker_swarm_service.get_docker_environment(
+ env_string, env_files=['dummypath']
+ )
+ assert result == expected_result
+
+ assert result == expected_result
+ # Test with empty env
+ result = docker_swarm_service.get_docker_environment(
+ [], env_files=None
+ )
+ assert result == []
+ # Test with empty env_files
+ result = docker_swarm_service.get_docker_environment(
+ None, env_files=[]
+ )
+ assert result == []
+
+
+def test_get_nanoseconds_from_raw_option(docker_swarm_service):
+ value = docker_swarm_service.get_nanoseconds_from_raw_option('test', None)
+ assert value is None
+
+ value = docker_swarm_service.get_nanoseconds_from_raw_option('test', '1m30s535ms')
+ assert value == 90535000000
+
+ value = docker_swarm_service.get_nanoseconds_from_raw_option('test', 10000000000)
+ assert value == 10000000000
+
+ with pytest.raises(ValueError):
+ docker_swarm_service.get_nanoseconds_from_raw_option('test', [])
+
+
+def test_has_dict_changed(docker_swarm_service):
+ assert not docker_swarm_service.has_dict_changed(
+ {"a": 1},
+ {"a": 1},
+ )
+ assert not docker_swarm_service.has_dict_changed(
+ {"a": 1},
+ {"a": 1, "b": 2}
+ )
+ assert docker_swarm_service.has_dict_changed(
+ {"a": 1},
+ {"a": 2, "b": 2}
+ )
+ assert docker_swarm_service.has_dict_changed(
+ {"a": 1, "b": 1},
+ {"a": 1}
+ )
+ assert not docker_swarm_service.has_dict_changed(
+ None,
+ {"a": 2, "b": 2}
+ )
+ assert docker_swarm_service.has_dict_changed(
+ {},
+ {"a": 2, "b": 2}
+ )
+ assert docker_swarm_service.has_dict_changed(
+ {"a": 1},
+ {}
+ )
+ assert docker_swarm_service.has_dict_changed(
+ {"a": 1},
+ None
+ )
+ assert not docker_swarm_service.has_dict_changed(
+ {},
+ {}
+ )
+ assert not docker_swarm_service.has_dict_changed(
+ None,
+ None
+ )
+ assert not docker_swarm_service.has_dict_changed(
+ {},
+ None
+ )
+ assert not docker_swarm_service.has_dict_changed(
+ None,
+ {}
+ )
+
+
+def test_has_list_changed(docker_swarm_service):
+
+ # List comparisons without dictionaries
+ # I could improve the indenting, but pycodestyle wants this instead
+ assert not docker_swarm_service.has_list_changed(None, None)
+ assert not docker_swarm_service.has_list_changed(None, [])
+ assert not docker_swarm_service.has_list_changed(None, [1, 2])
+
+ assert not docker_swarm_service.has_list_changed([], None)
+ assert not docker_swarm_service.has_list_changed([], [])
+ assert docker_swarm_service.has_list_changed([], [1, 2])
+
+ assert docker_swarm_service.has_list_changed([1, 2], None)
+ assert docker_swarm_service.has_list_changed([1, 2], [])
+
+ assert docker_swarm_service.has_list_changed([1, 2, 3], [1, 2])
+ assert docker_swarm_service.has_list_changed([1, 2], [1, 2, 3])
+
+ # Check list sorting
+ assert not docker_swarm_service.has_list_changed([1, 2], [2, 1])
+ assert docker_swarm_service.has_list_changed(
+ [1, 2],
+ [2, 1],
+ sort_lists=False
+ )
+
+ # Check type matching
+ assert docker_swarm_service.has_list_changed([None, 1], [2, 1])
+ assert docker_swarm_service.has_list_changed([2, 1], [None, 1])
+ assert docker_swarm_service.has_list_changed(
+ "command --with args",
+ ['command', '--with', 'args']
+ )
+ assert docker_swarm_service.has_list_changed(
+ ['sleep', '3400'],
+ [u'sleep', u'3600'],
+ sort_lists=False
+ )
+
+ # List comparisons with dictionaries
+ assert not docker_swarm_service.has_list_changed(
+ [{'a': 1}],
+ [{'a': 1}],
+ sort_key='a'
+ )
+
+ assert not docker_swarm_service.has_list_changed(
+ [{'a': 1}, {'a': 2}],
+ [{'a': 1}, {'a': 2}],
+ sort_key='a'
+ )
+
+ with pytest.raises(Exception):
+ docker_swarm_service.has_list_changed(
+ [{'a': 1}, {'a': 2}],
+ [{'a': 1}, {'a': 2}]
+ )
+
+ # List sort checking with sort key
+ assert not docker_swarm_service.has_list_changed(
+ [{'a': 1}, {'a': 2}],
+ [{'a': 2}, {'a': 1}],
+ sort_key='a'
+ )
+ assert docker_swarm_service.has_list_changed(
+ [{'a': 1}, {'a': 2}],
+ [{'a': 2}, {'a': 1}],
+ sort_lists=False
+ )
+
+ assert docker_swarm_service.has_list_changed(
+ [{'a': 1}, {'a': 2}, {'a': 3}],
+ [{'a': 2}, {'a': 1}],
+ sort_key='a'
+ )
+ assert docker_swarm_service.has_list_changed(
+ [{'a': 1}, {'a': 2}],
+ [{'a': 1}, {'a': 2}, {'a': 3}],
+ sort_lists=False
+ )
+
+ # Additional dictionary elements
+ assert not docker_swarm_service.has_list_changed(
+ [
+ {"src": 1, "dst": 2},
+ {"src": 1, "dst": 2, "protocol": "udp"},
+ ],
+ [
+ {"src": 1, "dst": 2, "protocol": "tcp"},
+ {"src": 1, "dst": 2, "protocol": "udp"},
+ ],
+ sort_key='dst'
+ )
+ assert not docker_swarm_service.has_list_changed(
+ [
+ {"src": 1, "dst": 2, "protocol": "udp"},
+ {"src": 1, "dst": 3, "protocol": "tcp"},
+ ],
+ [
+ {"src": 1, "dst": 2, "protocol": "udp"},
+ {"src": 1, "dst": 3, "protocol": "tcp"},
+ ],
+ sort_key='dst'
+ )
+ assert docker_swarm_service.has_list_changed(
+ [
+ {"src": 1, "dst": 2, "protocol": "udp"},
+ {"src": 1, "dst": 2},
+ {"src": 3, "dst": 4},
+ ],
+ [
+ {"src": 1, "dst": 3, "protocol": "udp"},
+ {"src": 1, "dst": 2, "protocol": "tcp"},
+ {"src": 3, "dst": 4, "protocol": "tcp"},
+ ],
+ sort_key='dst'
+ )
+ assert docker_swarm_service.has_list_changed(
+ [
+ {"src": 1, "dst": 3, "protocol": "tcp"},
+ {"src": 1, "dst": 2, "protocol": "udp"},
+ ],
+ [
+ {"src": 1, "dst": 2, "protocol": "tcp"},
+ {"src": 1, "dst": 2, "protocol": "udp"},
+ ],
+ sort_key='dst'
+ )
+ assert docker_swarm_service.has_list_changed(
+ [
+ {"src": 1, "dst": 2, "protocol": "udp"},
+ {"src": 1, "dst": 2, "protocol": "tcp", "extra": {"test": "foo"}},
+ ],
+ [
+ {"src": 1, "dst": 2, "protocol": "udp"},
+ {"src": 1, "dst": 2, "protocol": "tcp"},
+ ],
+ sort_key='dst'
+ )
+ assert not docker_swarm_service.has_list_changed(
+ [{'id': '123', 'aliases': []}],
+ [{'id': '123'}],
+ sort_key='id'
+ )
+
+
+def test_have_networks_changed(docker_swarm_service):
+ assert not docker_swarm_service.have_networks_changed(
+ None,
+ None
+ )
+
+ assert not docker_swarm_service.have_networks_changed(
+ [],
+ None
+ )
+
+ assert not docker_swarm_service.have_networks_changed(
+ [{'id': 1}],
+ [{'id': 1}]
+ )
+
+ assert docker_swarm_service.have_networks_changed(
+ [{'id': 1}],
+ [{'id': 1}, {'id': 2}]
+ )
+
+ assert not docker_swarm_service.have_networks_changed(
+ [{'id': 1}, {'id': 2}],
+ [{'id': 1}, {'id': 2}]
+ )
+
+ assert not docker_swarm_service.have_networks_changed(
+ [{'id': 1}, {'id': 2}],
+ [{'id': 2}, {'id': 1}]
+ )
+
+ assert not docker_swarm_service.have_networks_changed(
+ [
+ {'id': 1},
+ {'id': 2, 'aliases': []}
+ ],
+ [
+ {'id': 1},
+ {'id': 2}
+ ]
+ )
+
+ assert docker_swarm_service.have_networks_changed(
+ [
+ {'id': 1},
+ {'id': 2, 'aliases': ['alias1']}
+ ],
+ [
+ {'id': 1},
+ {'id': 2}
+ ]
+ )
+
+ assert docker_swarm_service.have_networks_changed(
+ [
+ {'id': 1},
+ {'id': 2, 'aliases': ['alias1', 'alias2']}
+ ],
+ [
+ {'id': 1},
+ {'id': 2, 'aliases': ['alias1']}
+ ]
+ )
+
+ assert not docker_swarm_service.have_networks_changed(
+ [
+ {'id': 1},
+ {'id': 2, 'aliases': ['alias1', 'alias2']}
+ ],
+ [
+ {'id': 1},
+ {'id': 2, 'aliases': ['alias1', 'alias2']}
+ ]
+ )
+
+ assert not docker_swarm_service.have_networks_changed(
+ [
+ {'id': 1},
+ {'id': 2, 'aliases': ['alias1', 'alias2']}
+ ],
+ [
+ {'id': 1},
+ {'id': 2, 'aliases': ['alias2', 'alias1']}
+ ]
+ )
+
+ assert not docker_swarm_service.have_networks_changed(
+ [
+ {'id': 1, 'options': {}},
+ {'id': 2, 'aliases': ['alias1', 'alias2']}],
+ [
+ {'id': 1},
+ {'id': 2, 'aliases': ['alias2', 'alias1']}
+ ]
+ )
+
+ assert not docker_swarm_service.have_networks_changed(
+ [
+ {'id': 1, 'options': {'option1': 'value1'}},
+ {'id': 2, 'aliases': ['alias1', 'alias2']}],
+ [
+ {'id': 1, 'options': {'option1': 'value1'}},
+ {'id': 2, 'aliases': ['alias2', 'alias1']}
+ ]
+ )
+
+ assert docker_swarm_service.have_networks_changed(
+ [
+ {'id': 1, 'options': {'option1': 'value1'}},
+ {'id': 2, 'aliases': ['alias1', 'alias2']}],
+ [
+ {'id': 1, 'options': {'option1': 'value2'}},
+ {'id': 2, 'aliases': ['alias2', 'alias1']}
+ ]
+ )
+
+
+def test_get_docker_networks(docker_swarm_service):
+ network_names = [
+ 'network_1',
+ 'network_2',
+ 'network_3',
+ 'network_4',
+ ]
+ networks = [
+ network_names[0],
+ {'name': network_names[1]},
+ {'name': network_names[2], 'aliases': ['networkalias1']},
+ {'name': network_names[3], 'aliases': ['networkalias2'], 'options': {'foo': 'bar'}},
+ ]
+ network_ids = {
+ network_names[0]: '1',
+ network_names[1]: '2',
+ network_names[2]: '3',
+ network_names[3]: '4',
+ }
+ parsed_networks = docker_swarm_service.get_docker_networks(
+ networks,
+ network_ids
+ )
+ assert len(parsed_networks) == 4
+ for i, network in enumerate(parsed_networks):
+ assert 'name' not in network
+ assert 'id' in network
+ expected_name = network_names[i]
+ assert network['id'] == network_ids[expected_name]
+ if i == 2:
+ assert network['aliases'] == ['networkalias1']
+ if i == 3:
+ assert network['aliases'] == ['networkalias2']
+ if i == 3:
+ assert 'foo' in network['options']
+ # Test missing name
+ with pytest.raises(TypeError):
+ docker_swarm_service.get_docker_networks([{'invalid': 'err'}], {'err': 1})
+ # test for invalid aliases type
+ with pytest.raises(TypeError):
+ docker_swarm_service.get_docker_networks(
+ [{'name': 'test', 'aliases': 1}],
+ {'test': 1}
+ )
+ # Test invalid aliases elements
+ with pytest.raises(TypeError):
+ docker_swarm_service.get_docker_networks(
+ [{'name': 'test', 'aliases': [1]}],
+ {'test': 1}
+ )
+ # Test for invalid options type
+ with pytest.raises(TypeError):
+ docker_swarm_service.get_docker_networks(
+ [{'name': 'test', 'options': 1}],
+ {'test': 1}
+ )
+ # Test for invalid networks type
+ with pytest.raises(TypeError):
+ docker_swarm_service.get_docker_networks(
+ 1,
+ {'test': 1}
+ )
+ # Test for non existing networks
+ with pytest.raises(ValueError):
+ docker_swarm_service.get_docker_networks(
+ [{'name': 'idontexist'}],
+ {'test': 1}
+ )
+ # Test empty values
+ assert docker_swarm_service.get_docker_networks([], {}) == []
+ assert docker_swarm_service.get_docker_networks(None, {}) is None
+ # Test invalid options
+ with pytest.raises(TypeError):
+ docker_swarm_service.get_docker_networks(
+ [{'name': 'test', 'nonexisting_option': 'foo'}],
+ {'test': '1'}
+ )
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_volume.py b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_volume.py
new file mode 100644
index 00000000..6bce3f38
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/plugins/modules/test_docker_volume.py
@@ -0,0 +1,36 @@
+# Copyright (c) 2018 Ansible Project
+# GNU General Public License v3.0+ (see COPYING or https://www.gnu.org/licenses/gpl-3.0.txt)
+
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import json
+
+import pytest
+
+from ansible_collections.community.docker.plugins.modules import docker_volume
+from ansible_collections.community.docker.plugins.module_utils import common
+
+pytestmark = pytest.mark.usefixtures('patch_ansible_module')
+
+TESTCASE_DOCKER_VOLUME = [
+ {
+ 'name': 'daemon_config',
+ 'state': 'present'
+ }
+]
+
+
+@pytest.mark.parametrize('patch_ansible_module', TESTCASE_DOCKER_VOLUME, indirect=['patch_ansible_module'])
+def test_create_volume_on_invalid_docker_version(mocker, capfd):
+ mocker.patch.object(common, 'HAS_DOCKER_PY', True)
+ mocker.patch.object(common, 'docker_version', '1.8.0')
+
+ with pytest.raises(SystemExit):
+ docker_volume.main()
+
+ out, dummy = capfd.readouterr()
+ results = json.loads(out)
+ assert results['failed']
+ assert 'Error: Docker SDK for Python version is 1.8.0 ' in results['msg']
+ assert 'Minimum version required is 1.10.0.' in results['msg']
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/unit/requirements.txt b/collections-debian-merged/ansible_collections/community/docker/tests/unit/requirements.txt
new file mode 100644
index 00000000..89f3f5a6
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/unit/requirements.txt
@@ -0,0 +1,2 @@
+unittest2 ; python_version < '2.7'
+importlib ; python_version < '2.7'
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/utils/constraints.txt b/collections-debian-merged/ansible_collections/community/docker/tests/utils/constraints.txt
new file mode 100644
index 00000000..ae6000ae
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/utils/constraints.txt
@@ -0,0 +1,52 @@
+coverage >= 4.2, < 5.0.0, != 4.3.2 ; python_version <= '3.7' # features in 4.2+ required, avoid known bug in 4.3.2 on python 2.6, coverage 5.0+ incompatible
+coverage >= 4.5.4, < 5.0.0 ; python_version > '3.7' # coverage had a bug in < 4.5.4 that would cause unit tests to hang in Python 3.8, coverage 5.0+ incompatible
+cryptography < 2.2 ; python_version < '2.7' # cryptography 2.2 drops support for python 2.6
+deepdiff < 4.0.0 ; python_version < '3' # deepdiff 4.0.0 and later require python 3
+jinja2 < 2.11 ; python_version < '2.7' # jinja2 2.11 and later require python 2.7 or later
+urllib3 < 1.24 ; python_version < '2.7' # urllib3 1.24 and later require python 2.7 or later
+pywinrm >= 0.3.0 # message encryption support
+sphinx < 1.6 ; python_version < '2.7' # sphinx 1.6 and later require python 2.7 or later
+sphinx < 1.8 ; python_version >= '2.7' # sphinx 1.8 and later are currently incompatible with rstcheck 3.3
+pygments >= 2.4.0 # Pygments 2.4.0 includes bugfixes for YAML and YAML+Jinja lexers
+wheel < 0.30.0 ; python_version < '2.7' # wheel 0.30.0 and later require python 2.7 or later
+yamllint != 1.8.0, < 1.14.0 ; python_version < '2.7' # yamllint 1.8.0 and 1.14.0+ require python 2.7+
+pycrypto >= 2.6 # Need features found in 2.6 and greater
+ncclient >= 0.5.2 # Need features added in 0.5.2 and greater
+idna < 2.6, >= 2.5 # linode requires idna < 2.9, >= 2.5, requests requires idna < 2.6, but cryptography will cause the latest version to be installed instead
+paramiko < 2.4.0 ; python_version < '2.7' # paramiko 2.4.0 drops support for python 2.6
+pytest < 3.3.0 ; python_version < '2.7' # pytest 3.3.0 drops support for python 2.6
+pytest < 5.0.0 ; python_version == '2.7' # pytest 5.0.0 and later will no longer support python 2.7
+pytest-forked < 1.0.2 ; python_version < '2.7' # pytest-forked 1.0.2 and later require python 2.7 or later
+pytest-forked >= 1.0.2 ; python_version >= '2.7' # pytest-forked before 1.0.2 does not work with pytest 4.2.0+ (which requires python 2.7+)
+ntlm-auth >= 1.3.0 # message encryption support using cryptography
+requests < 2.20.0 ; python_version < '2.7' # requests 2.20.0 drops support for python 2.6
+requests-ntlm >= 1.1.0 # message encryption support
+requests-credssp >= 0.1.0 # message encryption support
+voluptuous >= 0.11.0 # Schema recursion via Self
+openshift >= 0.6.2, < 0.9.0 # merge_type support
+virtualenv < 16.0.0 ; python_version < '2.7' # virtualenv 16.0.0 and later require python 2.7 or later
+pathspec < 0.6.0 ; python_version < '2.7' # pathspec 0.6.0 and later require python 2.7 or later
+pyopenssl < 18.0.0 ; python_version < '2.7' # pyOpenSSL 18.0.0 and later require python 2.7 or later
+pyfmg == 0.6.1 # newer versions do not pass current unit tests
+pyyaml < 5.1 ; python_version < '2.7' # pyyaml 5.1 and later require python 2.7 or later
+pycparser < 2.19 ; python_version < '2.7' # pycparser 2.19 and later require python 2.7 or later
+mock >= 2.0.0 # needed for features backported from Python 3.6 unittest.mock (assert_called, assert_called_once...)
+pytest-mock >= 1.4.0 # needed for mock_use_standalone_module pytest option
+xmltodict < 0.12.0 ; python_version < '2.7' # xmltodict 0.12.0 and later require python 2.7 or later
+lxml < 4.3.0 ; python_version < '2.7' # lxml 4.3.0 and later require python 2.7 or later
+pyvmomi < 6.0.0 ; python_version < '2.7' # pyvmomi 6.0.0 and later require python 2.7 or later
+pyone == 1.1.9 # newer versions do not pass current integration tests
+boto3 < 1.11 ; python_version < '2.7' # boto3 1.11 drops Python 2.6 support
+botocore >= 1.10.0, < 1.14 ; python_version < '2.7' # adds support for the following AWS services: secretsmanager, fms, and acm-pca; botocore 1.14 drops Python 2.6 support
+botocore >= 1.10.0 ; python_version >= '2.7' # adds support for the following AWS services: secretsmanager, fms, and acm-pca
+setuptools < 45 ; python_version <= '2.7' # setuptools 45 and later require python 3.5 or later
+cffi >= 1.14.2, != 1.14.3 # Yanked version which older versions of pip will still install:
+
+# freeze pylint and its requirements for consistent test results
+astroid == 2.2.5
+isort == 4.3.15
+lazy-object-proxy == 1.3.1
+mccabe == 0.6.1
+pylint == 2.3.1
+typed-ast == 1.4.0 # 1.4.0 is required to compile on Python 3.8
+wrapt == 1.11.1
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/check_matrix.py b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/check_matrix.py
new file mode 100755
index 00000000..ab8d66c0
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/check_matrix.py
@@ -0,0 +1,120 @@
+#!/usr/bin/env python
+"""Verify the currently executing Shippable test matrix matches the one defined in the "shippable.yml" file."""
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import datetime
+import json
+import os
+import re
+import sys
+import time
+
+try:
+ from typing import NoReturn
+except ImportError:
+ NoReturn = None
+
+try:
+ # noinspection PyCompatibility
+ from urllib2 import urlopen # pylint: disable=ansible-bad-import-from
+except ImportError:
+ # noinspection PyCompatibility
+ from urllib.request import urlopen
+
+
+def main(): # type: () -> None
+ """Main entry point."""
+ repo_full_name = os.environ['REPO_FULL_NAME']
+ required_repo_full_name = 'ansible-collections/community.docker'
+
+ if repo_full_name != required_repo_full_name:
+ sys.stderr.write('Skipping matrix check on repo "%s" which is not "%s".\n' % (repo_full_name, required_repo_full_name))
+ return
+
+ with open('shippable.yml', 'rb') as yaml_file:
+ yaml = yaml_file.read().decode('utf-8').splitlines()
+
+ defined_matrix = [match.group(1) for match in [re.search(r'^ *- env: T=(.*)$', line) for line in yaml] if match and match.group(1) != 'none']
+
+ if not defined_matrix:
+ fail('No matrix entries found in the "shippable.yml" file.',
+ 'Did you modify the "shippable.yml" file?')
+
+ run_id = os.environ['SHIPPABLE_BUILD_ID']
+ sleep = 1
+ jobs = []
+
+ for attempts_remaining in range(4, -1, -1):
+ try:
+ jobs = json.loads(urlopen('https://api.shippable.com/jobs?runIds=%s' % run_id).read())
+
+ if not isinstance(jobs, list):
+ raise Exception('Shippable run %s data is not a list.' % run_id)
+
+ break
+ except Exception as ex:
+ if not attempts_remaining:
+ fail('Unable to retrieve Shippable run %s matrix.' % run_id,
+ str(ex))
+
+ sys.stderr.write('Unable to retrieve Shippable run %s matrix: %s\n' % (run_id, ex))
+ sys.stderr.write('Trying again in %d seconds...\n' % sleep)
+ time.sleep(sleep)
+ sleep *= 2
+
+ if len(jobs) != len(defined_matrix):
+ if len(jobs) == 1:
+ hint = '\n\nMake sure you do not use the "Rebuild with SSH" option.'
+ else:
+ hint = ''
+
+ fail('Shippable run %s has %d jobs instead of the expected %d jobs.' % (run_id, len(jobs), len(defined_matrix)),
+ 'Try re-running the entire matrix.%s' % hint)
+
+ actual_matrix = dict((job.get('jobNumber'), dict(tuple(line.split('=', 1)) for line in job.get('env', [])).get('T', '')) for job in jobs)
+ errors = [(job_number, test, actual_matrix.get(job_number)) for job_number, test in enumerate(defined_matrix, 1) if actual_matrix.get(job_number) != test]
+
+ if len(errors):
+ error_summary = '\n'.join('Job %s expected "%s" but found "%s" instead.' % (job_number, expected, actual) for job_number, expected, actual in errors)
+
+ fail('Shippable run %s has a job matrix mismatch.' % run_id,
+ 'Try re-running the entire matrix.\n\n%s' % error_summary)
+
+
+def fail(message, output): # type: (str, str) -> NoReturn
+ # Include a leading newline to improve readability on Shippable "Tests" tab.
+ # Without this, the first line becomes indented.
+ output = '\n' + output.strip()
+
+ timestamp = datetime.datetime.utcnow().replace(microsecond=0).isoformat()
+
+ # hack to avoid requiring junit-xml, which isn't pre-installed on Shippable outside our test containers
+ xml = '''
+<?xml version="1.0" encoding="utf-8"?>
+<testsuites disabled="0" errors="1" failures="0" tests="1" time="0.0">
+\t<testsuite disabled="0" errors="1" failures="0" file="None" log="None" name="ansible-test" skipped="0" tests="1" time="0" timestamp="%s" url="None">
+\t\t<testcase classname="timeout" name="timeout">
+\t\t\t<error message="%s" type="error">%s</error>
+\t\t</testcase>
+\t</testsuite>
+</testsuites>
+''' % (timestamp, message, output)
+
+ path = 'shippable/testresults/check-matrix.xml'
+ dir_path = os.path.dirname(path)
+
+ if not os.path.exists(dir_path):
+ os.makedirs(dir_path)
+
+ with open(path, 'w') as junit_fd:
+ junit_fd.write(xml.lstrip())
+
+ sys.stderr.write(message + '\n')
+ sys.stderr.write(output + '\n')
+
+ sys.exit(1)
+
+
+if __name__ == '__main__':
+ main()
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/cloud.sh b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/cloud.sh
new file mode 100755
index 00000000..d76c3228
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/cloud.sh
@@ -0,0 +1,19 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+cloud="${args[0]}"
+python="${args[1]}"
+group="${args[2]}"
+
+target="shippable/${cloud}/group${group}/"
+
+stage="${S:-prod}"
+
+# shellcheck disable=SC2086
+ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
+ --remote-terminate always --remote-stage "${stage}" \
+ --docker --python "${python}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/linux.sh b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/linux.sh
new file mode 100755
index 00000000..9cc2f966
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/linux.sh
@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+image="${args[1]}"
+
+if [ "${#args[@]}" -gt 2 ]; then
+ target="shippable/posix/group${args[2]}/"
+else
+ target="shippable/posix/"
+fi
+
+# shellcheck disable=SC2086
+ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
+ --docker "${image}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/remote.sh b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/remote.sh
new file mode 100755
index 00000000..cd3014cc
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/remote.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+platform="${args[0]}"
+version="${args[1]}"
+
+if [ "${#args[@]}" -gt 2 ]; then
+ target="shippable/posix/group${args[2]}/"
+else
+ target="shippable/posix/"
+fi
+
+stage="${S:-prod}"
+provider="${P:-default}"
+
+# shellcheck disable=SC2086
+ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
+ --remote "${platform}/${version}" --remote-terminate always --remote-stage "${stage}" --remote-provider "${provider}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/rhel.sh b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/rhel.sh
new file mode 100755
index 00000000..cd3014cc
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/rhel.sh
@@ -0,0 +1,22 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+platform="${args[0]}"
+version="${args[1]}"
+
+if [ "${#args[@]}" -gt 2 ]; then
+ target="shippable/posix/group${args[2]}/"
+else
+ target="shippable/posix/"
+fi
+
+stage="${S:-prod}"
+provider="${P:-default}"
+
+# shellcheck disable=SC2086
+ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
+ --remote "${platform}/${version}" --remote-terminate always --remote-stage "${stage}" --remote-provider "${provider}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/sanity.sh b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/sanity.sh
new file mode 100755
index 00000000..dee0626c
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/sanity.sh
@@ -0,0 +1,24 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+group="${args[1]}"
+
+if [ "${BASE_BRANCH:-}" ]; then
+ base_branch="origin/${BASE_BRANCH}"
+else
+ base_branch=""
+fi
+
+if [ "${group}" == "extra" ]; then
+ ../internal_test_tools/tools/run.py --color
+ exit
+fi
+
+# shellcheck disable=SC2086
+ansible-test sanity --color -v --junit ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \
+ --docker --base-branch "${base_branch}" \
+ --allow-disabled
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/shippable.sh b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/shippable.sh
new file mode 100755
index 00000000..e9318cdd
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/shippable.sh
@@ -0,0 +1,219 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+ansible_version="${args[0]}"
+script="${args[1]}"
+
+function join {
+ local IFS="$1";
+ shift;
+ echo "$*";
+}
+
+# Ensure we can write other collections to this dir
+sudo chown "$(whoami)" "${PWD}/../../"
+
+test="$(join / "${args[@]:1}")"
+
+docker images ansible/ansible
+docker images quay.io/ansible/*
+docker ps
+
+for container in $(docker ps --format '{{.Image}} {{.ID}}' | grep -v -e '^drydock/' -e '^quay.io/ansible/azure-pipelines-test-container:' | sed 's/^.* //'); do
+ docker rm -f "${container}" || true # ignore errors
+done
+
+docker ps
+
+if [ -d /home/shippable/cache/ ]; then
+ ls -la /home/shippable/cache/
+fi
+
+command -v python
+python -V
+
+function retry
+{
+ # shellcheck disable=SC2034
+ for repetition in 1 2 3; do
+ set +e
+ "$@"
+ result=$?
+ set -e
+ if [ ${result} == 0 ]; then
+ return ${result}
+ fi
+ echo "@* -> ${result}"
+ done
+ echo "Command '@*' failed 3 times!"
+ exit -1
+}
+
+command -v pip
+pip --version
+pip list --disable-pip-version-check
+if [ "${ansible_version}" == "devel" ]; then
+ retry pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
+else
+ retry pip install "https://github.com/ansible/ansible/archive/stable-${ansible_version}.tar.gz" --disable-pip-version-check
+fi
+
+if [ "${SHIPPABLE_BUILD_ID:-}" ]; then
+ export ANSIBLE_COLLECTIONS_PATHS="${HOME}/.ansible"
+ SHIPPABLE_RESULT_DIR="$(pwd)/shippable"
+ TEST_DIR="${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/community/docker"
+ mkdir -p "${TEST_DIR}"
+ cp -aT "${SHIPPABLE_BUILD_DIR}" "${TEST_DIR}"
+ cd "${TEST_DIR}"
+else
+ export ANSIBLE_COLLECTIONS_PATHS="${PWD}/../../../"
+fi
+
+if [ "${script}" != "sanity" ] || [ "${test}" == "sanity/extra" ]; then
+ # Nothing further should be added to this list.
+ # This is to prevent modules or plugins in this collection having a runtime dependency on other collections.
+ retry ansible-galaxy -vvv collection install community.internal_test_tools
+fi
+
+if [ "${script}" != "sanity" ] && [ "${script}" != "units" ]; then
+ # To prevent Python dependencies on other collections only install other collections for integration tests
+ retry ansible-galaxy -vvv collection install ansible.posix
+ retry ansible-galaxy -vvv collection install community.crypto
+ retry ansible-galaxy -vvv collection install community.general
+fi
+
+# END: HACK
+
+export PYTHONIOENCODING='utf-8'
+
+if [ "${JOB_TRIGGERED_BY_NAME:-}" == "nightly-trigger" ]; then
+ COVERAGE=yes
+ COMPLETE=yes
+fi
+
+if [ -n "${COVERAGE:-}" ]; then
+ # on-demand coverage reporting triggered by setting the COVERAGE environment variable to a non-empty value
+ export COVERAGE="--coverage"
+elif [[ "${COMMIT_MESSAGE}" =~ ci_coverage ]]; then
+ # on-demand coverage reporting triggered by having 'ci_coverage' in the latest commit message
+ export COVERAGE="--coverage"
+else
+ # on-demand coverage reporting disabled (default behavior, always-on coverage reporting remains enabled)
+ export COVERAGE="--coverage-check"
+fi
+
+if [ -n "${COMPLETE:-}" ]; then
+ # disable change detection triggered by setting the COMPLETE environment variable to a non-empty value
+ export CHANGED=""
+elif [[ "${COMMIT_MESSAGE}" =~ ci_complete ]]; then
+ # disable change detection triggered by having 'ci_complete' in the latest commit message
+ export CHANGED=""
+else
+ # enable change detection (default behavior)
+ export CHANGED="--changed"
+fi
+
+if [ "${IS_PULL_REQUEST:-}" == "true" ]; then
+ # run unstable tests which are targeted by focused changes on PRs
+ export UNSTABLE="--allow-unstable-changed"
+else
+ # do not run unstable tests outside PRs
+ export UNSTABLE=""
+fi
+
+# remove empty core/extras module directories from PRs created prior to the repo-merge
+find plugins -type d -empty -print -delete
+
+function cleanup
+{
+ # for complete on-demand coverage generate a report for all files with no coverage on the "sanity/5" job so we only have one copy
+ if [ "${COVERAGE}" == "--coverage" ] && [ "${CHANGED}" == "" ] && [ "${test}" == "sanity/5" ]; then
+ stub="--stub"
+ # trigger coverage reporting for stubs even if no other coverage data exists
+ mkdir -p tests/output/coverage/
+ else
+ stub=""
+ fi
+
+ if [ -d tests/output/coverage/ ]; then
+ if find tests/output/coverage/ -mindepth 1 -name '.*' -prune -o -print -quit | grep -q .; then
+ process_coverage='yes' # process existing coverage files
+ elif [ "${stub}" ]; then
+ process_coverage='yes' # process coverage when stubs are enabled
+ else
+ process_coverage=''
+ fi
+
+ if [ "${process_coverage}" ]; then
+ # use python 3.7 for coverage to avoid running out of memory during coverage xml processing
+ # only use it for coverage to avoid the additional overhead of setting up a virtual environment for a potential no-op job
+ virtualenv --python /usr/bin/python3.7 ~/ansible-venv
+ set +ux
+ . ~/ansible-venv/bin/activate
+ set -ux
+
+ # shellcheck disable=SC2086
+ ansible-test coverage xml --color -v --requirements --group-by command --group-by version ${stub:+"$stub"}
+ cp -a tests/output/reports/coverage=*.xml "$SHIPPABLE_RESULT_DIR/codecoverage/"
+
+ if [ "${ansible_version}" != "2.9" ]; then
+ # analyze and capture code coverage aggregated by integration test target
+ ansible-test coverage analyze targets generate -v "$SHIPPABLE_RESULT_DIR/testresults/coverage-analyze-targets.json"
+ fi
+
+ # upload coverage report to codecov.io only when using complete on-demand coverage
+ if [ "${COVERAGE}" == "--coverage" ] && [ "${CHANGED}" == "" ]; then
+ for file in tests/output/reports/coverage=*.xml; do
+ flags="${file##*/coverage=}"
+ flags="${flags%-powershell.xml}"
+ flags="${flags%.xml}"
+ # remove numbered component from stub files when converting to tags
+ flags="${flags//stub-[0-9]*/stub}"
+ flags="${flags//=/,}"
+ flags="${flags//[^a-zA-Z0-9_,]/_}"
+
+ bash <(curl -s https://codecov.io/bash) \
+ -f "${file}" \
+ -F "${flags}" \
+ -n "${test}" \
+ -t 8450ed26-4e94-4d07-8831-d2023d6d20a3 \
+ -X coveragepy \
+ -X gcov \
+ -X fix \
+ -X search \
+ -X xcode \
+ || echo "Failed to upload code coverage report to codecov.io: ${file}"
+ done
+ fi
+ fi
+ fi
+
+ if [ -d tests/output/junit/ ]; then
+ cp -aT tests/output/junit/ "$SHIPPABLE_RESULT_DIR/testresults/"
+ fi
+
+ if [ -d tests/output/data/ ]; then
+ cp -a tests/output/data/ "$SHIPPABLE_RESULT_DIR/testresults/"
+ fi
+
+ if [ -d tests/output/bot/ ]; then
+ cp -aT tests/output/bot/ "$SHIPPABLE_RESULT_DIR/testresults/"
+ fi
+}
+
+if [ "${SHIPPABLE_BUILD_ID:-}" ]; then trap cleanup EXIT; fi
+
+if [[ "${COVERAGE:-}" == "--coverage" ]]; then
+ timeout=60
+else
+ timeout=50
+fi
+
+ansible-test env --dump --show --timeout "${timeout}" --color -v
+
+if [ "${SHIPPABLE_BUILD_ID:-}" ]; then "tests/utils/shippable/check_matrix.py"; fi
+"tests/utils/shippable/${script}.sh" "${test}"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/timing.py b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/timing.py
new file mode 100755
index 00000000..fb538271
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/timing.py
@@ -0,0 +1,16 @@
+#!/usr/bin/env python3.7
+from __future__ import (absolute_import, division, print_function)
+__metaclass__ = type
+
+import sys
+import time
+
+start = time.time()
+
+sys.stdin.reconfigure(errors='surrogateescape')
+sys.stdout.reconfigure(errors='surrogateescape')
+
+for line in sys.stdin:
+ seconds = time.time() - start
+ sys.stdout.write('%02d:%02d %s' % (seconds // 60, seconds % 60, line))
+ sys.stdout.flush()
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/timing.sh b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/timing.sh
new file mode 100755
index 00000000..77e25783
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/timing.sh
@@ -0,0 +1,5 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eu
+
+"$@" 2>&1 | "$(dirname "$0")/timing.py"
diff --git a/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/units.sh b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/units.sh
new file mode 100755
index 00000000..f204dc87
--- /dev/null
+++ b/collections-debian-merged/ansible_collections/community/docker/tests/utils/shippable/units.sh
@@ -0,0 +1,26 @@
+#!/usr/bin/env bash
+
+set -o pipefail -eux
+
+declare -a args
+IFS='/:' read -ra args <<< "$1"
+
+group="${args[1]}"
+
+if [[ "${COVERAGE:-}" == "--coverage" ]]; then
+ timeout=90
+else
+ timeout=30
+fi
+
+group1=()
+
+case "${group}" in
+ 1) options=("${group1[@]:+${group1[@]}}") ;;
+esac
+
+ansible-test env --timeout "${timeout}" --color -v
+
+# shellcheck disable=SC2086
+ansible-test units --color -v --docker default ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \
+ "${options[@]:+${options[@]}}" \