diff --git a/.azure-pipelines/templates/matrix.yml b/.azure-pipelines/templates/matrix.yml index 85a869a8..49f5d859 100644 --- a/.azure-pipelines/templates/matrix.yml +++ b/.azure-pipelines/templates/matrix.yml @@ -1,3 +1,4 @@ +--- # Copyright (c) Ansible Project # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later @@ -49,11 +50,11 @@ jobs: parameters: jobs: - ${{ if eq(length(parameters.groups), 0) }}: - - ${{ each target in parameters.targets }}: - - name: ${{ format(parameters.nameFormat, coalesce(target.name, target.test)) }} - test: ${{ format(parameters.testFormat, coalesce(target.test, target.name)) }} - - ${{ if not(eq(length(parameters.groups), 0)) }}: - - ${{ each group in parameters.groups }}: - ${{ each target in parameters.targets }}: - - name: ${{ format(format(parameters.nameGroupFormat, parameters.nameFormat), coalesce(target.name, target.test), group) }} - test: ${{ format(format(parameters.testGroupFormat, parameters.testFormat), coalesce(target.test, target.name), group) }} + - name: ${{ format(parameters.nameFormat, coalesce(target.name, target.test)) }} + test: ${{ format(parameters.testFormat, coalesce(target.test, target.name)) }} + - ${{ if not(eq(length(parameters.groups), 0)) }}: + - ${{ each group in parameters.groups }}: + - ${{ each target in parameters.targets }}: + - name: ${{ format(format(parameters.nameGroupFormat, parameters.nameFormat), coalesce(target.name, target.test), group) }} + test: ${{ format(format(parameters.testGroupFormat, parameters.testFormat), coalesce(target.test, target.name), group) }} diff --git a/.azure-pipelines/templates/test.yml b/.azure-pipelines/templates/test.yml index 90501327..b263379c 100644 --- a/.azure-pipelines/templates/test.yml +++ b/.azure-pipelines/templates/test.yml @@ -1,3 +1,4 @@ +--- # Copyright (c) Ansible Project # GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # SPDX-License-Identifier: GPL-3.0-or-later @@ -13,37 +14,37 @@ parameters: jobs: - ${{ each job in parameters.jobs }}: - - job: test_${{ replace(replace(replace(job.test, '/', '_'), '.', '_'), '-', '_') }} - displayName: ${{ job.name }} - container: default - workspace: - clean: all - steps: - - checkout: self - fetchDepth: $(fetchDepth) - path: $(checkoutPath) - - bash: .azure-pipelines/scripts/run-tests.sh "$(entryPoint)" "${{ job.test }}" "$(coverageBranches)" - displayName: Run Tests - - bash: .azure-pipelines/scripts/process-results.sh - condition: succeededOrFailed() - displayName: Process Results - - bash: .azure-pipelines/scripts/aggregate-coverage.sh "$(Agent.TempDirectory)" - condition: eq(variables.haveCoverageData, 'true') - displayName: Aggregate Coverage Data - - task: PublishTestResults@2 - condition: eq(variables.haveTestResults, 'true') - inputs: - testResultsFiles: "$(outputPath)/junit/*.xml" - displayName: Publish Test Results - - task: PublishPipelineArtifact@1 - condition: eq(variables.haveBotResults, 'true') - displayName: Publish Bot Results - inputs: - targetPath: "$(outputPath)/bot/" - artifactName: "Bot $(System.JobAttempt) $(System.StageDisplayName) $(System.JobDisplayName)" - - task: PublishPipelineArtifact@1 - condition: eq(variables.haveCoverageData, 'true') - displayName: Publish Coverage Data - inputs: - targetPath: "$(Agent.TempDirectory)/coverage/" - artifactName: "Coverage $(System.JobAttempt) $(System.StageDisplayName) $(System.JobDisplayName)" + - job: test_${{ replace(replace(replace(job.test, '/', '_'), '.', '_'), '-', '_') }} + displayName: ${{ job.name }} + container: default + workspace: + clean: all + steps: + - checkout: self + fetchDepth: $(fetchDepth) + path: $(checkoutPath) + - bash: .azure-pipelines/scripts/run-tests.sh "$(entryPoint)" "${{ job.test }}" "$(coverageBranches)" + displayName: Run Tests + - bash: .azure-pipelines/scripts/process-results.sh + condition: succeededOrFailed() + displayName: Process Results + - bash: .azure-pipelines/scripts/aggregate-coverage.sh "$(Agent.TempDirectory)" + condition: eq(variables.haveCoverageData, 'true') + displayName: Aggregate Coverage Data + - task: PublishTestResults@2 + condition: eq(variables.haveTestResults, 'true') + inputs: + testResultsFiles: "$(outputPath)/junit/*.xml" + displayName: Publish Test Results + - task: PublishPipelineArtifact@1 + condition: eq(variables.haveBotResults, 'true') + displayName: Publish Bot Results + inputs: + targetPath: "$(outputPath)/bot/" + artifactName: "Bot $(System.JobAttempt) $(System.StageDisplayName) $(System.JobDisplayName)" + - task: PublishPipelineArtifact@1 + condition: eq(variables.haveCoverageData, 'true') + displayName: Publish Coverage Data + inputs: + targetPath: "$(Agent.TempDirectory)/coverage/" + artifactName: "Coverage $(System.JobAttempt) $(System.StageDisplayName) $(System.JobDisplayName)" diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 33f4be58..ebebf3df 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -7,7 +7,7 @@ # https://github.com/marketplace/actions/ansible-test name: EOL CI -on: +'on': # Run EOL CI against all pushes (direct commits, also merged PRs), Pull Requests push: branches: diff --git a/.github/workflows/docker-images.yml b/.github/workflows/docker-images.yml index 28f506c8..3c982c4f 100644 --- a/.github/workflows/docker-images.yml +++ b/.github/workflows/docker-images.yml @@ -4,7 +4,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later name: Helper Docker images for testing -on: +'on': # Run CI against all pushes (direct commits, also merged PRs), Pull Requests push: branches: diff --git a/.github/workflows/docs-pr.yml b/.github/workflows/docs-pr.yml index 139d291d..11771fdd 100644 --- a/.github/workflows/docs-pr.yml +++ b/.github/workflows/docs-pr.yml @@ -7,7 +7,7 @@ name: Collection Docs concurrency: group: docs-pr-${{ github.head_ref }} cancel-in-progress: true -on: +'on': pull_request_target: types: [opened, synchronize, reopened, closed] diff --git a/.github/workflows/docs-push.yml b/.github/workflows/docs-push.yml index 06dd844b..83b41373 100644 --- a/.github/workflows/docs-push.yml +++ b/.github/workflows/docs-push.yml @@ -7,7 +7,7 @@ name: Collection Docs concurrency: group: docs-push-${{ github.sha }} cancel-in-progress: true -on: +'on': push: branches: - main diff --git a/.github/workflows/ee.yml b/.github/workflows/ee.yml index c3f2aa6b..be1320c5 100644 --- a/.github/workflows/ee.yml +++ b/.github/workflows/ee.yml @@ -4,7 +4,7 @@ # SPDX-License-Identifier: GPL-3.0-or-later name: execution environment -on: +'on': # Run CI against all pushes (direct commits, also merged PRs), Pull Requests push: branches: diff --git a/galaxy.yml b/galaxy.yml index 8f4b946e..f41c2a77 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -15,7 +15,7 @@ description: Modules and plugins for working with Docker license: - GPL-3.0-or-later - Apache-2.0 -#license_file: COPYING +# license_file: COPYING tags: - docker dependencies: diff --git a/plugins/modules/current_container_facts.py b/plugins/modules/current_container_facts.py index 621965ad..a376baca 100644 --- a/plugins/modules/current_container_facts.py +++ b/plugins/modules/current_container_facts.py @@ -27,6 +27,7 @@ extends_documentation_fragment: """ EXAMPLES = r""" +--- - name: Get facts on current container community.docker.current_container_facts: diff --git a/plugins/modules/docker_compose_v2.py b/plugins/modules/docker_compose_v2.py index 57583008..cab98b29 100644 --- a/plugins/modules/docker_compose_v2.py +++ b/plugins/modules/docker_compose_v2.py @@ -178,6 +178,7 @@ seealso: """ EXAMPLES = r""" +--- # Examples use the django example at https://docs.docker.com/compose/django. Follow it to create the # flask directory diff --git a/plugins/modules/docker_compose_v2_exec.py b/plugins/modules/docker_compose_v2_exec.py index a4919d0c..c4f379e5 100644 --- a/plugins/modules/docker_compose_v2_exec.py +++ b/plugins/modules/docker_compose_v2_exec.py @@ -119,6 +119,7 @@ notes: """ EXAMPLES = r""" +--- - name: Run a simple command (command) community.docker.docker_compose_v2_exec: service: foo diff --git a/plugins/modules/docker_compose_v2_pull.py b/plugins/modules/docker_compose_v2_pull.py index 2c556c0f..9d4dbdb2 100644 --- a/plugins/modules/docker_compose_v2_pull.py +++ b/plugins/modules/docker_compose_v2_pull.py @@ -75,6 +75,7 @@ seealso: """ EXAMPLES = r""" +--- - name: Pull images for flask project community.docker.docker_compose_v2_pull: project_src: /path/to/flask diff --git a/plugins/modules/docker_compose_v2_run.py b/plugins/modules/docker_compose_v2_run.py index 3d07bfb2..a07531d3 100644 --- a/plugins/modules/docker_compose_v2_run.py +++ b/plugins/modules/docker_compose_v2_run.py @@ -187,6 +187,7 @@ notes: """ EXAMPLES = r""" +--- - name: Run a simple command (command) community.docker.docker_compose_v2_run: service: foo diff --git a/plugins/modules/docker_config.py b/plugins/modules/docker_config.py index 6ca6f229..b6fe3cf1 100644 --- a/plugins/modules/docker_config.py +++ b/plugins/modules/docker_config.py @@ -111,6 +111,7 @@ author: """ EXAMPLES = r""" +--- - name: Create config foo (from a file on the control machine) community.docker.docker_config: name: foo diff --git a/plugins/modules/docker_container.py b/plugins/modules/docker_container.py index 58669492..91c78699 100644 --- a/plugins/modules/docker_container.py +++ b/plugins/modules/docker_container.py @@ -996,6 +996,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Create a data container community.docker.docker_container: name: mydata diff --git a/plugins/modules/docker_container_copy_into.py b/plugins/modules/docker_container_copy_into.py index 78b78136..3c48f485 100644 --- a/plugins/modules/docker_container_copy_into.py +++ b/plugins/modules/docker_container_copy_into.py @@ -120,6 +120,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Copy a file into the container community.docker.docker_container_copy_into: container: mydata diff --git a/plugins/modules/docker_container_exec.py b/plugins/modules/docker_container_exec.py index 3eb86daa..130ed731 100644 --- a/plugins/modules/docker_container_exec.py +++ b/plugins/modules/docker_container_exec.py @@ -111,6 +111,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Run a simple command (command) community.docker.docker_container_exec: container: foo diff --git a/plugins/modules/docker_container_info.py b/plugins/modules/docker_container_info.py index 27addd4a..abb94bd2 100644 --- a/plugins/modules/docker_container_info.py +++ b/plugins/modules/docker_container_info.py @@ -40,6 +40,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Get infos on container community.docker.docker_container_info: name: mydata diff --git a/plugins/modules/docker_context_info.py b/plugins/modules/docker_context_info.py index e539d4fc..cfdc4485 100644 --- a/plugins/modules/docker_context_info.py +++ b/plugins/modules/docker_context_info.py @@ -51,6 +51,7 @@ author: """ EXAMPLES = r""" +--- - name: Get infos on contexts community.docker.docker_context_info: register: result diff --git a/plugins/modules/docker_host_info.py b/plugins/modules/docker_host_info.py index c678989d..99181676 100644 --- a/plugins/modules/docker_host_info.py +++ b/plugins/modules/docker_host_info.py @@ -122,6 +122,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Get info on docker host community.docker.docker_host_info: register: result diff --git a/plugins/modules/docker_image.py b/plugins/modules/docker_image.py index dbce6c21..0c97cd98 100644 --- a/plugins/modules/docker_image.py +++ b/plugins/modules/docker_image.py @@ -263,6 +263,7 @@ seealso: """ EXAMPLES = r""" +--- - name: Pull an image community.docker.docker_image: name: pacur/centos-7 diff --git a/plugins/modules/docker_image_build.py b/plugins/modules/docker_image_build.py index 182ab49b..298f2927 100644 --- a/plugins/modules/docker_image_build.py +++ b/plugins/modules/docker_image_build.py @@ -248,6 +248,7 @@ seealso: """ EXAMPLES = r""" +--- - name: Build Python 3.12 image community.docker.docker_image_build: name: localhost/python/3.12:latest diff --git a/plugins/modules/docker_image_export.py b/plugins/modules/docker_image_export.py index 4c0cc041..23997f41 100644 --- a/plugins/modules/docker_image_export.py +++ b/plugins/modules/docker_image_export.py @@ -71,6 +71,7 @@ seealso: """ EXAMPLES = r""" +--- - name: Export an image community.docker.docker_image_export: name: pacur/centos-7 diff --git a/plugins/modules/docker_image_info.py b/plugins/modules/docker_image_info.py index 7ff0ec9a..ef299233 100644 --- a/plugins/modules/docker_image_info.py +++ b/plugins/modules/docker_image_info.py @@ -46,6 +46,7 @@ author: """ EXAMPLES = r""" +--- - name: Inspect a single image community.docker.docker_image_info: name: pacur/centos-7 @@ -71,20 +72,68 @@ images: returned: always type: list elements: dict - sample: [{"Architecture": "amd64", "Author": "", "Comment": "", "Config": {"AttachStderr": false, "AttachStdin": false, - "AttachStdout": false, "Cmd": ["/etc/docker/registry/config.yml"], "Domainname": "", "Entrypoint": ["/bin/registry"], - "Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"], "ExposedPorts": {"5000/tcp": {}}, - "Hostname": "e5c68db50333", "Image": "c72dce2618dc8f7b794d2b2c2b1e64e0205ead5befc294f8111da23bd6a2c799", "Labels": {}, - "OnBuild": [], "OpenStdin": false, "StdinOnce": false, "Tty": false, "User": "", "Volumes": {"/var/lib/registry": {}}, - "WorkingDir": ""}, "Container": "e83a452b8fb89d78a25a6739457050131ca5c863629a47639530d9ad2008d610", "ContainerConfig": { - "AttachStderr": false, "AttachStdin": false, "AttachStdout": false, "Cmd": ["/bin/sh", "-c", '#(nop) CMD ["/etc/docker/registry/config.yml"]'], - "Domainname": "", "Entrypoint": ["/bin/registry"], "Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"], - "ExposedPorts": {"5000/tcp": {}}, "Hostname": "e5c68db50333", "Image": "c72dce2618dc8f7b794d2b2c2b1e64e0205ead5befc294f8111da23bd6a2c799", - "Labels": {}, "OnBuild": [], "OpenStdin": false, "StdinOnce": false, "Tty": false, "User": "", "Volumes": {"/var/lib/registry": {}}, - "WorkingDir": ""}, "Created": "2016-03-08T21:08:15.399680378Z", "DockerVersion": "1.9.1", "GraphDriver": {"Data": null, - "Name": "aufs"}, "Id": "53773d8552f07b730f3e19979e32499519807d67b344141d965463a950a66e08", "Name": "registry:2", - "Os": "linux", "Parent": "f0b1f729f784b755e7bf9c8c2e65d8a0a35a533769c2588f02895f6781ac0805", "RepoDigests": [], "RepoTags": [ - "registry:2"], "Size": 0, "VirtualSize": 165808884}] + sample: [ + { + "Architecture": "amd64", + "Author": "", + "Comment": "", + "Config": { + "AttachStderr": false, + "AttachStdin": false, + "AttachStdout": false, + "Cmd": ["/etc/docker/registry/config.yml"], + "Domainname": "", + "Entrypoint": ["/bin/registry"], + "Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"], + "ExposedPorts": {"5000/tcp": {}}, + "Hostname": "e5c68db50333", + "Image": "c72dce2618dc8f7b794d2b2c2b1e64e0205ead5befc294f8111da23bd6a2c799", + "Labels": {}, + "OnBuild": [], + "OpenStdin": false, + "StdinOnce": false, + "Tty": false, + "User": "", + "Volumes": {"/var/lib/registry": {}}, + "WorkingDir": "", + }, + "Container": "e83a452b8fb89d78a25a6739457050131ca5c863629a47639530d9ad2008d610", + "ContainerConfig": { + "AttachStderr": false, + "AttachStdin": false, + "AttachStdout": false, + "Cmd": ["/bin/sh", "-c", '#(nop) CMD ["/etc/docker/registry/config.yml"]'], + "Domainname": "", + "Entrypoint": ["/bin/registry"], + "Env": ["PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"], + "ExposedPorts": {"5000/tcp": {}}, + "Hostname": "e5c68db50333", + "Image": "c72dce2618dc8f7b794d2b2c2b1e64e0205ead5befc294f8111da23bd6a2c799", + "Labels": {}, + "OnBuild": [], + "OpenStdin": false, + "StdinOnce": false, + "Tty": false, + "User": "", + "Volumes": {"/var/lib/registry": {}}, + "WorkingDir": "", + }, + "Created": "2016-03-08T21:08:15.399680378Z", + "DockerVersion": "1.9.1", + "GraphDriver": { + "Data": null, + "Name": "aufs", + }, + "Id": "53773d8552f07b730f3e19979e32499519807d67b344141d965463a950a66e08", + "Name": "registry:2", + "Os": "linux", + "Parent": "f0b1f729f784b755e7bf9c8c2e65d8a0a35a533769c2588f02895f6781ac0805", + "RepoDigests": [], + "RepoTags": ["registry:2"], + "Size": 0, + "VirtualSize": 165808884, + }, + ] """ import traceback diff --git a/plugins/modules/docker_image_load.py b/plugins/modules/docker_image_load.py index 2ce5b314..f8fd3f8c 100644 --- a/plugins/modules/docker_image_load.py +++ b/plugins/modules/docker_image_load.py @@ -52,6 +52,7 @@ seealso: """ EXAMPLES = r""" +--- - name: Load all image(s) from the given tar file community.docker.docker_image_load: path: /path/to/images.tar diff --git a/plugins/modules/docker_image_pull.py b/plugins/modules/docker_image_pull.py index 28d22ba4..2ba98f35 100644 --- a/plugins/modules/docker_image_pull.py +++ b/plugins/modules/docker_image_pull.py @@ -75,6 +75,7 @@ seealso: """ EXAMPLES = r""" +--- - name: Pull an image community.docker.docker_image_pull: name: pacur/centos-7 diff --git a/plugins/modules/docker_image_push.py b/plugins/modules/docker_image_push.py index fee386e9..58b64693 100644 --- a/plugins/modules/docker_image_push.py +++ b/plugins/modules/docker_image_push.py @@ -57,6 +57,7 @@ seealso: """ EXAMPLES = r""" +--- - name: Push an image community.docker.docker_image_push: name: registry.example.com:5000/repo/image diff --git a/plugins/modules/docker_image_remove.py b/plugins/modules/docker_image_remove.py index 428bdb62..815355cf 100644 --- a/plugins/modules/docker_image_remove.py +++ b/plugins/modules/docker_image_remove.py @@ -68,6 +68,7 @@ seealso: """ EXAMPLES = r""" +--- - name: Remove an image community.docker.docker_image_remove: name: pacur/centos-7 diff --git a/plugins/modules/docker_image_tag.py b/plugins/modules/docker_image_tag.py index f8e3747a..5c8fd02b 100644 --- a/plugins/modules/docker_image_tag.py +++ b/plugins/modules/docker_image_tag.py @@ -76,6 +76,7 @@ seealso: """ EXAMPLES = r""" +--- - name: Tag Python 3.12 image with two new names community.docker.docker_image_tag: name: python:3.12 diff --git a/plugins/modules/docker_login.py b/plugins/modules/docker_login.py index d3994f47..714a03c5 100644 --- a/plugins/modules/docker_login.py +++ b/plugins/modules/docker_login.py @@ -85,6 +85,7 @@ author: """ EXAMPLES = r""" +--- - name: Log into DockerHub community.docker.docker_login: username: docker diff --git a/plugins/modules/docker_network.py b/plugins/modules/docker_network.py index f21f23e7..db81a281 100644 --- a/plugins/modules/docker_network.py +++ b/plugins/modules/docker_network.py @@ -203,6 +203,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Create a network community.docker.docker_network: name: network_one diff --git a/plugins/modules/docker_network_info.py b/plugins/modules/docker_network_info.py index 5b01e671..53fca2d1 100644 --- a/plugins/modules/docker_network_info.py +++ b/plugins/modules/docker_network_info.py @@ -40,6 +40,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Get infos on network community.docker.docker_network_info: name: mydata @@ -68,10 +69,32 @@ network: - Will be V(none) if network does not exist. returned: always type: dict - sample: {"Attachable": false, "ConfigFrom": {"Network": ""}, "ConfigOnly": false, "Containers": {}, "Created": "2018-12-07T01:47:51.250835114-06:00", - "Driver": "bridge", "EnableIPv6": false, "IPAM": {"Config": [{"Gateway": "192.168.96.1", "Subnet": "192.168.96.0/20"}], - "Driver": "default", "Options": null}, "Id": "0856968545f22026c41c2c7c3d448319d3b4a6a03a40b148b3ac4031696d1c0a", "Ingress": false, - "Internal": false, "Labels": {}, "Name": "ansible-test-f2700bba", "Options": {}, "Scope": "local"} + sample: { + "Attachable": false, + "ConfigFrom": {"Network": ""}, + "ConfigOnly": false, + "Containers": {}, + "Created": "2018-12-07T01:47:51.250835114-06:00", + "Driver": "bridge", + "EnableIPv6": false, + "IPAM": { + "Config": [ + { + "Gateway": "192.168.96.1", + "Subnet": "192.168.96.0/20", + }, + ], + "Driver": "default", + "Options": null, + }, + "Id": "0856968545f22026c41c2c7c3d448319d3b4a6a03a40b148b3ac4031696d1c0a", + "Ingress": false, + "Internal": false, + "Labels": {}, + "Name": "ansible-test-f2700bba", + "Options": {}, + "Scope": "local", + } """ import traceback diff --git a/plugins/modules/docker_node.py b/plugins/modules/docker_node.py index 917dcbe9..07915120 100644 --- a/plugins/modules/docker_node.py +++ b/plugins/modules/docker_node.py @@ -90,6 +90,7 @@ author: """ EXAMPLES = r""" +--- - name: Set node role community.docker.docker_node: hostname: mynode diff --git a/plugins/modules/docker_node_info.py b/plugins/modules/docker_node_info.py index 29434b16..3e4880d8 100644 --- a/plugins/modules/docker_node_info.py +++ b/plugins/modules/docker_node_info.py @@ -52,6 +52,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Get info on all nodes community.docker.docker_node_info: register: result diff --git a/plugins/modules/docker_plugin.py b/plugins/modules/docker_plugin.py index c116b95a..135ec7dc 100644 --- a/plugins/modules/docker_plugin.py +++ b/plugins/modules/docker_plugin.py @@ -86,6 +86,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Install a plugin community.docker.docker_plugin: plugin_name: plugin_one diff --git a/plugins/modules/docker_prune.py b/plugins/modules/docker_prune.py index bad9c5d8..7522e64e 100644 --- a/plugins/modules/docker_prune.py +++ b/plugins/modules/docker_prune.py @@ -114,6 +114,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Prune containers older than 24h community.docker.docker_prune: containers: true diff --git a/plugins/modules/docker_secret.py b/plugins/modules/docker_secret.py index 78d05a9b..dcb8cbe8 100644 --- a/plugins/modules/docker_secret.py +++ b/plugins/modules/docker_secret.py @@ -103,6 +103,7 @@ author: """ EXAMPLES = r""" +--- - name: Create secret foo (from a file on the control machine) community.docker.docker_secret: name: foo diff --git a/plugins/modules/docker_stack.py b/plugins/modules/docker_stack.py index 6e3accc8..b6521986 100644 --- a/plugins/modules/docker_stack.py +++ b/plugins/modules/docker_stack.py @@ -128,6 +128,7 @@ stack_spec_diff: """ EXAMPLES = r""" +--- - name: Deploy stack from a compose file community.docker.docker_stack: state: present diff --git a/plugins/modules/docker_stack_info.py b/plugins/modules/docker_stack_info.py index 41f7d6c0..7ec2fbad 100644 --- a/plugins/modules/docker_stack_info.py +++ b/plugins/modules/docker_stack_info.py @@ -66,6 +66,7 @@ results: """ EXAMPLES = r""" +--- - name: Shows stack info community.docker.docker_stack_info: register: result diff --git a/plugins/modules/docker_stack_task_info.py b/plugins/modules/docker_stack_task_info.py index a89e074b..150f2a9c 100644 --- a/plugins/modules/docker_stack_task_info.py +++ b/plugins/modules/docker_stack_task_info.py @@ -59,14 +59,21 @@ results: description: - List of dictionaries containing the list of tasks associated to a stack name. sample: - - {"CurrentState": "Running", "DesiredState": "Running", "Error": "", "ID": "7wqv6m02ugkw", "Image": "busybox", "Name": "test_stack.1", - "Node": "swarm", "Ports": ""} + - CurrentState: Running + DesiredState: Running + Error: "" + ID: 7wqv6m02ugkw + Image: busybox + Name: test_stack.1 + Node: swarm + Ports: "" returned: always type: list elements: dict """ EXAMPLES = r""" +--- - name: Shows stack info community.docker.docker_stack_task_info: name: test_stack diff --git a/plugins/modules/docker_swarm.py b/plugins/modules/docker_swarm.py index de316945..202a0cff 100644 --- a/plugins/modules/docker_swarm.py +++ b/plugins/modules/docker_swarm.py @@ -206,6 +206,7 @@ author: """ EXAMPLES = r""" +--- - name: Init a new swarm with default parameters community.docker.docker_swarm: state: present diff --git a/plugins/modules/docker_swarm_info.py b/plugins/modules/docker_swarm_info.py index 6f8b4af2..f87adc29 100644 --- a/plugins/modules/docker_swarm_info.py +++ b/plugins/modules/docker_swarm_info.py @@ -89,6 +89,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Get info on Docker Swarm community.docker.docker_swarm_info: ignore_errors: true diff --git a/plugins/modules/docker_swarm_service.py b/plugins/modules/docker_swarm_service.py index 7a8f75e2..210ebd01 100644 --- a/plugins/modules/docker_swarm_service.py +++ b/plugins/modules/docker_swarm_service.py @@ -694,6 +694,7 @@ rebuilt: """ EXAMPLES = r""" +--- - name: Set command and arguments community.docker.docker_swarm_service: name: myservice diff --git a/plugins/modules/docker_swarm_service_info.py b/plugins/modules/docker_swarm_service_info.py index 66a73f9a..07c79bd9 100644 --- a/plugins/modules/docker_swarm_service_info.py +++ b/plugins/modules/docker_swarm_service_info.py @@ -41,6 +41,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Get info from a service community.docker.docker_swarm_service_info: name: myservice diff --git a/plugins/modules/docker_volume.py b/plugins/modules/docker_volume.py index 7d46688b..ce0db3ce 100644 --- a/plugins/modules/docker_volume.py +++ b/plugins/modules/docker_volume.py @@ -91,6 +91,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Create a volume community.docker.docker_volume: name: volume_one diff --git a/plugins/modules/docker_volume_info.py b/plugins/modules/docker_volume_info.py index 04012b05..145a10fb 100644 --- a/plugins/modules/docker_volume_info.py +++ b/plugins/modules/docker_volume_info.py @@ -38,6 +38,7 @@ requirements: """ EXAMPLES = r""" +--- - name: Get infos on volume community.docker.docker_volume_info: name: mydata diff --git a/tests/integration/requirements.yml b/tests/integration/requirements.yml index b4c045f4..0baadf34 100644 --- a/tests/integration/requirements.yml +++ b/tests/integration/requirements.yml @@ -4,8 +4,8 @@ # SPDX-License-Identifier: GPL-3.0-or-later collections: -- ansible.posix -- community.crypto -- community.general -- community.internal_test_tools -- community.library_inventory_filtering_v1 + - ansible.posix + - community.crypto + - community.general + - community.internal_test_tools + - community.library_inventory_filtering_v1 diff --git a/tests/integration/targets/connection/test_connection.yml b/tests/integration/targets/connection/test_connection.yml index bb0a9939..7f8b5697 100644 --- a/tests/integration/targets/connection/test_connection.yml +++ b/tests/integration/targets/connection/test_connection.yml @@ -8,41 +8,41 @@ serial: 1 tasks: - ### raw with unicode arg and output + ### 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 + - 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 + ### 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" + - 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 + ### 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 + - 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 + ### 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" + - 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: + ### test wait_for_connection plugin + - ansible.builtin.wait_for_connection: diff --git a/tests/integration/targets/docker_compose_v2/tasks/tests/container-exit.yml b/tests/integration/targets/docker_compose_v2/tasks/tests/container-exit.yml index 7cac56e0..53f90e33 100644 --- a/tests/integration/targets/docker_compose_v2/tasks/tests/container-exit.yml +++ b/tests/integration/targets/docker_compose_v2/tasks/tests/container-exit.yml @@ -67,4 +67,4 @@ - present_1.images[0].Tag == (docker_test_image_alpine | split(':') | last) - present_1.warnings | default([]) | select('regex', ' Please report this at ') | length == 0 - >- - ("container " ~ pname ~ '-' ~ cname ~ "-1 exited (0)") in present_1.msg + ("container " ~ pname ~ '-' ~ cname ~ "-1 exited (0)") in present_1.msg diff --git a/tests/integration/targets/docker_config/tasks/test_docker_config.yml b/tests/integration/targets/docker_config/tasks/test_docker_config.yml index 015e8003..98cfec2e 100644 --- a/tests/integration/targets/docker_config/tasks/test_docker_config.yml +++ b/tests/integration/targets/docker_config/tasks/test_docker_config.yml @@ -4,313 +4,131 @@ # SPDX-License-Identifier: GPL-3.0-or-later - block: - - shell: "docker info --format '{% raw %}{{json .}}{% endraw %}' | python -m json.tool" + - 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 + - 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" + - shell: "docker info --format '{% raw %}{{json .}}{% endraw %}' | python -m json.tool" - - name: Create a Swarm cluster - docker_swarm: - name: default - state: present - advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}" - - - name: Parameter name should be required - docker_config: - state: present - ignore_errors: true - register: output - - - name: Assert failure when called with no name - assert: - that: - - 'output is failed' - - 'output.msg == "missing required arguments: name"' - - - name: Test parameters - docker_config: - name: foo - state: present - ignore_errors: true - register: output - - - name: Assert failure when called with no data - assert: - that: - - 'output is failed' - - 'output.msg == "state is present but any of the following are missing: data, data_src"' - - - 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: true - - - 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: - - output is not changed - - - name: Write config into file - copy: - dest: "{{ remote_tmp_dir }}/data" - content: |- - opensesame! - - - name: Create config again (from file) - docker_config: - name: db_password - data_src: "{{ remote_tmp_dir }}/data" - state: present - register: output - - - name: Assert create config is idempotent - assert: - that: - - output is not 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: - - output is not changed - - - name: Update config - docker_config: - name: db_password - data: newpassword! - state: present - register: output - - - name: Assert config was updated - assert: - that: - - output is 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: true - - - name: Assert config was removed - assert: - that: - - output is failed - - - name: Remove config - docker_config: - name: db_password - state: absent - register: output - - - name: Assert remove config is idempotent - assert: - that: - - output is not changed - -# Rolling update - - - name: Create rolling config - docker_config: - name: rolling_password - data: opensesame! - rolling_versions: true - state: present - register: original_output - - - name: Create variable config_id - set_fact: - config_id: "{{ original_output.config_id }}" - - - name: Inspect config - command: "docker config inspect {{ config_id }}" - register: inspect - ignore_errors: true - - - debug: - var: inspect - - - name: Assert config creation succeeded - assert: - that: - - "'rolling_password' in inspect.stdout" - - "'ansible_key' in inspect.stdout" - - "'ansible_version' in inspect.stdout" - - original_output.config_name == 'rolling_password_v1' - 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: rolling_password - data: newpassword! - rolling_versions: true - state: present - register: new_output - - - name: Assert that new version is created - assert: - that: - - new_output is changed - - new_output.config_id != original_output.config_id - - new_output.config_name != original_output.config_name - - new_output.config_name == 'rolling_password_v2' - - - name: Remove rolling configs - docker_config: - name: rolling_password - rolling_versions: true - state: absent - - - name: Check that config is removed - command: "docker config inspect {{ original_output.config_id }}" - register: output - ignore_errors: true - - - name: Assert config was removed - assert: - that: - - output is failed - - - name: Check that config is removed - command: "docker config inspect {{ new_output.config_id }}" - register: output - ignore_errors: true - - - name: Assert config was removed - assert: - that: - - output is failed - -# template_driver tests - - - when: docker_py_version is version('5.0.3', '>=') and docker_api_version is version('1.37', '>=') - block: - - - name: Create regular config - docker_config: - name: db_password - data: opensesame! + - name: Create a Swarm cluster + docker_swarm: + name: default state: present + advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}" - - name: Update config with template_driver + - name: Parameter name should be required docker_config: - name: db_password - data: opensesame! - template_driver: golang - state: present - register: output - - - name: Assert config was updated - assert: - that: - - output is changed - - - name: Invalid template_driver - docker_config: - name: db_password - data: opensesame! - template_driver: "not a template driver" state: present ignore_errors: true register: output - - name: Assert failure when called with invalid template_driver + - name: Assert failure when called with no name assert: that: - - 'output is failed' - - 'output.msg == "value of template_driver must be one of: golang, got: not a template driver"' + - 'output is failed' + - 'output.msg == "missing required arguments: name"' + + - name: Test parameters + docker_config: + name: foo + state: present + ignore_errors: true + register: output + + - name: Assert failure when called with no data + assert: + that: + - 'output is failed' + - 'output.msg == "state is present but any of the following are missing: data, data_src"' + + - 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: true + + - 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! - template_driver: golang state: present register: output - name: Assert create config is idempotent assert: that: - - output is not changed + - output is not changed - # data is the docker swarm's name - - name: Update config with template data + - name: Write config into file + copy: + dest: "{{ remote_tmp_dir }}/data" + content: |- + opensesame! + + - name: Create config again (from file) docker_config: name: db_password - data: "{{ '{{' }} .Service.Name {{ '}}' }}" - template_driver: golang + data_src: "{{ remote_tmp_dir }}/data" state: present register: output - - name: Inspect config - command: "docker config inspect {{ output.config_id }}" - register: inspect - - - name: Show inspection result - debug: - var: inspect - - - name: Assert config creation succeeded + - name: Assert create config is idempotent assert: that: - - "'db_password' in inspect.stdout" - - "'ansible_key' in inspect.stdout" - # According to the API docs, 'Data' is "Base64-url-safe-encoded (RFC 4648) config data." - - "'\"Data\": \"e3sgLlNlcnZpY2UuTmFtZSB9fQ==\"' in inspect.stdout" - - "'Templating' in inspect.stdout" - - "'\"Name\": \"golang\"' in inspect.stdout" + - output is not 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: + - output is not changed + + - name: Update config + docker_config: + name: db_password + data: newpassword! + state: present + register: output + + - name: Assert config was updated + assert: + that: + - output is changed + - output.config_id != config_id - name: Remove config docker_config: @@ -318,7 +136,7 @@ state: absent - name: Check that config is removed - command: "docker config inspect {{ output.config_id }}" + command: "docker config inspect {{ config_id }}" register: output ignore_errors: true @@ -327,8 +145,190 @@ that: - output is failed + - name: Remove config + docker_config: + name: db_password + state: absent + register: output + + - name: Assert remove config is idempotent + assert: + that: + - output is not changed + + # Rolling update + + - name: Create rolling config + docker_config: + name: rolling_password + data: opensesame! + rolling_versions: true + state: present + register: original_output + + - name: Create variable config_id + set_fact: + config_id: "{{ original_output.config_id }}" + + - name: Inspect config + command: "docker config inspect {{ config_id }}" + register: inspect + ignore_errors: true + + - debug: + var: inspect + + - name: Assert config creation succeeded + assert: + that: + - "'rolling_password' in inspect.stdout" + - "'ansible_key' in inspect.stdout" + - "'ansible_version' in inspect.stdout" + - original_output.config_name == 'rolling_password_v1' + 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: rolling_password + data: newpassword! + rolling_versions: true + state: present + register: new_output + + - name: Assert that new version is created + assert: + that: + - new_output is changed + - new_output.config_id != original_output.config_id + - new_output.config_name != original_output.config_name + - new_output.config_name == 'rolling_password_v2' + + - name: Remove rolling configs + docker_config: + name: rolling_password + rolling_versions: true + state: absent + + - name: Check that config is removed + command: "docker config inspect {{ original_output.config_id }}" + register: output + ignore_errors: true + + - name: Assert config was removed + assert: + that: + - output is failed + + - name: Check that config is removed + command: "docker config inspect {{ new_output.config_id }}" + register: output + ignore_errors: true + + - name: Assert config was removed + assert: + that: + - output is failed + + # template_driver tests + + - when: docker_py_version is version('5.0.3', '>=') and docker_api_version is version('1.37', '>=') + block: + + - name: Create regular config + docker_config: + name: db_password + data: opensesame! + state: present + + - name: Update config with template_driver + docker_config: + name: db_password + data: opensesame! + template_driver: golang + state: present + register: output + + - name: Assert config was updated + assert: + that: + - output is changed + + - name: Invalid template_driver + docker_config: + name: db_password + data: opensesame! + template_driver: "not a template driver" + state: present + ignore_errors: true + register: output + + - name: Assert failure when called with invalid template_driver + assert: + that: + - 'output is failed' + - 'output.msg == "value of template_driver must be one of: golang, got: not a template driver"' + + - name: Create config again + docker_config: + name: db_password + data: opensesame! + template_driver: golang + state: present + register: output + + - name: Assert create config is idempotent + assert: + that: + - output is not changed + + # data is the docker swarm's name + - name: Update config with template data + docker_config: + name: db_password + data: "{{ '{{' }} .Service.Name {{ '}}' }}" + template_driver: golang + state: present + register: output + + - name: Inspect config + command: "docker config inspect {{ output.config_id }}" + register: inspect + + - name: Show inspection result + debug: + var: inspect + + - name: Assert config creation succeeded + assert: + that: + - "'db_password' in inspect.stdout" + - "'ansible_key' in inspect.stdout" + # According to the API docs, 'Data' is "Base64-url-safe-encoded (RFC 4648) config data." + - "'\"Data\": \"e3sgLlNlcnZpY2UuTmFtZSB9fQ==\"' in inspect.stdout" + - "'Templating' in inspect.stdout" + - "'\"Name\": \"golang\"' in inspect.stdout" + + - name: Remove config + docker_config: + name: db_password + state: absent + + - name: Check that config is removed + command: "docker config inspect {{ output.config_id }}" + register: output + ignore_errors: true + + - name: Assert config was removed + assert: + that: + - output is failed + always: - - name: Remove a Swarm cluster - docker_swarm: - state: absent - force: true + - name: Remove a Swarm cluster + docker_swarm: + state: absent + force: true diff --git a/tests/integration/targets/docker_container/tasks/tests/comparisons.yml b/tests/integration/targets/docker_container/tasks/tests/comparisons.yml index c37a0c4d..c4b8ec07 100644 --- a/tests/integration/targets/docker_container/tasks/tests/comparisons.yml +++ b/tests/integration/targets/docker_container/tasks/tests/comparisons.yml @@ -56,9 +56,9 @@ - assert: that: - - value_1 is changed - - value_2 is not changed - - value_3 is changed + - value_1 is changed + - value_2 is not changed + - value_3 is changed #################################################################### ## list ############################################################ @@ -71,8 +71,8 @@ name: "{{ cname }}" state: started dns_servers: - - 1.1.1.1 - - 8.8.8.8 + - 1.1.1.1 + - 8.8.8.8 register: list_1 - name: list (change, ignore) @@ -82,7 +82,7 @@ name: "{{ cname }}" state: started dns_servers: - - 9.9.9.9 + - 9.9.9.9 force_kill: true comparisons: dns_servers: ignore @@ -95,7 +95,7 @@ name: "{{ cname }}" state: started dns_servers: - - 9.9.9.9 + - 9.9.9.9 force_kill: true comparisons: dns_servers: strict @@ -110,9 +110,9 @@ - assert: that: - - list_1 is changed - - list_2 is not changed - - list_3 is changed + - list_1 is changed + - list_2 is not changed + - list_3 is changed #################################################################### ## set ############################################################# @@ -125,8 +125,8 @@ name: "{{ cname }}" state: started groups: - - "1010" - - "1011" + - "1010" + - "1011" register: set_1 - name: set (change, ignore) @@ -136,9 +136,9 @@ name: "{{ cname }}" state: started groups: - - "1010" - - "1011" - - "1012" + - "1010" + - "1011" + - "1012" force_kill: true comparisons: groups: ignore @@ -151,9 +151,9 @@ name: "{{ cname }}" state: started groups: - - "1010" - - "1011" - - "1012" + - "1010" + - "1011" + - "1012" force_kill: true comparisons: groups: allow_more_present @@ -166,8 +166,8 @@ name: "{{ cname }}" state: started groups: - - "1010" - - "1012" + - "1010" + - "1012" force_kill: true comparisons: groups: allow_more_present @@ -180,8 +180,8 @@ name: "{{ cname }}" state: started groups: - - "1010" - - "1012" + - "1010" + - "1012" force_kill: true comparisons: groups: strict @@ -196,11 +196,11 @@ - 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_1 is changed + - set_2 is not changed + - set_3 is changed + - set_4 is not changed + - set_5 is changed #################################################################### ## set(dict) ####################################################### @@ -213,8 +213,8 @@ name: "{{ cname }}" state: started devices: - - "/dev/random:/dev/virt-random:rwm" - - "/dev/urandom:/dev/virt-urandom:rwm" + - "/dev/random:/dev/virt-random:rwm" + - "/dev/urandom:/dev/virt-urandom:rwm" register: set_dict_1 - name: set(dict) (change, ignore) @@ -224,9 +224,9 @@ name: "{{ cname }}" state: started devices: - - "/dev/random:/dev/virt-random:rwm" - - "/dev/urandom:/dev/virt-urandom:rwm" - - "/dev/null:/dev/virt-null:rwm" + - "/dev/random:/dev/virt-random:rwm" + - "/dev/urandom:/dev/virt-urandom:rwm" + - "/dev/null:/dev/virt-null:rwm" force_kill: true comparisons: devices: ignore @@ -239,9 +239,9 @@ name: "{{ cname }}" state: started devices: - - "/dev/random:/dev/virt-random:rwm" - - "/dev/urandom:/dev/virt-urandom:rwm" - - "/dev/null:/dev/virt-null:rwm" + - "/dev/random:/dev/virt-random:rwm" + - "/dev/urandom:/dev/virt-urandom:rwm" + - "/dev/null:/dev/virt-null:rwm" force_kill: true comparisons: devices: allow_more_present @@ -254,8 +254,8 @@ name: "{{ cname }}" state: started devices: - - "/dev/random:/dev/virt-random:rwm" - - "/dev/null:/dev/virt-null:rwm" + - "/dev/random:/dev/virt-random:rwm" + - "/dev/null:/dev/virt-null:rwm" force_kill: true comparisons: devices: allow_more_present @@ -268,8 +268,8 @@ name: "{{ cname }}" state: started devices: - - "/dev/random:/dev/virt-random:rwm" - - "/dev/null:/dev/virt-null:rwm" + - "/dev/random:/dev/virt-random:rwm" + - "/dev/null:/dev/virt-null:rwm" force_kill: true comparisons: devices: strict @@ -284,11 +284,11 @@ - 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 + - 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 ############################################################ @@ -372,11 +372,11 @@ - assert: that: - - dict_1 is changed - - dict_2 is not changed - - dict_3 is changed - - dict_4 is not changed - - dict_5 is changed + - dict_1 is changed + - dict_2 is not changed + - dict_3 is changed + - dict_4 is not changed + - dict_5 is changed #################################################################### ## wildcard ######################################################## @@ -460,7 +460,7 @@ - assert: that: - - wildcard_1 is changed - - wildcard_2 is not changed - - wildcard_3 is changed - - wildcard_4 is not changed + - wildcard_1 is changed + - wildcard_2 is not changed + - wildcard_3 is changed + - wildcard_4 is not changed diff --git a/tests/integration/targets/docker_container/tasks/tests/compatibility.yml b/tests/integration/targets/docker_container/tasks/tests/compatibility.yml index 265aacac..9c0dfb58 100644 --- a/tests/integration/targets/docker_container/tasks/tests/compatibility.yml +++ b/tests/integration/targets/docker_container/tasks/tests/compatibility.yml @@ -60,10 +60,10 @@ - assert: that: - - start_1 is changed - - start_2 is changed - - start_3 is not changed - - start_4 is not changed + - start_1 is changed + - start_2 is changed + - start_3 is not changed + - start_4 is not changed #################################################################### ## container_default_behavior: no_defaults ######################### @@ -116,7 +116,7 @@ - assert: that: - - start_1 is changed - - start_2 is changed - - start_3 is not changed - - start_4 is not changed + - start_1 is changed + - start_2 is changed + - start_3 is not changed + - start_4 is not changed diff --git a/tests/integration/targets/docker_container/tasks/tests/image-ids.yml b/tests/integration/targets/docker_container/tasks/tests/image-ids.yml index e905defc..7f88f17a 100644 --- a/tests/integration/targets/docker_container/tasks/tests/image-ids.yml +++ b/tests/integration/targets/docker_container/tasks/tests/image-ids.yml @@ -22,8 +22,8 @@ - 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 }}" + - "{{ docker_test_image_hello_world }}" + - "{{ docker_test_image_alpine }}" register: image_info - assert: diff --git a/tests/integration/targets/docker_container/tasks/tests/mounts-volumes.yml b/tests/integration/targets/docker_container/tasks/tests/mounts-volumes.yml index 3ce6691a..a2308ad9 100644 --- a/tests/integration/targets/docker_container/tasks/tests/mounts-volumes.yml +++ b/tests/integration/targets/docker_container/tasks/tests/mounts-volumes.yml @@ -29,13 +29,13 @@ name: "{{ cname }}" state: started mounts: - - source: /tmp - target: /tmp - type: bind - - source: / - target: /whatever - type: bind - read_only: false + - source: /tmp + target: /tmp + type: bind + - source: / + target: /whatever + type: bind + read_only: false register: mounts_1 - name: mounts (idempotency) @@ -45,13 +45,13 @@ name: "{{ cname }}" state: started mounts: - - source: / - target: /whatever - type: bind - read_only: false - - source: /tmp - target: /tmp - type: bind + - source: / + target: /whatever + type: bind + read_only: false + - source: /tmp + target: /tmp + type: bind register: mounts_2 - name: mounts (less mounts) @@ -61,9 +61,9 @@ name: "{{ cname }}" state: started mounts: - - source: /tmp - target: /tmp - type: bind + - source: /tmp + target: /tmp + type: bind register: mounts_3 - name: mounts (more mounts) @@ -73,13 +73,13 @@ name: "{{ cname }}" state: started mounts: - - source: /tmp - target: /tmp - type: bind - - source: /tmp - target: /somewhereelse - type: bind - read_only: true + - source: /tmp + target: /tmp + type: bind + - source: /tmp + target: /somewhereelse + type: bind + read_only: true force_kill: true register: mounts_4 @@ -90,13 +90,13 @@ name: "{{ cname }}" state: started mounts: - - source: /tmp - target: /tmp - type: bind - - source: /tmp - target: /somewhereelse - type: bind - read_only: false + - source: /tmp + target: /tmp + type: bind + - source: /tmp + target: /somewhereelse + type: bind + read_only: false force_kill: true register: mounts_5 @@ -107,13 +107,13 @@ name: "{{ cname }}" state: started mounts: - - source: /home - target: /x - type: bind - - source: /etc - target: /x - type: bind - read_only: false + - source: /home + target: /x + type: bind + - source: /etc + target: /x + type: bind + read_only: false force_kill: true register: mounts_6 ignore_errors: true @@ -151,15 +151,15 @@ - 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" - - mounts_7 is changed - - mounts_8 is not changed + - 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" + - mounts_7 is changed + - mounts_8 is not changed #################################################################### ## tmpfs ########################################################### @@ -172,14 +172,14 @@ name: "{{ cname }}" state: started mounts: - - target: /cache1 - type: tmpfs - tmpfs_mode: "1777" - tmpfs_size: "1GB" - - target: /cache2 - type: tmpfs - tmpfs_mode: "1777" - tmpfs_size: "1GB" + - target: /cache1 + type: tmpfs + tmpfs_mode: "1777" + tmpfs_size: "1GB" + - target: /cache2 + type: tmpfs + tmpfs_mode: "1777" + tmpfs_size: "1GB" force_kill: true register: tmpfs_1 @@ -190,14 +190,14 @@ name: "{{ cname }}" state: started mounts: - - target: /cache2 - type: tmpfs - tmpfs_mode: "1777" - tmpfs_size: "1GB" - - target: /cache1 - type: tmpfs - tmpfs_mode: "1777" - tmpfs_size: "1GB" + - target: /cache2 + type: tmpfs + tmpfs_mode: "1777" + tmpfs_size: "1GB" + - target: /cache1 + type: tmpfs + tmpfs_mode: "1777" + tmpfs_size: "1GB" force_kill: true register: tmpfs_2 @@ -208,18 +208,18 @@ name: "{{ cname }}" state: started mounts: - - target: /cache1 - type: tmpfs - tmpfs_mode: "1777" - tmpfs_size: "1GB" - - target: /cache2 - type: tmpfs - tmpfs_mode: "1777" - tmpfs_size: "1GB" - - target: /cache3 - type: tmpfs - tmpfs_mode: "1777" - tmpfs_size: "1GB" + - target: /cache1 + type: tmpfs + tmpfs_mode: "1777" + tmpfs_size: "1GB" + - target: /cache2 + type: tmpfs + tmpfs_mode: "1777" + tmpfs_size: "1GB" + - target: /cache3 + type: tmpfs + tmpfs_mode: "1777" + tmpfs_size: "1GB" force_kill: true register: tmpfs_3 @@ -230,10 +230,10 @@ name: "{{ cname }}" state: started mounts: - - target: /cache1 - type: tmpfs - tmpfs_mode: "1700" - tmpfs_size: "1GB" + - target: /cache1 + type: tmpfs + tmpfs_mode: "1700" + tmpfs_size: "1GB" force_kill: true register: tmpfs_4 @@ -244,10 +244,10 @@ name: "{{ cname }}" state: started mounts: - - target: /cache1 - type: tmpfs - tmpfs_mode: "1700" - tmpfs_size: "2GB" + - target: /cache1 + type: tmpfs + tmpfs_mode: "1700" + tmpfs_size: "2GB" force_kill: true register: tmpfs_5 @@ -260,11 +260,11 @@ - assert: that: - - tmpfs_1 is changed - - tmpfs_2 is not changed - - tmpfs_3 is changed - - tmpfs_4 is changed - - tmpfs_5 is changed + - tmpfs_1 is changed + - tmpfs_2 is not changed + - tmpfs_3 is changed + - tmpfs_4 is changed + - tmpfs_5 is changed #################################################################### ## mounts + volumes ################################################ @@ -277,12 +277,12 @@ name: "{{ cname }}" state: started mounts: - - source: / - target: /whatever - type: bind - read_only: true + - source: / + target: /whatever + type: bind + read_only: true volumes: - - /tmp:/tmp + - /tmp:/tmp register: mounts_volumes_1 - name: mounts + volumes (idempotency) @@ -292,12 +292,12 @@ name: "{{ cname }}" state: started mounts: - - source: / - target: /whatever - type: bind - read_only: true + - source: / + target: /whatever + type: bind + read_only: true volumes: - - /tmp:/tmp + - /tmp:/tmp register: mounts_volumes_2 - name: mounts + volumes (switching) @@ -307,12 +307,12 @@ name: "{{ cname }}" state: started mounts: - - source: /tmp - target: /tmp - type: bind - read_only: false + - source: /tmp + target: /tmp + type: bind + read_only: false volumes: - - /:/whatever:ro + - /:/whatever:ro force_kill: true register: mounts_volumes_3 @@ -323,12 +323,12 @@ name: "{{ cname }}" state: started mounts: - - source: /tmp - target: /tmp - type: bind - read_only: false + - source: /tmp + target: /tmp + type: bind + read_only: false volumes: - - /tmp:/tmp + - /tmp:/tmp force_kill: true register: mounts_volumes_4 ignore_errors: true @@ -342,11 +342,11 @@ - 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" + - 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" #################################################################### ## volume_driver ################################################### @@ -389,9 +389,9 @@ - assert: that: - - volume_driver_1 is changed - - volume_driver_2 is not changed - - volume_driver_3 is changed + - volume_driver_1 is changed + - volume_driver_2 is not changed + - volume_driver_3 is changed #################################################################### ## volumes ######################################################### @@ -404,9 +404,9 @@ name: "{{ cname }}" state: started volumes: - - "/tmp:/tmp" - - "/:/whatever:rw,z" - - "/anon:rw" + - "/tmp:/tmp" + - "/:/whatever:rw,z" + - "/anon:rw" register: volumes_1 - name: volumes (idempotency) @@ -416,9 +416,9 @@ name: "{{ cname }}" state: started volumes: - - "/:/whatever:rw,z" - - "/tmp:/tmp" - - "/anon:rw" + - "/:/whatever:rw,z" + - "/tmp:/tmp" + - "/anon:rw" register: volumes_2 - name: volumes (less volumes) @@ -428,7 +428,7 @@ name: "{{ cname }}" state: started volumes: - - "/tmp:/tmp" + - "/tmp:/tmp" register: volumes_3 - name: volumes (more volumes) @@ -438,8 +438,8 @@ name: "{{ cname }}" state: started volumes: - - "/tmp:/tmp" - - "/tmp:/somewhereelse:ro,Z" + - "/tmp:/tmp" + - "/tmp:/somewhereelse:ro,Z" force_kill: true register: volumes_4 @@ -450,8 +450,8 @@ name: "{{ cname }}" state: started volumes: - - "/tmp:/tmp" - - "/tmp:/somewhereelse:ro" + - "/tmp:/tmp" + - "/tmp:/somewhereelse:ro" force_kill: true register: volumes_5 @@ -462,8 +462,8 @@ name: "{{ cname }}" state: started volumes: - - "/etc:/tmp" - - "/home:/tmp:ro" + - "/etc:/tmp" + - "/home:/tmp:ro" force_kill: true register: volumes_6 ignore_errors: true @@ -477,16 +477,16 @@ - 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_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 #################################################### @@ -499,10 +499,10 @@ name: "{{ container_name }}" state: started volumes: - - "{{ '/tmp:/tmp' if container_name == cname_h1 else '/:/whatever:ro' }}" + - "{{ '/tmp:/tmp' if container_name == cname_h1 else '/:/whatever:ro' }}" loop: - - "{{ cname_h1 }}" - - "{{ cname_h2 }}" + - "{{ cname_h1 }}" + - "{{ cname_h2 }}" loop_control: loop_var: container_name @@ -540,18 +540,18 @@ state: absent force_kill: true loop: - - "{{ cname }}" - - "{{ cname_h1 }}" - - "{{ cname_h2 }}" + - "{{ cname }}" + - "{{ cname_h1 }}" + - "{{ cname_h2 }}" loop_control: loop_var: container_name diff: false - assert: that: - - volumes_from_1 is changed - - volumes_from_2 is not changed - - volumes_from_3 is changed + - volumes_from_1 is changed + - volumes_from_2 is not changed + - volumes_from_3 is changed #################################################################### #################################################################### diff --git a/tests/integration/targets/docker_container/tasks/tests/network.yml b/tests/integration/targets/docker_container/tasks/tests/network.yml index e731ec47..78d761ed 100644 --- a/tests/integration/targets/docker_container/tasks/tests/network.yml +++ b/tests/integration/targets/docker_container/tasks/tests/network.yml @@ -20,8 +20,8 @@ name: "{{ network_name }}" state: present loop: - - "{{ nname_1 }}" - - "{{ nname_2 }}" + - "{{ nname_1 }}" + - "{{ nname_2 }}" loop_control: loop_var: network_name @@ -126,24 +126,24 @@ state: absent force_kill: true loop: - - "{{ cname }}" - - "{{ cname_h1 }}" + - "{{ cname }}" + - "{{ cname_h1 }}" loop_control: loop_var: container_name diff: false - 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) + - 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 ######### @@ -156,8 +156,8 @@ name: "{{ cname }}" state: started networks: - - name: "{{ nname_1 }}" - - name: "{{ nname_2 }}" + - name: "{{ nname_1 }}" + - name: "{{ nname_2 }}" networks_cli_compatible: false register: networks_1 @@ -168,8 +168,8 @@ name: "{{ cname }}" state: started networks: - - name: "{{ nname_1 }}" - - name: "{{ nname_2 }}" + - name: "{{ nname_1 }}" + - name: "{{ nname_2 }}" networks_cli_compatible: false register: networks_2 @@ -182,8 +182,8 @@ comparisons: networks: strict networks: - - name: bridge - - name: "{{ nname_1 }}" + - name: bridge + - name: "{{ nname_1 }}" networks_cli_compatible: false force_kill: true register: networks_3 @@ -197,8 +197,8 @@ comparisons: networks: strict networks: - - name: "{{ nname_1 }}" - - name: bridge + - name: "{{ nname_1 }}" + - name: bridge networks_cli_compatible: false register: networks_4 @@ -209,7 +209,7 @@ name: "{{ cname }}" state: started networks: - - name: bridge + - name: bridge networks_cli_compatible: false register: networks_5 @@ -222,7 +222,7 @@ comparisons: networks: strict networks: - - name: bridge + - name: bridge networks_cli_compatible: false force_kill: true register: networks_6 @@ -236,8 +236,8 @@ comparisons: networks: strict networks: - - name: bridge - - name: "{{ nname_2 }}" + - name: bridge + - name: "{{ nname_2 }}" networks_cli_compatible: false force_kill: true register: networks_7 @@ -251,42 +251,42 @@ - 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" + # 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" #################################################################### ## networks for networks_cli_compatible=yes ######################## @@ -299,11 +299,11 @@ name: "{{ cname }}" state: started networks: - - name: "{{ nname_1 }}" - aliases: - - alias1 - - alias2 - - name: "{{ nname_2 }}" + - name: "{{ nname_1 }}" + aliases: + - alias1 + - alias2 + - name: "{{ nname_2 }}" networks_cli_compatible: true register: networks_1 @@ -314,8 +314,8 @@ name: "{{ cname }}" state: started networks: - - name: "{{ nname_1 }}" - - name: "{{ nname_2 }}" + - name: "{{ nname_1 }}" + - name: "{{ nname_2 }}" networks_cli_compatible: true register: networks_2 @@ -409,38 +409,38 @@ - 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 + # 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 #################################################################### ## networks with comparisons ####################################### @@ -453,7 +453,7 @@ name: "{{ cname }}" state: started networks: - - name: "{{ nname_1 }}" + - name: "{{ nname_1 }}" networks_cli_compatible: true register: networks_1 @@ -464,7 +464,7 @@ name: "{{ cname }}" state: started networks: - - name: "{{ nname_2 }}" + - name: "{{ nname_2 }}" networks_cli_compatible: true comparisons: network_mode: ignore # otherwise we'd have to set network_mode to nname_1 @@ -502,7 +502,7 @@ name: "{{ cname }}" state: started networks: - - name: "{{ nname_2 }}" + - name: "{{ nname_2 }}" networks_cli_compatible: true comparisons: network_mode: ignore # otherwise we'd have to set network_mode to nname_1 @@ -517,7 +517,7 @@ name: "{{ cname }}" state: started networks: - - name: "{{ nname_2 }}" + - name: "{{ nname_2 }}" networks_cli_compatible: true comparisons: networks: strict @@ -546,34 +546,34 @@ - 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 + # 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 #################################################################### ## networks with IP address ######################################## @@ -586,9 +586,9 @@ name: "{{ cname }}" state: stopped networks: - - name: "{{ nname_3 }}" - ipv4_address: "{{ nname_3_ipv4_2 }}" - ipv6_address: "{{ nname_3_ipv6_2 }}" + - name: "{{ nname_3 }}" + ipv4_address: "{{ nname_3_ipv4_2 }}" + ipv6_address: "{{ nname_3_ipv6_2 }}" networks_cli_compatible: true register: networks_1 @@ -599,9 +599,9 @@ name: "{{ cname }}" state: stopped networks: - - name: "{{ nname_3 }}" - ipv4_address: "{{ nname_3_ipv4_2 }}" - ipv6_address: "{{ nname_3_ipv6_2 }}" + - name: "{{ nname_3 }}" + ipv4_address: "{{ nname_3_ipv4_2 }}" + ipv6_address: "{{ nname_3_ipv6_2 }}" networks_cli_compatible: true register: networks_2 @@ -612,9 +612,9 @@ name: "{{ cname }}" state: stopped networks: - - name: "{{ nname_3 }}" - ipv4_address: "{{ nname_3_ipv4_3 }}" - ipv6_address: "{{ nname_3_ipv6_2 }}" + - name: "{{ nname_3 }}" + ipv4_address: "{{ nname_3_ipv4_3 }}" + ipv6_address: "{{ nname_3_ipv6_2 }}" networks_cli_compatible: true register: networks_3 @@ -625,9 +625,9 @@ name: "{{ cname }}" state: stopped networks: - - name: "{{ nname_3 }}" - ipv4_address: "{{ nname_3_ipv4_3 }}" - ipv6_address: "{{ nname_3_ipv6_3 }}" + - name: "{{ nname_3 }}" + ipv4_address: "{{ nname_3_ipv4_3 }}" + ipv6_address: "{{ nname_3_ipv6_3 }}" networks_cli_compatible: true register: networks_4 @@ -644,9 +644,9 @@ name: "{{ cname }}" state: started networks: - - name: "{{ nname_3 }}" - ipv4_address: "{{ nname_3_ipv4_4 }}" - ipv6_address: "{{ nname_3_ipv6_3 }}" + - name: "{{ nname_3 }}" + ipv4_address: "{{ nname_3_ipv4_4 }}" + ipv6_address: "{{ nname_3_ipv6_3 }}" networks_cli_compatible: true force_kill: true register: networks_6 @@ -658,9 +658,9 @@ name: "{{ cname }}" state: started networks: - - name: "{{ nname_3 }}" - ipv4_address: "{{ nname_3_ipv4_4 }}" - ipv6_address: "{{ nname_3_ipv6_4 }}" + - name: "{{ nname_3 }}" + ipv4_address: "{{ nname_3_ipv4_4 }}" + ipv6_address: "{{ nname_3_ipv6_4 }}" networks_cli_compatible: true force_kill: true register: networks_7 @@ -672,9 +672,9 @@ name: "{{ cname }}" state: started networks: - - name: "{{ nname_3 }}" - ipv4_address: "{{ nname_3_ipv4_4 }}" - ipv6_address: "{{ nname_3_ipv6_4 }}" + - name: "{{ nname_3 }}" + ipv4_address: "{{ nname_3_ipv4_4 }}" + ipv6_address: "{{ nname_3_ipv6_4 }}" networks_cli_compatible: true register: networks_8 @@ -687,46 +687,46 @@ - 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 + - 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 #################################################################### #################################################################### @@ -738,8 +738,8 @@ state: absent force: true loop: - - "{{ nname_1 }}" - - "{{ nname_2 }}" - - "{{ nname_3 }}" + - "{{ nname_1 }}" + - "{{ nname_2 }}" + - "{{ nname_3 }}" loop_control: loop_var: network_name diff --git a/tests/integration/targets/docker_container/tasks/tests/options.yml b/tests/integration/targets/docker_container/tasks/tests/options.yml index 0c1223c1..e3608b83 100644 --- a/tests/integration/targets/docker_container/tasks/tests/options.yml +++ b/tests/integration/targets/docker_container/tasks/tests/options.yml @@ -38,8 +38,8 @@ - assert: that: - - auto_remove_1 is changed - - auto_remove_2 is not changed + - auto_remove_1 is changed + - auto_remove_2 is not changed #################################################################### ## blkio_weight #################################################### @@ -86,17 +86,17 @@ - when: blkio_weight_1 is failed assert: that: - - "'setting cgroup config for procHooks process caused: failed to write' in blkio_weight_1.msg" + - "'setting cgroup config for procHooks process caused: failed to write' in blkio_weight_1.msg" - when: blkio_weight_1 is not failed assert: that: - - blkio_weight_1 is changed - - blkio_weight_2 is not failed - - >- - 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 | default([]))) - - blkio_weight_3 is not failed - - blkio_weight_3 is changed + - blkio_weight_1 is changed + - blkio_weight_2 is not failed + - >- + 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 | default([]))) + - blkio_weight_3 is not failed + - blkio_weight_3 is changed #################################################################### ## cap_drop, capabilities ########################################## @@ -109,9 +109,9 @@ name: "{{ cname }}" state: started capabilities: - - sys_time + - sys_time cap_drop: - - all + - all register: capabilities_1 - name: capabilities, cap_drop (idempotency) @@ -121,9 +121,9 @@ name: "{{ cname }}" state: started capabilities: - - sys_time + - sys_time cap_drop: - - all + - all register: capabilities_2 - name: capabilities, cap_drop (less) @@ -134,7 +134,7 @@ state: started capabilities: [] cap_drop: - - all + - all register: capabilities_3 - name: capabilities, cap_drop (changed) @@ -144,9 +144,9 @@ name: "{{ cname }}" state: started capabilities: - - setgid + - setgid cap_drop: - - all + - all force_kill: true register: capabilities_4 @@ -159,10 +159,10 @@ - assert: that: - - capabilities_1 is changed - - capabilities_2 is not changed - - capabilities_3 is not changed - - capabilities_4 is changed + - capabilities_1 is changed + - capabilities_2 is not changed + - capabilities_3 is not changed + - capabilities_4 is changed #################################################################### ## cgroupns_mode ################################################### @@ -207,23 +207,23 @@ - assert: that: - - cgroupns_mode_1 is changed - - cgroupns_mode_2 is not changed and cgroupns_mode_2 is not failed - - >- - cgroupns_mode_3 is changed or - ('Docker warning: Your kernel does not support cgroup namespaces. Cgroup namespace setting discarded.' in (cgroupns_mode_3.warnings | default([]))) or - (cgroupns_mode_3 is failed and 'error mounting "cgroup" to rootfs at "/sys/fs/cgroup"' in cgroupns_mode_3.msg) + - cgroupns_mode_1 is changed + - cgroupns_mode_2 is not changed and cgroupns_mode_2 is not failed + - >- + cgroupns_mode_3 is changed or + ('Docker warning: Your kernel does not support cgroup namespaces. Cgroup namespace setting discarded.' in (cgroupns_mode_3.warnings | default([]))) or + (cgroupns_mode_3 is failed and 'error mounting "cgroup" to rootfs at "/sys/fs/cgroup"' in cgroupns_mode_3.msg) when: docker_api_version is version('1.41', '>=') and cgroupns_mode_1 is not failed - assert: that: - - >- - 'error mounting "cgroup" to rootfs at "/sys/fs/cgroup"' in cgroupns_mode_1.msg + - >- + 'error mounting "cgroup" to rootfs at "/sys/fs/cgroup"' in cgroupns_mode_1.msg when: docker_api_version is version('1.41', '>=') and cgroupns_mode_1 is failed - assert: that: - - cgroupns_mode_1 is failed - - | - ('API version is ' ~ docker_api_version ~ '.') in cgroupns_mode_1.msg and 'Minimum version required is 1.41 ' in cgroupns_mode_1.msg + - cgroupns_mode_1 is failed + - | + ('API version is ' ~ docker_api_version ~ '.') in cgroupns_mode_1.msg and 'Minimum version required is 1.41 ' in cgroupns_mode_1.msg when: docker_api_version is version('1.41', '<') #################################################################### @@ -257,8 +257,8 @@ - assert: that: - - cgroup_parent_1 is changed - - cgroup_parent_2 is not changed + - cgroup_parent_1 is changed + - cgroup_parent_2 is not changed #################################################################### ## command ######################################################### @@ -326,11 +326,11 @@ - assert: that: - - command_1 is changed - - command_2 is not changed - - command_3 is not changed - - command_4 is changed - - command_5 is not changed + - command_1 is changed + - command_2 is not changed + - command_3 is not changed + - command_4 is changed + - command_5 is not changed # new @@ -394,11 +394,11 @@ - assert: that: - - command_1 is changed - - command_2 is not changed - - command_3 is not changed - - command_4 is changed - - command_5 is changed + - command_1 is changed + - command_2 is not changed + - command_3 is not changed + - command_4 is changed + - command_5 is changed #################################################################### ## cpu_period ###################################################### @@ -441,9 +441,9 @@ - assert: that: - - cpu_period_1 is changed - - cpu_period_2 is not changed - - cpu_period_3 is changed + - cpu_period_1 is changed + - cpu_period_2 is not changed + - cpu_period_3 is changed #################################################################### ## cpu_quota ####################################################### @@ -486,9 +486,9 @@ - assert: that: - - cpu_quota_1 is changed - - cpu_quota_2 is not changed - - cpu_quota_3 is changed + - cpu_quota_1 is changed + - cpu_quota_2 is not changed + - cpu_quota_3 is changed #################################################################### ## cpu_shares ###################################################### @@ -531,9 +531,9 @@ - assert: that: - - cpu_shares_1 is changed - - cpu_shares_2 is not changed - - cpu_shares_3 is changed + - cpu_shares_1 is changed + - cpu_shares_2 is not changed + - cpu_shares_3 is changed #################################################################### ## cpuset_cpus ##################################################### @@ -579,9 +579,9 @@ - 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_cpus_1 is changed + - cpuset_cpus_2 is not changed + - cpuset_cpus_3 is failed or cpuset_cpus_3 is changed #################################################################### ## cpuset_mems ##################################################### @@ -627,9 +627,9 @@ - assert: that: - - cpuset_mems_1 is changed - - cpuset_mems_2 is not changed - - cpuset_mems_3 is failed or cpuset_mems_3 is changed + - cpuset_mems_1 is changed + - cpuset_mems_2 is not changed + - cpuset_mems_3 is failed or cpuset_mems_3 is changed #################################################################### ## cpus ############################################################ @@ -674,9 +674,9 @@ - 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 + - cpus_1 is changed + - cpus_2 is not changed and cpus_2 is not failed + - cpus_3 is failed or cpus_3 is changed #################################################################### ## debug ########################################################### @@ -717,10 +717,10 @@ - assert: that: - - debug_1 is changed - - debug_2 is changed - - debug_3 is changed - - debug_4 is changed + - debug_1 is changed + - debug_2 is changed + - debug_3 is changed + - debug_4 is changed #################################################################### ## detach, cleanup ################################################# @@ -784,24 +784,24 @@ - 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 - - detach_cleanup_nonzero is failed - - detach_cleanup_nonzero.status == 42 - - "'Output' in detach_cleanup_nonzero.container" - - "detach_cleanup_nonzero.container.Output == ''" - - "'Cannot retrieve result as auto_remove is enabled' == detach_auto_remove.container.Output" - - detach_auto_remove_cleanup is not changed + # 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 + - detach_cleanup_nonzero is failed + - detach_cleanup_nonzero.status == 42 + - "'Output' in detach_cleanup_nonzero.container" + - "detach_cleanup_nonzero.container.Output == ''" + - "'Cannot retrieve result as auto_remove is enabled' == detach_auto_remove.container.Output" + - detach_auto_remove_cleanup is not changed #################################################################### ## devices ######################################################### @@ -814,8 +814,8 @@ name: "{{ cname }}" state: started devices: - - "/dev/random:/dev/virt-random:rwm" - - "/dev/urandom:/dev/virt-urandom:rwm" + - "/dev/random:/dev/virt-random:rwm" + - "/dev/urandom:/dev/virt-urandom:rwm" register: devices_1 - name: devices (idempotency) @@ -825,8 +825,8 @@ name: "{{ cname }}" state: started devices: - - "/dev/urandom:/dev/virt-urandom:rwm" - - "/dev/random:/dev/virt-random:rwm" + - "/dev/urandom:/dev/virt-urandom:rwm" + - "/dev/random:/dev/virt-random:rwm" register: devices_2 - name: devices (less) @@ -836,7 +836,7 @@ name: "{{ cname }}" state: started devices: - - "/dev/random:/dev/virt-random:rwm" + - "/dev/random:/dev/virt-random:rwm" register: devices_3 - name: devices (changed) @@ -846,8 +846,8 @@ name: "{{ cname }}" state: started devices: - - "/dev/random:/dev/virt-random:rwm" - - "/dev/null:/dev/virt-null:rwm" + - "/dev/random:/dev/virt-random:rwm" + - "/dev/null:/dev/virt-null:rwm" force_kill: true register: devices_4 @@ -860,10 +860,10 @@ - assert: that: - - devices_1 is changed - - devices_2 is not changed - - devices_3 is not changed - - devices_4 is changed + - devices_1 is changed + - devices_2 is not changed + - devices_3 is not changed + - devices_4 is changed #################################################################### ## device_read_bps ################################################# @@ -934,19 +934,19 @@ - when: device_read_bps_1 is not failed assert: that: - - device_read_bps_1 is not failed - - device_read_bps_1 is changed - - device_read_bps_2 is not failed - - device_read_bps_2 is not changed - - device_read_bps_3 is not failed - - device_read_bps_3 is not changed - - device_read_bps_4 is not failed - - device_read_bps_4 is changed + - device_read_bps_1 is not failed + - device_read_bps_1 is changed + - device_read_bps_2 is not failed + - device_read_bps_2 is not changed + - device_read_bps_3 is not failed + - device_read_bps_3 is not changed + - device_read_bps_4 is not failed + - device_read_bps_4 is changed - when: device_read_bps_1 is failed assert: that: - - "'error setting cgroup config for procHooks process' in device_read_bps_1.msg and 'blkio.throttle.read_bps_device: no such device' in device_read_bps_1.msg" + - "'error setting cgroup config for procHooks process' in device_read_bps_1.msg and 'blkio.throttle.read_bps_device: no such device' in device_read_bps_1.msg" #################################################################### ## device_read_iops ################################################ @@ -1017,19 +1017,19 @@ - when: device_read_iops_1 is not failed assert: that: - - device_read_iops_1 is not failed - - device_read_iops_1 is changed - - device_read_iops_2 is not failed - - device_read_iops_2 is not changed - - device_read_iops_3 is not failed - - device_read_iops_3 is not changed - - device_read_iops_4 is not failed - - device_read_iops_4 is changed + - device_read_iops_1 is not failed + - device_read_iops_1 is changed + - device_read_iops_2 is not failed + - device_read_iops_2 is not changed + - device_read_iops_3 is not failed + - device_read_iops_3 is not changed + - device_read_iops_4 is not failed + - device_read_iops_4 is changed - when: device_read_iops_1 is failed assert: that: - - "'error setting cgroup config for procHooks process' in device_read_iops_1.msg and 'blkio.throttle.read_iops_device: no such device' in device_read_iops_1.msg" + - "'error setting cgroup config for procHooks process' in device_read_iops_1.msg and 'blkio.throttle.read_iops_device: no such device' in device_read_iops_1.msg" #################################################################### ## device_write_bps and device_write_iops ########################## @@ -1091,15 +1091,15 @@ - when: device_write_limit_1 is not failed assert: that: - - device_write_limit_1 is not failed and device_write_limit_2 is not failed and device_write_limit_3 is not failed - - device_write_limit_1 is changed - - device_write_limit_2 is not changed - - device_write_limit_3 is changed + - device_write_limit_1 is not failed and device_write_limit_2 is not failed and device_write_limit_3 is not failed + - device_write_limit_1 is changed + - device_write_limit_2 is not changed + - device_write_limit_3 is changed - when: device_write_limit_1 is failed assert: that: - - "'error setting cgroup config for procHooks process' in device_write_limit_1.msg and 'blkio.throttle.write_bps_device: no such device' in device_write_limit_1.msg" + - "'error setting cgroup config for procHooks process' in device_write_limit_1.msg and 'blkio.throttle.write_bps_device: no such device' in device_write_limit_1.msg" #################################################################### ## device_requests ################################################# @@ -1134,14 +1134,14 @@ - assert: that: - - device_requests_1 is changed - - device_requests_2 is not changed + - device_requests_1 is changed + - device_requests_2 is not changed when: docker_api_version is version('1.40', '>=') - assert: that: - - device_requests_1 is failed - - | - ('API version is ' ~ docker_api_version ~ '.') in device_requests_1.msg and 'Minimum version required is 1.40 ' in device_requests_1.msg + - device_requests_1 is failed + - | + ('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_api_version is version('1.40', '<') #################################################################### @@ -1156,7 +1156,7 @@ state: started force_kill: true device_cgroup_rules: - - "c 42:* rmw" + - "c 42:* rmw" register: device_cgroup_rules_1 ignore_errors: true @@ -1168,7 +1168,7 @@ state: started force_kill: true device_cgroup_rules: - - "c 42:* rmw" + - "c 42:* rmw" register: device_cgroup_rules_2 ignore_errors: true @@ -1180,7 +1180,7 @@ state: started force_kill: true device_cgroup_rules: - - "c 189:* rmw" + - "c 189:* rmw" register: device_cgroup_rules_3 ignore_errors: true @@ -1193,15 +1193,15 @@ - assert: that: - - device_cgroup_rules_1 is changed - - device_cgroup_rules_2 is not changed - - device_cgroup_rules_3 is changed + - device_cgroup_rules_1 is changed + - device_cgroup_rules_2 is not changed + - device_cgroup_rules_3 is changed when: docker_api_version is version('1.28', '>=') - assert: that: - - device_cgroup_rules_1 is failed - - | - ('API version is ' ~ docker_api_version ~ '.') in device_cgroup_rules_1.msg and 'Minimum version required is 1.28 ' in device_cgroup_rules_1.msg + - device_cgroup_rules_1 is failed + - | + ('API version is ' ~ docker_api_version ~ '.') in device_cgroup_rules_1.msg and 'Minimum version required is 1.28 ' in device_cgroup_rules_1.msg when: docker_api_version is version('1.28', '<') #################################################################### @@ -1215,8 +1215,8 @@ name: "{{ cname }}" state: started dns_opts: - - "timeout:10" - - rotate + - "timeout:10" + - rotate register: dns_opts_1 - name: dns_opts (idempotency) @@ -1226,8 +1226,8 @@ name: "{{ cname }}" state: started dns_opts: - - rotate - - "timeout:10" + - rotate + - "timeout:10" register: dns_opts_2 - name: dns_opts (less resolv.conf options) @@ -1237,7 +1237,7 @@ name: "{{ cname }}" state: started dns_opts: - - "timeout:10" + - "timeout:10" register: dns_opts_3 - name: dns_opts (more resolv.conf options) @@ -1247,8 +1247,8 @@ name: "{{ cname }}" state: started dns_opts: - - "timeout:10" - - no-check-names + - "timeout:10" + - no-check-names force_kill: true register: dns_opts_4 @@ -1261,10 +1261,10 @@ - assert: that: - - dns_opts_1 is changed - - dns_opts_2 is not changed - - dns_opts_3 is not changed - - dns_opts_4 is changed + - dns_opts_1 is changed + - dns_opts_2 is not changed + - dns_opts_3 is not changed + - dns_opts_4 is changed #################################################################### ## dns_search_domains ############################################## @@ -1277,8 +1277,8 @@ name: "{{ cname }}" state: started dns_search_domains: - - example.com - - example.org + - example.com + - example.org register: dns_search_domains_1 - name: dns_search_domains (idempotency) @@ -1288,8 +1288,8 @@ name: "{{ cname }}" state: started dns_search_domains: - - example.com - - example.org + - example.com + - example.org register: dns_search_domains_2 - name: dns_search_domains (different order) @@ -1299,8 +1299,8 @@ name: "{{ cname }}" state: started dns_search_domains: - - example.org - - example.com + - example.org + - example.com force_kill: true register: dns_search_domains_3 @@ -1311,8 +1311,8 @@ name: "{{ cname }}" state: started dns_search_domains: - - ansible.com - - example.com + - ansible.com + - example.com force_kill: true register: dns_search_domains_4 @@ -1325,10 +1325,10 @@ - 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_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 ##################################################### @@ -1341,8 +1341,8 @@ name: "{{ cname }}" state: started dns_servers: - - 1.1.1.1 - - 8.8.8.8 + - 1.1.1.1 + - 8.8.8.8 register: dns_servers_1 - name: dns_servers (idempotency) @@ -1352,8 +1352,8 @@ name: "{{ cname }}" state: started dns_servers: - - 1.1.1.1 - - 8.8.8.8 + - 1.1.1.1 + - 8.8.8.8 register: dns_servers_2 - name: dns_servers (changed order) @@ -1363,8 +1363,8 @@ name: "{{ cname }}" state: started dns_servers: - - 8.8.8.8 - - 1.1.1.1 + - 8.8.8.8 + - 1.1.1.1 force_kill: true register: dns_servers_3 @@ -1375,8 +1375,8 @@ name: "{{ cname }}" state: started dns_servers: - - 8.8.8.8 - - 9.9.9.9 + - 8.8.8.8 + - 9.9.9.9 force_kill: true register: dns_servers_4 @@ -1389,10 +1389,10 @@ - assert: that: - - dns_servers_1 is changed - - dns_servers_2 is not changed - - dns_servers_3 is changed - - dns_servers_4 is changed + - dns_servers_1 is changed + - dns_servers_2 is not changed + - dns_servers_3 is changed + - dns_servers_4 is changed #################################################################### ## domainname ###################################################### @@ -1435,9 +1435,9 @@ - assert: that: - - domainname_1 is changed - - domainname_2 is not changed - - domainname_3 is changed + - domainname_1 is changed + - domainname_2 is not changed + - domainname_3 is changed #################################################################### ## entrypoint ###################################################### @@ -1450,10 +1450,10 @@ image: "{{ docker_test_image_alpine }}" command_handling: compatibility entrypoint: - - /bin/sh - - "-v" - - "-c" - - "'sleep 10m'" + - /bin/sh + - "-v" + - "-c" + - "'sleep 10m'" name: "{{ cname }}" state: started register: entrypoint_1 @@ -1463,10 +1463,10 @@ image: "{{ docker_test_image_alpine }}" command_handling: compatibility entrypoint: - - /bin/sh - - "-v" - - "-c" - - "'sleep 10m'" + - /bin/sh + - "-v" + - "-c" + - "'sleep 10m'" name: "{{ cname }}" state: started register: entrypoint_2 @@ -1476,10 +1476,10 @@ image: "{{ docker_test_image_alpine }}" command_handling: compatibility entrypoint: - - /bin/sh - - "-c" - - "'sleep 10m'" - - "-v" + - /bin/sh + - "-c" + - "'sleep 10m'" + - "-v" name: "{{ cname }}" state: started force_kill: true @@ -1490,9 +1490,9 @@ image: "{{ docker_test_image_alpine }}" command_handling: compatibility entrypoint: - - /bin/sh - - "-c" - - "'sleep 10m'" + - /bin/sh + - "-c" + - "'sleep 10m'" name: "{{ cname }}" state: started force_kill: true @@ -1503,9 +1503,9 @@ image: "{{ docker_test_image_alpine }}" command_handling: compatibility entrypoint: - - /bin/sh - - "-c" - - "'sleep 5m'" + - /bin/sh + - "-c" + - "'sleep 5m'" name: "{{ cname }}" state: started force_kill: true @@ -1530,12 +1530,12 @@ - assert: that: - - entrypoint_1 is changed - - entrypoint_2 is not changed - - entrypoint_3 is changed - - entrypoint_4 is changed - - entrypoint_5 is changed - - entrypoint_6 is not changed + - entrypoint_1 is changed + - entrypoint_2 is not changed + - entrypoint_3 is changed + - entrypoint_4 is changed + - entrypoint_5 is changed + - entrypoint_6 is not changed # New @@ -1544,10 +1544,10 @@ image: "{{ docker_test_image_alpine }}" command_handling: correct entrypoint: - - /bin/sh - - "-v" - - "-c" - - "sleep 10m" + - /bin/sh + - "-v" + - "-c" + - "sleep 10m" name: "{{ cname }}" state: started register: entrypoint_1 @@ -1557,10 +1557,10 @@ image: "{{ docker_test_image_alpine }}" command_handling: correct entrypoint: - - /bin/sh - - "-v" - - "-c" - - "sleep 10m" + - /bin/sh + - "-v" + - "-c" + - "sleep 10m" name: "{{ cname }}" state: started register: entrypoint_2 @@ -1570,10 +1570,10 @@ image: "{{ docker_test_image_alpine }}" command_handling: correct entrypoint: - - /bin/sh - - "-c" - - "sleep 10m" - - "-v" + - /bin/sh + - "-c" + - "sleep 10m" + - "-v" name: "{{ cname }}" state: started force_kill: true @@ -1584,9 +1584,9 @@ image: "{{ docker_test_image_alpine }}" command_handling: correct entrypoint: - - /bin/sh - - "-c" - - "sleep 10m" + - /bin/sh + - "-c" + - "sleep 10m" name: "{{ cname }}" state: started force_kill: true @@ -1597,9 +1597,9 @@ image: "{{ docker_test_image_alpine }}" command_handling: correct entrypoint: - - /bin/sh - - "-c" - - "sleep 5m" + - /bin/sh + - "-c" + - "sleep 5m" name: "{{ cname }}" state: started force_kill: true @@ -1624,12 +1624,12 @@ - assert: that: - - entrypoint_1 is changed - - entrypoint_2 is not changed - - entrypoint_3 is changed - - entrypoint_4 is changed - - entrypoint_5 is changed - - entrypoint_6 is changed + - entrypoint_1 is changed + - entrypoint_2 is not changed + - entrypoint_3 is changed + - entrypoint_4 is changed + - entrypoint_5 is changed + - entrypoint_6 is changed #################################################################### ## env ############################################################# @@ -1706,20 +1706,20 @@ - assert: that: - - env_1 is changed - - "'TEST1=val1' in env_1.container.Config.Env" - - "'TEST2=val2' in env_1.container.Config.Env" - - "'TEST3=False' in env_1.container.Config.Env" - - "'TEST4=true' in env_1.container.Config.Env" - - "'TEST5=yes' in env_1.container.Config.Env" - - env_2 is not changed - - env_3 is not changed - - "'TEST1=val1' in env_4.container.Config.Env" - - "'TEST2=val2' not in env_4.container.Config.Env" - - "'TEST3=val3' in env_4.container.Config.Env" - - env_4 is changed - - env_5 is failed - - "('Non-string value found for env option.') in env_5.msg" + - env_1 is changed + - "'TEST1=val1' in env_1.container.Config.Env" + - "'TEST2=val2' in env_1.container.Config.Env" + - "'TEST3=False' in env_1.container.Config.Env" + - "'TEST4=true' in env_1.container.Config.Env" + - "'TEST5=yes' in env_1.container.Config.Env" + - env_2 is not changed + - env_3 is not changed + - "'TEST1=val1' in env_4.container.Config.Env" + - "'TEST2=val2' not in env_4.container.Config.Env" + - "'TEST3=val3' in env_4.container.Config.Env" + - env_4 is changed + - env_5 is failed + - "('Non-string value found for env option.') in env_5.msg" #################################################################### ## env_file ######################################################### @@ -1805,20 +1805,20 @@ - assert: that: - - env_file_1 is changed - - "'TEST3=val3' in env_file_1.container.Config.Env" - - "'TEST4=val4' in env_file_1.container.Config.Env" - - env_file_2 is not changed - - env_file_3 is not changed - - env_file_4 is changed - - "'TEST1=val1' in env_file_4.container.Config.Env" - - "'TEST3=val3' in env_file_4.container.Config.Env" - - "'TEST4=val4' in env_file_4.container.Config.Env" - - env_file_5 is not changed - - env_file_6 is changed - - "'TEST2=val2' in env_file_6.container.Config.Env" - - "'TEST3=val3' in env_file_6.container.Config.Env" - - "'TEST4=val4alt' in env_file_6.container.Config.Env" + - env_file_1 is changed + - "'TEST3=val3' in env_file_1.container.Config.Env" + - "'TEST4=val4' in env_file_1.container.Config.Env" + - env_file_2 is not changed + - env_file_3 is not changed + - env_file_4 is changed + - "'TEST1=val1' in env_file_4.container.Config.Env" + - "'TEST3=val3' in env_file_4.container.Config.Env" + - "'TEST4=val4' in env_file_4.container.Config.Env" + - env_file_5 is not changed + - env_file_6 is changed + - "'TEST2=val2' in env_file_6.container.Config.Env" + - "'TEST3=val3' in env_file_6.container.Config.Env" + - "'TEST4=val4alt' in env_file_6.container.Config.Env" #################################################################### ## etc_hosts ####################################################### @@ -1877,10 +1877,10 @@ - assert: that: - - etc_hosts_1 is changed - - etc_hosts_2 is not changed - - etc_hosts_3 is not changed - - etc_hosts_4 is changed + - etc_hosts_1 is changed + - etc_hosts_2 is not changed + - etc_hosts_3 is not changed + - etc_hosts_4 is changed #################################################################### ## exposed_ports ################################################### @@ -1893,8 +1893,8 @@ name: "{{ cname }}" state: started exposed_ports: - - "9001" - - "9002" + - "9001" + - "9002" register: exposed_ports_1 - name: exposed_ports (idempotency) @@ -1904,8 +1904,8 @@ name: "{{ cname }}" state: started exposed_ports: - - "9002" - - "9001" + - "9002" + - "9001" register: exposed_ports_2 - name: exposed_ports (less ports) @@ -1915,7 +1915,7 @@ name: "{{ cname }}" state: started exposed_ports: - - "9002" + - "9002" register: exposed_ports_3 - name: exposed_ports (more ports) @@ -1925,8 +1925,8 @@ name: "{{ cname }}" state: started exposed_ports: - - "9002" - - "9003" + - "9002" + - "9003" force_kill: true register: exposed_ports_4 @@ -1939,10 +1939,10 @@ - assert: that: - - exposed_ports_1 is changed - - exposed_ports_2 is not changed - - exposed_ports_3 is not changed - - exposed_ports_4 is changed + - exposed_ports_1 is changed + - exposed_ports_2 is not changed + - exposed_ports_3 is not changed + - exposed_ports_4 is changed #################################################################### ## force_kill ###################################################### @@ -1961,8 +1961,8 @@ name: "{{ cname }}" state: started groups: - - "1234" - - "5678" + - "1234" + - "5678" register: groups_1 - name: groups (idempotency) @@ -1972,8 +1972,8 @@ name: "{{ cname }}" state: started groups: - - "5678" - - "1234" + - "5678" + - "1234" register: groups_2 - name: groups (less groups) @@ -1983,7 +1983,7 @@ name: "{{ cname }}" state: started groups: - - "1234" + - "1234" register: groups_3 - name: groups (more groups) @@ -1993,8 +1993,8 @@ name: "{{ cname }}" state: started groups: - - "1234" - - "2345" + - "1234" + - "2345" force_kill: true register: groups_4 @@ -2007,10 +2007,10 @@ - assert: that: - - groups_1 is changed - - groups_2 is not changed - - groups_3 is not changed - - groups_4 is changed + - groups_1 is changed + - groups_2 is not changed + - groups_3 is not changed + - groups_4 is changed #################################################################### ## healthcheck ##################################################### @@ -2024,9 +2024,9 @@ state: started healthcheck: test: - - CMD - - sleep - - 1 + - CMD + - sleep + - 1 timeout: 2s interval: 0h0m2s3ms4us retries: 2 @@ -2041,9 +2041,9 @@ state: started healthcheck: test: - - CMD - - sleep - - 1 + - CMD + - sleep + - 1 timeout: 2s interval: 0h0m2s3ms4us retries: 2 @@ -2058,9 +2058,9 @@ state: started healthcheck: test: - - CMD - - sleep - - 1 + - CMD + - sleep + - 1 timeout: 3s interval: 0h1m2s3ms4us retries: 3 @@ -2084,7 +2084,7 @@ state: started healthcheck: test: - - NONE + - NONE force_kill: true register: healthcheck_5 @@ -2096,7 +2096,7 @@ state: started healthcheck: test: - - NONE + - NONE force_kill: true register: healthcheck_6 @@ -2108,7 +2108,7 @@ state: started healthcheck: test: - - NONE + - NONE force_kill: true comparisons: '*': strict @@ -2145,15 +2145,15 @@ - 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 not changed - - healthcheck_8 is changed - - healthcheck_9 is not changed + - 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 not changed + - healthcheck_8 is changed + - healthcheck_9 is not changed #################################################################### ## hostname ######################################################## @@ -2196,9 +2196,9 @@ - assert: that: - - hostname_1 is changed - - hostname_2 is not changed - - hostname_3 is changed + - hostname_1 is changed + - hostname_2 is not changed + - hostname_3 is changed #################################################################### ## init ############################################################ @@ -2241,9 +2241,9 @@ - assert: that: - - init_1 is changed - - init_2 is not changed - - init_3 is changed + - init_1 is changed + - init_2 is not changed + - init_3 is changed #################################################################### ## interactive ##################################################### @@ -2286,9 +2286,9 @@ - assert: that: - - interactive_1 is changed - - interactive_2 is not changed - - interactive_3 is changed + - interactive_1 is changed + - interactive_2 is not changed + - interactive_3 is changed #################################################################### ## image / image_comparison ######################################## @@ -2370,12 +2370,12 @@ - assert: that: - - image_1 is changed - - image_2 is not changed - - ignore_image is not changed - - ignore_image_2 is not changed - - ignore_image_3 is changed - - image_change is changed + - image_1 is changed + - image_2 is not changed + - ignore_image is not changed + - ignore_image_2 is not changed + - ignore_image_3 is changed + - image_change is changed #################################################################### ## image_label_mismatch ############################################ @@ -2522,22 +2522,22 @@ - assert: that: - - image_label_mismatch_1 is changed - - image_label_mismatch_1.container.Config.Labels.img_label == "base" - - image_label_mismatch_2 is not changed - - image_label_mismatch_3 is not changed - - image_label_mismatch_4 is not changed - - image_label_mismatch_5 is changed - - image_label_mismatch_5.container.Config.Labels.img_label == "override" - - image_label_mismatch_6 is changed - - image_label_mismatch_6.container.Config.Labels.img_label == "base" - - image_label_mismatch_7 is not changed - - image_label_mismatch_8 is not changed - - image_label_mismatch_9 is failed - - >- - image_label_mismatch_9.msg == ("Some labels should be removed but are present in the base image. You can set image_label_mismatch to 'ignore' to ignore this error. " ~ 'Labels: "img_label"') - - image_label_mismatch_10 is not changed - - image_label_mismatch_11 is changed + - image_label_mismatch_1 is changed + - image_label_mismatch_1.container.Config.Labels.img_label == "base" + - image_label_mismatch_2 is not changed + - image_label_mismatch_3 is not changed + - image_label_mismatch_4 is not changed + - image_label_mismatch_5 is changed + - image_label_mismatch_5.container.Config.Labels.img_label == "override" + - image_label_mismatch_6 is changed + - image_label_mismatch_6.container.Config.Labels.img_label == "base" + - image_label_mismatch_7 is not changed + - image_label_mismatch_8 is not changed + - image_label_mismatch_9 is failed + - >- + image_label_mismatch_9.msg == ("Some labels should be removed but are present in the base image. You can set image_label_mismatch to 'ignore' to ignore this error. " ~ 'Labels: "img_label"') + - image_label_mismatch_10 is not changed + - image_label_mismatch_11 is changed #################################################################### ## image_name_mismatch ############################################# @@ -2619,12 +2619,12 @@ - assert: that: - - image_1 is changed - - image_2 is not changed - - ignore_image is not changed - - ignore_image_2 is not changed - - ignore_image_3 is changed - - image_change is changed + - image_1 is changed + - image_2 is not changed + - ignore_image is not changed + - ignore_image_2 is not changed + - ignore_image_3 is changed + - image_change is changed #################################################################### ## image_name_mismatch ############################################# @@ -2683,10 +2683,10 @@ - assert: that: - - image_name_mismatch_1 is changed - - image_name_mismatch_2 is not changed - - image_name_mismatch_3 is changed - - image_name_mismatch_3.container.Image == image_name_mismatch_2.container.Image + - image_name_mismatch_1 is changed + - image_name_mismatch_2 is not changed + - image_name_mismatch_3 is changed + - image_name_mismatch_3.container.Image == image_name_mismatch_2.container.Image #################################################################### ## ipc_mode ######################################################## @@ -2700,7 +2700,7 @@ state: started ipc_mode: shareable loop: - - "{{ cname_h1 }}" + - "{{ cname_h1 }}" loop_control: loop_var: container_name @@ -2740,17 +2740,17 @@ state: absent force_kill: true loop: - - "{{ cname }}" - - "{{ cname_h1 }}" + - "{{ cname }}" + - "{{ cname_h1 }}" loop_control: loop_var: container_name diff: false - assert: that: - - ipc_mode_1 is changed - - ipc_mode_2 is not changed - - ipc_mode_3 is changed + - ipc_mode_1 is changed + - ipc_mode_2 is not changed + - ipc_mode_3 is changed #################################################################### ## kernel_memory ################################################### @@ -2796,9 +2796,9 @@ - assert: that: - - kernel_memory_1 is changed - - kernel_memory_2 is not changed - - kernel_memory_3 is changed + - 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 - >- @@ -2869,10 +2869,10 @@ - assert: that: - - labels_1 is changed - - labels_2 is not changed - - labels_3 is not changed - - labels_4 is changed + - labels_1 is changed + - labels_2 is not changed + - labels_3 is not changed + - labels_4 is changed #################################################################### ## links ########################################################### @@ -2885,9 +2885,9 @@ name: "{{ container_name }}" state: started loop: - - "{{ cname_h1 }}" - - "{{ cname_h2 }}" - - "{{ cname_h3 }}" + - "{{ cname_h1 }}" + - "{{ cname_h2 }}" + - "{{ cname_h3 }}" loop_control: loop_var: container_name @@ -2898,8 +2898,8 @@ name: "{{ cname }}" state: started links: - - "{{ cname_h1 }}:test1" - - "{{ cname_h2 }}:test2" + - "{{ cname_h1 }}:test1" + - "{{ cname_h2 }}:test2" register: links_1 - name: links (idempotency) @@ -2909,8 +2909,8 @@ name: "{{ cname }}" state: started links: - - "{{ cname_h2 }}:test2" - - "{{ cname_h1 }}:test1" + - "{{ cname_h2 }}:test2" + - "{{ cname_h1 }}:test1" register: links_2 - name: links (less links) @@ -2920,7 +2920,7 @@ name: "{{ cname }}" state: started links: - - "{{ cname_h1 }}:test1" + - "{{ cname_h1 }}:test1" register: links_3 - name: links (more links) @@ -2930,8 +2930,8 @@ name: "{{ cname }}" state: started links: - - "{{ cname_h1 }}:test1" - - "{{ cname_h3 }}:test3" + - "{{ cname_h1 }}:test1" + - "{{ cname_h3 }}:test3" force_kill: true register: links_4 @@ -2941,20 +2941,20 @@ state: absent force_kill: true loop: - - "{{ cname }}" - - "{{ cname_h1 }}" - - "{{ cname_h2 }}" - - "{{ cname_h3 }}" + - "{{ cname }}" + - "{{ cname_h1 }}" + - "{{ cname_h2 }}" + - "{{ cname_h3 }}" loop_control: loop_var: container_name diff: false - assert: that: - - links_1 is changed - - links_2 is not changed - - links_3 is not changed - - links_4 is changed + - links_1 is changed + - links_2 is not changed + - links_3 is not changed + - links_4 is changed #################################################################### ## log_driver ###################################################### @@ -2997,9 +2997,9 @@ - assert: that: - - log_driver_1 is changed - - log_driver_2 is not changed - - log_driver_3 is changed + - log_driver_1 is changed + - log_driver_2 is not changed + - log_driver_3 is changed #################################################################### ## log_options ##################################################### @@ -3064,12 +3064,12 @@ - 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 | default([]))" - - log_options_3 is not changed - - log_options_4 is changed + - 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 | default([]))" + - log_options_3 is not changed + - log_options_4 is changed #################################################################### ## mac_address ##################################################### @@ -3114,9 +3114,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - mac_address_1 is changed - - mac_address_2 is not changed - - mac_address_3 is changed + - mac_address_1 is changed + - mac_address_2 is not changed + - mac_address_3 is changed #################################################################### ## memory ########################################################## @@ -3159,9 +3159,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - memory_1 is changed - - memory_2 is not changed - - memory_3 is changed + - memory_1 is changed + - memory_2 is not changed + - memory_3 is changed #################################################################### ## memory_reservation ############################################## @@ -3204,9 +3204,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - memory_reservation_1 is changed - - memory_reservation_2 is not changed - - memory_reservation_3 is changed + - memory_reservation_1 is changed + - memory_reservation_2 is not changed + - memory_reservation_3 is changed #################################################################### ## memory_swap ##################################################### @@ -3284,16 +3284,16 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - 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 - # Unlimited memory_swap (using 'unlimited') should be allowed - # (If the value was already -1 because of the above reasons, it won't change) - - (memory_swap_4 is changed or memory_swap_3.container.HostConfig.MemorySwap == -1) and memory_swap_4.container.HostConfig.MemorySwap == -1 - # Unlimited memory_swap (using '-1') should be allowed - - memory_swap_5 is not changed and memory_swap_5.container.HostConfig.MemorySwap == -1 + - 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 + # Unlimited memory_swap (using 'unlimited') should be allowed + # (If the value was already -1 because of the above reasons, it won't change) + - (memory_swap_4 is changed or memory_swap_3.container.HostConfig.MemorySwap == -1) and memory_swap_4.container.HostConfig.MemorySwap == -1 + # Unlimited memory_swap (using '-1') should be allowed + - memory_swap_5 is not changed and memory_swap_5.container.HostConfig.MemorySwap == -1 - debug: var=memory_swap_1 when: memory_swap_2 is changed @@ -3343,9 +3343,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - memory_swappiness_1 is changed - - memory_swappiness_2 is not changed - - memory_swappiness_3 is changed + - memory_swappiness_1 is changed + - memory_swappiness_2 is not changed + - memory_swappiness_3 is changed when: >- 'Docker warning: Your kernel does not support memory swappiness capabilities or the cgroup is not mounted. Memory swappiness discarded.' not in (memory_swappiness_1.warnings | default([])) @@ -3390,9 +3390,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - oom_killer_1 is changed - - oom_killer_2 is not changed - - oom_killer_3 is changed + - oom_killer_1 is changed + - oom_killer_2 is not changed + - oom_killer_3 is changed when: >- 'Docker warning: Your kernel does not support OomKillDisable. OomKillDisable discarded.' not in (oom_killer_1.warnings | default([])) @@ -3437,9 +3437,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - oom_score_adj_1 is changed - - oom_score_adj_2 is not changed - - oom_score_adj_3 is changed + - oom_score_adj_1 is changed + - oom_score_adj_2 is not changed + - oom_score_adj_3 is changed when: >- 'Docker warning: Your kernel does not support OomScoreAdj. OomScoreAdj discarded.' not in (oom_score_adj_1.warnings | default([])) @@ -3500,11 +3500,11 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - 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"' + - 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 ######################################################## @@ -3552,17 +3552,17 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau state: absent force_kill: true loop: - - "{{ cname }}" - - "{{ cname_h1 }}" + - "{{ cname }}" + - "{{ cname_h1 }}" loop_control: loop_var: container_name diff: false - assert: that: - - pid_mode_1 is changed - - pid_mode_2 is not changed - - pid_mode_3 is changed + - pid_mode_1 is changed + - pid_mode_2 is not changed + - pid_mode_3 is changed #################################################################### ## pids_limit ###################################################### @@ -3605,9 +3605,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - pids_limit_1 is changed - - pids_limit_2 is not changed - - pids_limit_3 is changed + - pids_limit_1 is changed + - pids_limit_2 is not changed + - pids_limit_3 is changed #################################################################### ## platform ######################################################## @@ -3696,18 +3696,18 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - platform_1 is changed - - platform_2 is not changed and platform_2 is not failed - - platform_3 is not changed and platform_3 is not failed - - platform_4 is not changed and platform_4 is not failed - - platform_5 is changed - - platform_6 is not changed and platform_6 is not failed + - platform_1 is changed + - platform_2 is not changed and platform_2 is not failed + - platform_3 is not changed and platform_3 is not failed + - platform_4 is not changed and platform_4 is not failed + - platform_5 is changed + - platform_6 is not changed and platform_6 is not failed when: docker_api_version is version('1.41', '>=') - assert: that: - - platform_1 is failed - - | - ('API version is ' ~ docker_api_version ~ '.') in platform_1.msg and 'Minimum version required is 1.41 ' in platform_1.msg + - platform_1 is failed + - | + ('API version is ' ~ docker_api_version ~ '.') in platform_1.msg and 'Minimum version required is 1.41 ' in platform_1.msg when: docker_api_version is version('1.41', '<') #################################################################### @@ -3813,36 +3813,36 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - pull_1 is failed - - pull_1.msg == ("Cannot find image with name " ~ docker_test_image_hello_world ~ ", and pull=never") - - pull_2 is changed - - pulled_image_action not in pull_2.actions - - pulled_image_action_changed in pull_2.actions - - pulled_image_action_unchanged not in pull_2.actions - - pull_3 is changed - - pulled_image_action not in pull_3.actions - - pulled_image_action_changed in pull_3.actions - - pulled_image_action_unchanged not in pull_3.actions - - pull_4 is not changed - - pulled_image_action not in pull_4.actions - - pulled_image_action_changed not in pull_4.actions - - pulled_image_action_unchanged not in pull_4.actions - - pull_5 is not changed - - pulled_image_action not in pull_5.actions - - pulled_image_action_changed not in pull_5.actions - - pulled_image_action_unchanged not in pull_5.actions - - pull_6 is not changed - - pulled_image_action not in pull_6.actions - - pulled_image_action_changed not in pull_6.actions - - pulled_image_action_unchanged not in pull_6.actions - - pull_7 is changed - - pulled_image_action in pull_7.actions - - pulled_image_action_changed not in pull_7.actions - - pulled_image_action_unchanged not in pull_7.actions - - pull_8 is not changed - - pulled_image_action not in pull_8.actions - - pulled_image_action_changed not in pull_8.actions - - pulled_image_action_unchanged in pull_8.actions + - pull_1 is failed + - pull_1.msg == ("Cannot find image with name " ~ docker_test_image_hello_world ~ ", and pull=never") + - pull_2 is changed + - pulled_image_action not in pull_2.actions + - pulled_image_action_changed in pull_2.actions + - pulled_image_action_unchanged not in pull_2.actions + - pull_3 is changed + - pulled_image_action not in pull_3.actions + - pulled_image_action_changed in pull_3.actions + - pulled_image_action_unchanged not in pull_3.actions + - pull_4 is not changed + - pulled_image_action not in pull_4.actions + - pulled_image_action_changed not in pull_4.actions + - pulled_image_action_unchanged not in pull_4.actions + - pull_5 is not changed + - pulled_image_action not in pull_5.actions + - pulled_image_action_changed not in pull_5.actions + - pulled_image_action_unchanged not in pull_5.actions + - pull_6 is not changed + - pulled_image_action not in pull_6.actions + - pulled_image_action_changed not in pull_6.actions + - pulled_image_action_unchanged not in pull_6.actions + - pull_7 is changed + - pulled_image_action in pull_7.actions + - pulled_image_action_changed not in pull_7.actions + - pulled_image_action_unchanged not in pull_7.actions + - pull_8 is not changed + - pulled_image_action not in pull_8.actions + - pulled_image_action_changed not in pull_8.actions + - pulled_image_action_unchanged in pull_8.actions vars: pulled_image_action: pulled_image: "{{ docker_test_image_hello_world }}" @@ -3894,9 +3894,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - privileged_1 is changed - - privileged_2 is not changed - - privileged_3 is changed + - privileged_1 is changed + - privileged_2 is not changed + - privileged_3 is changed #################################################################### ## published_ports and default_host_ip ############################# @@ -3909,8 +3909,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started published_ports: - - '9001' - - '9002' + - '9001' + - '9002' register: published_ports_1 - name: published_ports (idempotency) @@ -3920,8 +3920,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started published_ports: - - '9002' - - '9001' + - '9002' + - '9001' register: published_ports_2 - name: published_ports (less published_ports) @@ -3931,7 +3931,7 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started published_ports: - - '9002' + - '9002' register: published_ports_3 - name: published_ports (more published_ports) @@ -3941,8 +3941,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started published_ports: - - '9002' - - '9003' + - '9002' + - '9003' force_kill: true register: published_ports_4 @@ -3953,9 +3953,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started published_ports: - - '127.0.0.1:9002:9002/tcp' - - '[::1]:9003:9003/tcp' - - '[fe80::1%test]:90:90/tcp' + - '127.0.0.1:9002:9002/tcp' + - '[::1]:9003:9003/tcp' + - '[fe80::1%test]:90:90/tcp' force_kill: true register: published_ports_5 when: docker_host_info.host_info.ServerVersion is version('27.0.0', '<') @@ -3967,9 +3967,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started published_ports: - - '127.0.0.1:9002:9002/tcp' - - '[::1]:9003:9003/tcp' - - '[fe80::1%test]:90:90/tcp' + - '127.0.0.1:9002:9002/tcp' + - '[::1]:9003:9003/tcp' + - '[fe80::1%test]:90:90/tcp' register: published_ports_6 when: docker_host_info.host_info.ServerVersion is version('27.0.0', '<') @@ -3992,8 +3992,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started published_ports: - - '9001' - - '9002' + - '9001' + - '9002' force_kill: true register: published_ports_8 @@ -4004,8 +4004,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started published_ports: - - '9002' - - '9001' + - '9002' + - '9001' default_host_ip: '' force_kill: true register: published_ports_9 @@ -4017,8 +4017,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started published_ports: - - '9002' - - '9001' + - '9002' + - '9001' default_host_ip: '' register: published_ports_10 @@ -4029,8 +4029,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started published_ports: - - '9002' - - '9001' + - '9002' + - '9001' force_kill: true register: published_ports_11 @@ -4043,17 +4043,17 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - 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 and published_ports_5 is not skipped) or published_ports_5 is skipped - - (published_ports_6 is not changed and published_ports_6 is not skipped) or published_ports_6 is skipped - - 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 + - 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 and published_ports_5 is not skipped) or published_ports_5 is skipped + - (published_ports_6 is not changed and published_ports_6 is not skipped) or published_ports_6 is skipped + - 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 ############################################################ @@ -4102,9 +4102,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - read_only_1 is changed - - read_only_2 is not changed - - read_only_3 is changed + - read_only_1 is changed + - read_only_2 is not changed + - read_only_3 is changed #################################################################### ## restart_policy ################################################## @@ -4147,9 +4147,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - restart_policy_1 is changed - - restart_policy_2 is not changed - - restart_policy_3 is changed + - restart_policy_1 is changed + - restart_policy_2 is not changed + - restart_policy_3 is changed #################################################################### ## restart_retries ################################################# @@ -4195,9 +4195,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - restart_retries_1 is changed - - restart_retries_2 is not changed - - restart_retries_3 is changed + - restart_retries_1 is changed + - restart_retries_2 is not changed + - restart_retries_3 is changed #################################################################### ## runtime ######################################################### @@ -4230,8 +4230,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - runtime_1 is changed - - runtime_2 is not changed + - runtime_1 is changed + - runtime_2 is not changed #################################################################### ## security_opts ################################################### @@ -4260,8 +4260,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started security_opts: - - "label:level:s0:c100,c200" - - "no-new-privileges" + - "label:level:s0:c100,c200" + - "no-new-privileges" register: security_opts_1 - name: security_opts (idempotency) @@ -4271,8 +4271,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started security_opts: - - "no-new-privileges" - - "label:level:s0:c100,c200" + - "no-new-privileges" + - "label:level:s0:c100,c200" register: security_opts_2 - name: security_opts (less security options) @@ -4282,7 +4282,7 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started security_opts: - - "no-new-privileges" + - "no-new-privileges" register: security_opts_3 - name: security_opts (more security options) @@ -4292,8 +4292,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started security_opts: - - "label:disable" - - "no-new-privileges" + - "label:disable" + - "no-new-privileges" force_kill: true register: security_opts_4 @@ -4306,10 +4306,10 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - security_opts_1 is changed - - security_opts_2 is not changed - - security_opts_3 is not changed - - security_opts_4 is changed + - security_opts_1 is changed + - security_opts_2 is not changed + - security_opts_3 is not changed + - security_opts_4 is changed #################################################################### ## shm_size ######################################################## @@ -4352,9 +4352,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - shm_size_1 is changed - - shm_size_2 is not changed - - shm_size_3 is changed + - shm_size_1 is changed + - shm_size_2 is not changed + - shm_size_3 is changed #################################################################### ## stop_signal ##################################################### @@ -4397,9 +4397,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - stop_signal_1 is changed - - stop_signal_2 is not changed - - stop_signal_3 is changed + - stop_signal_1 is changed + - stop_signal_2 is not changed + - stop_signal_3 is changed #################################################################### ## stop_timeout #################################################### @@ -4442,9 +4442,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - stop_timeout_1 is changed - - stop_timeout_2 is not changed - - stop_timeout_3 is not changed + - stop_timeout_1 is changed + - stop_timeout_2 is not changed + - stop_timeout_3 is not changed #################################################################### ## storage_opts #################################################### @@ -4493,16 +4493,16 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - storage_opts_1 is changed - - storage_opts_2 is not failed and storage_opts_2 is not changed - - storage_opts_3 is not failed and storage_opts_3 is changed + - storage_opts_1 is changed + - storage_opts_2 is not failed and storage_opts_2 is not changed + - storage_opts_3 is not failed and storage_opts_3 is changed when: storage_opts_1 is not failed - assert: that: - - "'is supported only for' in storage_opts_1.msg" - - storage_opts_2 is failed - - storage_opts_3 is failed + - "'is supported only for' in storage_opts_1.msg" + - storage_opts_2 is failed + - storage_opts_3 is failed when: storage_opts_1 is failed #################################################################### @@ -4572,10 +4572,10 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - sysctls_1 is changed - - sysctls_2 is not changed - - sysctls_3 is not changed - - sysctls_4 is changed + - sysctls_1 is changed + - sysctls_2 is not changed + - sysctls_3 is not changed + - sysctls_4 is changed #################################################################### ## tmpfs ########################################################### @@ -4588,8 +4588,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started tmpfs: - - "/test1:rw,noexec,nosuid,size=65536k" - - "/test2:rw,noexec,nosuid,size=65536k" + - "/test1:rw,noexec,nosuid,size=65536k" + - "/test2:rw,noexec,nosuid,size=65536k" register: tmpfs_1 - name: tmpfs (idempotency) @@ -4599,8 +4599,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started tmpfs: - - "/test2:rw,noexec,nosuid,size=65536k" - - "/test1:rw,noexec,nosuid,size=65536k" + - "/test2:rw,noexec,nosuid,size=65536k" + - "/test1:rw,noexec,nosuid,size=65536k" register: tmpfs_2 - name: tmpfs (less tmpfs) @@ -4610,7 +4610,7 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started tmpfs: - - "/test1:rw,noexec,nosuid,size=65536k" + - "/test1:rw,noexec,nosuid,size=65536k" register: tmpfs_3 - name: tmpfs (more tmpfs) @@ -4620,8 +4620,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started tmpfs: - - "/test1:rw,noexec,nosuid,size=65536k" - - "/test3:rw,noexec,nosuid,size=65536k" + - "/test1:rw,noexec,nosuid,size=65536k" + - "/test3:rw,noexec,nosuid,size=65536k" force_kill: true register: tmpfs_4 @@ -4634,10 +4634,10 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - tmpfs_1 is changed - - tmpfs_2 is not changed - - tmpfs_3 is not changed - - tmpfs_4 is changed + - tmpfs_1 is changed + - tmpfs_2 is not changed + - tmpfs_3 is not changed + - tmpfs_4 is changed #################################################################### ## tty ############################################################# @@ -4683,15 +4683,15 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - tty_1 is changed - - tty_2 is not changed and tty_2 is not failed - - tty_3 is changed + - tty_1 is changed + - tty_2 is not changed and tty_2 is not failed + - tty_3 is changed when: tty_1 is not failed - assert: that: - - "'error during container init: open /dev/pts/' in tty_1.msg" - - "': operation not permitted: ' in tty_1.msg" + - "'error during container init: open /dev/pts/' in tty_1.msg" + - "': operation not permitted: ' in tty_1.msg" when: tty_1 is failed #################################################################### @@ -4705,8 +4705,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started ulimits: - - "nofile:1234:1234" - - "nproc:3:6" + - "nofile:1234:1234" + - "nproc:3:6" register: ulimits_1 - name: ulimits (idempotency) @@ -4716,8 +4716,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started ulimits: - - "nproc:3:6" - - "nofile:1234:1234" + - "nproc:3:6" + - "nofile:1234:1234" register: ulimits_2 - name: ulimits (less ulimits) @@ -4727,7 +4727,7 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started ulimits: - - "nofile:1234:1234" + - "nofile:1234:1234" register: ulimits_3 - name: ulimits (more ulimits) @@ -4737,8 +4737,8 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau name: "{{ cname }}" state: started ulimits: - - "nofile:1234:1234" - - "sigpending:100:200" + - "nofile:1234:1234" + - "sigpending:100:200" force_kill: true register: ulimits_4 @@ -4751,10 +4751,10 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - ulimits_1 is changed - - ulimits_2 is not changed - - ulimits_3 is not changed - - ulimits_4 is changed + - ulimits_1 is changed + - ulimits_2 is not changed + - ulimits_3 is not changed + - ulimits_4 is changed #################################################################### ## user ############################################################ @@ -4797,9 +4797,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - user_1 is changed - - user_2 is not changed - - user_3 is changed + - user_1 is changed + - user_2 is not changed + - user_3 is changed #################################################################### ## userns_mode ##################################################### @@ -4842,9 +4842,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - userns_mode_1 is changed - - userns_mode_2 is not changed - - userns_mode_3 is changed + - userns_mode_1 is changed + - userns_mode_2 is not changed + - userns_mode_3 is changed #################################################################### ## uts ############################################################# @@ -4887,9 +4887,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - uts_1 is changed - - uts_2 is not changed - - uts_3 is changed + - uts_1 is changed + - uts_2 is not changed + - uts_3 is changed #################################################################### ## working_dir ##################################################### @@ -4932,9 +4932,9 @@ avoid such warnings, please quote the value.' in (log_options_2.warnings | defau - assert: that: - - working_dir_1 is changed - - working_dir_2 is not changed - - working_dir_3 is changed + - working_dir_1 is changed + - working_dir_2 is not changed + - working_dir_3 is changed #################################################################### #################################################################### diff --git a/tests/integration/targets/docker_container/tasks/tests/ports.yml b/tests/integration/targets/docker_container/tasks/tests/ports.yml index 460d68f2..4203faa9 100644 --- a/tests/integration/targets/docker_container/tasks/tests/ports.yml +++ b/tests/integration/targets/docker_container/tasks/tests/ports.yml @@ -22,7 +22,7 @@ name: "{{ cname }}" state: started published_ports: - - "[::1:2000:3000" + - "[::1:2000:3000" register: published_ports_1 ignore_errors: true @@ -33,7 +33,7 @@ name: "{{ cname }}" state: started published_ports: - - "::1:2000:3000" + - "::1:2000:3000" register: published_ports_2 ignore_errors: true @@ -44,7 +44,7 @@ name: "{{ cname }}" state: started published_ports: - - "foo:2000:3000" + - "foo:2000:3000" register: published_ports_3 ignore_errors: true @@ -68,11 +68,11 @@ name: "{{ cname }}" state: started exposed_ports: - - "9001" - - "9010-9050" + - "9001" + - "9010-9050" published_ports: - - "9001:9001" - - "9010-9050:9010-9050" + - "9001:9001" + - "9010-9050:9010-9050" force_kill: true register: published_ports_1 @@ -83,11 +83,11 @@ name: "{{ cname }}" state: started exposed_ports: - - "9001" - - "9010-9050" + - "9001" + - "9010-9050" published_ports: - - "9001:9001" - - "9010-9050:9010-9050" + - "9001:9001" + - "9010-9050:9010-9050" force_kill: true register: published_ports_2 @@ -98,11 +98,11 @@ name: "{{ cname }}" state: started exposed_ports: - - "9001" - - "9010-9050" + - "9001" + - "9010-9050" published_ports: - - "9001:9001" - - "9020-9060:9020-9060" + - "9001:9001" + - "9020-9060:9020-9060" force_kill: true register: published_ports_3 @@ -115,9 +115,9 @@ - assert: that: - - published_ports_1 is changed - - published_ports_2 is not changed - - published_ports_3 is changed + - published_ports_1 is changed + - published_ports_2 is not changed + - published_ports_3 is changed #################################################################### ## published_ports: one-element container port range ############### @@ -130,7 +130,7 @@ name: "{{ item }}" state: started published_ports: - - "9010-9050:9010" + - "9010-9050:9010" force_kill: true loop: - '{{ cname }}' @@ -144,7 +144,7 @@ name: "{{ item }}" state: started published_ports: - - "9010-9050:9010" + - "9010-9050:9010" force_kill: true loop: - '{{ cname }}' @@ -158,7 +158,7 @@ name: "{{ item }}" state: started published_ports: - - "9010-9051:9010" + - "9010-9051:9010" force_kill: true loop: - '{{ cname }}' @@ -177,9 +177,9 @@ - assert: that: - - published_ports_1 is changed - - published_ports_2 is not changed - - published_ports_3 is changed + - published_ports_1 is changed + - published_ports_2 is not changed + - published_ports_3 is changed #################################################################### ## published_ports: IPv6 addresses ################################# @@ -194,7 +194,7 @@ name: "{{ cname }}" state: started published_ports: - - "[::1]:9001:9001" + - "[::1]:9001:9001" force_kill: true register: published_ports_1 @@ -205,7 +205,7 @@ name: "{{ cname }}" state: started published_ports: - - "[::1]:9001:9001" + - "[::1]:9001:9001" force_kill: true register: published_ports_2 @@ -216,7 +216,7 @@ name: "{{ cname }}" state: started published_ports: - - "127.0.0.1:9001:9001" + - "127.0.0.1:9001:9001" force_kill: true register: published_ports_3 @@ -227,7 +227,7 @@ name: "{{ cname }}" state: started published_ports: - - "localhost:9001:9001" + - "localhost:9001:9001" force_kill: true register: published_ports_4 ignore_errors: true @@ -241,10 +241,10 @@ - assert: that: - - published_ports_1 is changed - - published_ports_2 is not changed - - published_ports_3 is changed - - published_ports_4 is failed + - published_ports_1 is changed + - published_ports_2 is not changed + - published_ports_3 is changed + - published_ports_4 is failed #################################################################### ## publish_all_ports ############################################### diff --git a/tests/integration/targets/docker_container/tasks/tests/regression-45700-dont-parse-on-absent.yml b/tests/integration/targets/docker_container/tasks/tests/regression-45700-dont-parse-on-absent.yml index 928463ae..aaffbcae 100644 --- a/tests/integration/targets/docker_container/tasks/tests/regression-45700-dont-parse-on-absent.yml +++ b/tests/integration/targets/docker_container/tasks/tests/regression-45700-dont-parse-on-absent.yml @@ -29,10 +29,10 @@ # before the container is stopped (see # https://github.com/ansible/ansible/issues/45486). networks: - - name: "nonexistant-network-{{ (2**32) | random }}" + - name: "nonexistant-network-{{ (2**32) | random }}" published_ports: - - '1:2' - - '3' + - '1:2' + - '3' links: - - "nonexistant-container-{{ (2**32) | random }}:test" + - "nonexistant-container-{{ (2**32) | random }}:test" state: absent diff --git a/tests/integration/targets/docker_container/tasks/tests/start-stop.yml b/tests/integration/targets/docker_container/tasks/tests/start-stop.yml index 97ac38a5..3f266181 100644 --- a/tests/integration/targets/docker_container/tasks/tests/start-stop.yml +++ b/tests/integration/targets/docker_container/tasks/tests/start-stop.yml @@ -50,10 +50,10 @@ - assert: that: - - create_1 is changed - - create_2 is changed - - create_3 is not changed - - create_4 is not changed + - create_1 is changed + - create_2 is changed + - create_3 is not changed + - create_4 is not changed #################################################################### ## Starting (after creation) ####################################### @@ -87,10 +87,10 @@ - assert: that: - - start_1 is changed - - start_2 is changed - - start_3 is not changed - - start_4 is not changed + - start_1 is changed + - start_2 is changed + - start_3 is not changed + - start_4 is not changed #################################################################### ## Present check for running container ############################# @@ -115,8 +115,8 @@ - assert: that: - - present_check_1 is not changed - - present_check_2 is not changed + - present_check_1 is not changed + - present_check_2 is not changed #################################################################### ## Starting (from scratch) ######################################### @@ -168,10 +168,10 @@ - assert: that: - - start_scratch_1 is changed - - start_scratch_2 is changed - - start_scratch_3 is not changed - - start_scratch_4 is not changed + - start_scratch_1 is changed + - start_scratch_2 is changed + - start_scratch_3 is not changed + - start_scratch_4 is not changed #################################################################### ## Recreating ###################################################### @@ -253,16 +253,16 @@ - 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 + - 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 ###################################################### @@ -276,7 +276,7 @@ state: started stop_timeout: 1 volumes: - - /tmp/tmp + - /tmp/tmp register: restart_1 - name: Restarting (restart, check mode) @@ -310,7 +310,7 @@ state: started stop_timeout: 1 volumes: - - /tmp/tmp + - /tmp/tmp register: restart_4 - name: cleanup @@ -322,11 +322,11 @@ - 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 + - 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 ######################################################## @@ -368,10 +368,10 @@ - assert: that: - - stop_1 is changed - - stop_2 is changed - - stop_3 is not changed - - stop_4 is not changed + - stop_1 is changed + - stop_2 is changed + - stop_3 is not changed + - stop_4 is not changed #################################################################### ## Removing ######################################################## @@ -405,10 +405,10 @@ - assert: that: - - remove_1 is changed - - remove_2 is changed - - remove_3 is not changed - - remove_4 is not changed + - remove_1 is changed + - remove_2 is changed + - remove_3 is not changed + - remove_4 is not changed #################################################################### ## Removing (from running) ######################################### @@ -453,7 +453,7 @@ - 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 + - 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/tests/integration/targets/docker_container/tasks/tests/update.yml b/tests/integration/targets/docker_container/tasks/tests/update.yml index 7ebdcf83..1ac50a52 100644 --- a/tests/integration/targets/docker_container/tasks/tests/update.yml +++ b/tests/integration/targets/docker_container/tasks/tests/update.yml @@ -131,91 +131,91 @@ - name: Check general things assert: that: - - create is changed - - update is changed - - update2 is changed - - recreate is changed + - create is changed + - update is changed + - update2 is changed + - recreate is changed - # Make sure the container was *not* recreated when it should not be - - create.container.Id == update.container.Id - - create.container.Id == update2.container.Id + # Make sure the container was *not* recreated when it should not be + - create.container.Id == update.container.Id + - create.container.Id == update2.container.Id - # Make sure that the container was recreated when it should be - - create.container.Id != recreate.container.Id + # Make sure that the container was recreated when it should be + - create.container.Id != recreate.container.Id - name: Check diff for first update assert: that: - # blkio_weight sometimes cannot be set, then we end up with 0 instead of the value we had - - >- - not has_blkio_weight or update.diff.before.blkio_weight == 123 or ('Docker warning: Your kernel does not support Block I/O weight or the cgroup is not mounted. Weight discarded.' in (create.warnings | default([]))) - - not has_blkio_weight or update.diff.after.blkio_weight == 234 - - update.diff.before.cpu_period == 90000 - - update.diff.after.cpu_period == 50000 - - update.diff.before.cpu_quota == 150000 - - update.diff.after.cpu_quota == 50000 - - update.diff.before.cpu_shares == 900 - - update.diff.after.cpu_shares == 1100 - - update.diff.before.memory == 67108864 - - update.diff.after.memory == 50331648 - - update.diff.before.memory_reservation == 67108864 - - update.diff.after.memory_reservation == 50331648 - - >- - (update.diff.before.memory_swap | default(0)) == 67108864 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([]))) - - >- - (update.diff.after.memory_swap | default(0)) == -1 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([]))) - - "'restart_policy' not in update.diff.before" - - update.diff.before.restart_retries == 5 - - update.diff.after.restart_retries == 2 + # blkio_weight sometimes cannot be set, then we end up with 0 instead of the value we had + - >- + not has_blkio_weight or update.diff.before.blkio_weight == 123 or ('Docker warning: Your kernel does not support Block I/O weight or the cgroup is not mounted. Weight discarded.' in (create.warnings | default([]))) + - not has_blkio_weight or update.diff.after.blkio_weight == 234 + - update.diff.before.cpu_period == 90000 + - update.diff.after.cpu_period == 50000 + - update.diff.before.cpu_quota == 150000 + - update.diff.after.cpu_quota == 50000 + - update.diff.before.cpu_shares == 900 + - update.diff.after.cpu_shares == 1100 + - update.diff.before.memory == 67108864 + - update.diff.after.memory == 50331648 + - update.diff.before.memory_reservation == 67108864 + - update.diff.after.memory_reservation == 50331648 + - >- + (update.diff.before.memory_swap | default(0)) == 67108864 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([]))) + - >- + (update.diff.after.memory_swap | default(0)) == -1 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([]))) + - "'restart_policy' not in update.diff.before" + - update.diff.before.restart_retries == 5 + - update.diff.after.restart_retries == 2 - name: Check diff for second update assert: that: - - >- - not has_blkio_weight or update2.diff.before.blkio_weight == 234 or ('Docker warning: Your kernel does not support Block I/O weight or the cgroup is not mounted. Weight discarded.' in (create.warnings | default([]))) - - not has_blkio_weight or update2.diff.after.blkio_weight == 135 - - update2.diff.before.cpu_period == 50000 - - update2.diff.after.cpu_period == 30000 - - update2.diff.before.cpu_quota == 50000 - - update2.diff.after.cpu_quota == 40000 - - update2.diff.before.cpu_shares == 1100 - - update2.diff.after.cpu_shares == 1000 - - update2.diff.before.memory == 50331648 - - update2.diff.after.memory == 33554432 - - update2.diff.before.memory_reservation == 50331648 - - update2.diff.after.memory_reservation == 31457280 - - >- - (update2.diff.before.memory_swap | default(0)) == -1 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([]))) - - >- - (update2.diff.after.memory_swap | default(0)) == 134217728 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([]))) - - update2.diff.before.restart_policy == 'on-failure' - - update2.diff.after.restart_policy == 'always' - - update2.diff.before.restart_retries == 2 - - update2.diff.after.restart_retries == 0 + - >- + not has_blkio_weight or update2.diff.before.blkio_weight == 234 or ('Docker warning: Your kernel does not support Block I/O weight or the cgroup is not mounted. Weight discarded.' in (create.warnings | default([]))) + - not has_blkio_weight or update2.diff.after.blkio_weight == 135 + - update2.diff.before.cpu_period == 50000 + - update2.diff.after.cpu_period == 30000 + - update2.diff.before.cpu_quota == 50000 + - update2.diff.after.cpu_quota == 40000 + - update2.diff.before.cpu_shares == 1100 + - update2.diff.after.cpu_shares == 1000 + - update2.diff.before.memory == 50331648 + - update2.diff.after.memory == 33554432 + - update2.diff.before.memory_reservation == 50331648 + - update2.diff.after.memory_reservation == 31457280 + - >- + (update2.diff.before.memory_swap | default(0)) == -1 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([]))) + - >- + (update2.diff.after.memory_swap | default(0)) == 134217728 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([]))) + - update2.diff.before.restart_policy == 'on-failure' + - update2.diff.after.restart_policy == 'always' + - update2.diff.before.restart_retries == 2 + - update2.diff.after.restart_retries == 0 - name: Check diff for recreation assert: that: - - >- - not has_blkio_weight or recreate.diff.before.blkio_weight == 135 or ('Docker warning: Your kernel does not support Block I/O weight or the cgroup is not mounted. Weight discarded.' in (create.warnings | default([]))) - - not has_blkio_weight or recreate.diff.after.blkio_weight == 234 - - recreate.diff.before.cpu_period == 30000 - - recreate.diff.after.cpu_period == 50000 - - recreate.diff.before.cpu_quota == 40000 - - recreate.diff.after.cpu_quota == 50000 - - recreate.diff.before.cpu_shares == 1000 - - recreate.diff.after.cpu_shares == 1100 - - recreate.diff.before.memory == 33554432 - - recreate.diff.after.memory == 50331648 - - recreate.diff.before.memory_reservation == 31457280 - - recreate.diff.after.memory_reservation == 50331648 - - >- - (recreate.diff.before.memory_swap | default(0)) == 134217728 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([]))) - - >- - (recreate.diff.after.memory_swap | default(0)) == -1 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([]))) - - recreate.diff.before.restart_policy == 'always' - - recreate.diff.after.restart_policy == 'on-failure' - - recreate.diff.before.restart_retries == 0 - - recreate.diff.after.restart_retries == 2 - - recreate.diff.before.command == ['/bin/sh', '-c', 'sleep 10m'] - - recreate.diff.after.command == ['/bin/sh', '-c', 'sleep 20m'] + - >- + not has_blkio_weight or recreate.diff.before.blkio_weight == 135 or ('Docker warning: Your kernel does not support Block I/O weight or the cgroup is not mounted. Weight discarded.' in (create.warnings | default([]))) + - not has_blkio_weight or recreate.diff.after.blkio_weight == 234 + - recreate.diff.before.cpu_period == 30000 + - recreate.diff.after.cpu_period == 50000 + - recreate.diff.before.cpu_quota == 40000 + - recreate.diff.after.cpu_quota == 50000 + - recreate.diff.before.cpu_shares == 1000 + - recreate.diff.after.cpu_shares == 1100 + - recreate.diff.before.memory == 33554432 + - recreate.diff.after.memory == 50331648 + - recreate.diff.before.memory_reservation == 31457280 + - recreate.diff.after.memory_reservation == 50331648 + - >- + (recreate.diff.before.memory_swap | default(0)) == 134217728 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([]))) + - >- + (recreate.diff.after.memory_swap | default(0)) == -1 or ('Docker warning: Your kernel does not support swap limit capabilities or the cgroup is not mounted. Memory limited without swap.' in (create.warnings | default([]))) + - recreate.diff.before.restart_policy == 'always' + - recreate.diff.after.restart_policy == 'on-failure' + - recreate.diff.before.restart_retries == 0 + - recreate.diff.after.restart_retries == 2 + - recreate.diff.before.command == ['/bin/sh', '-c', 'sleep 10m'] + - recreate.diff.after.command == ['/bin/sh', '-c', 'sleep 20m'] diff --git a/tests/integration/targets/docker_container_exec/tasks/main.yml b/tests/integration/targets/docker_container_exec/tasks/main.yml index 784e8386..f8f1ef4b 100644 --- a/tests/integration/targets/docker_container_exec/tasks/main.yml +++ b/tests/integration/targets/docker_container_exec/tasks/main.yml @@ -9,218 +9,218 @@ #################################################################### - block: - - name: Create random container name - set_fact: - cname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}" + - name: Create random container name + set_fact: + cname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}" - - name: Make sure container is not there - docker_container: - name: "{{ cname }}" - state: absent - force_kill: true + - name: Make sure container is not there + docker_container: + name: "{{ cname }}" + state: absent + force_kill: true - - name: Execute in a non-present container - docker_container_exec: - container: "{{ cname }}" - command: "/bin/bash -c 'ls -a'" - register: result - ignore_errors: true + - name: Execute in a non-present container + docker_container_exec: + container: "{{ cname }}" + command: "/bin/bash -c 'ls -a'" + register: result + ignore_errors: true - - assert: - that: - - result is failed - - "'Could not find container' in result.msg" + - assert: + that: + - result is failed + - "'Could not find container' in result.msg" - - name: Make sure container exists - docker_container: - name: "{{ cname }}" - image: "{{ docker_test_image_alpine }}" - command: '/bin/sh -c "sleep 10m"' - state: started - force_kill: true + - name: Make sure container exists + docker_container: + name: "{{ cname }}" + image: "{{ docker_test_image_alpine }}" + command: '/bin/sh -c "sleep 10m"' + state: started + force_kill: true - - name: Execute in a present container (command) - docker_container_exec: - container: "{{ cname }}" - command: "/bin/sh -c 'ls -a'" - register: result_cmd + - name: Execute in a present container (command) + docker_container_exec: + container: "{{ cname }}" + command: "/bin/sh -c 'ls -a'" + register: result_cmd - - assert: - that: - - result_cmd.rc == 0 - - "'stdout' in result_cmd" - - "'stdout_lines' in result_cmd" - - "'stderr' in result_cmd" - - "'stderr_lines' in result_cmd" + - assert: + that: + - result_cmd.rc == 0 + - "'stdout' in result_cmd" + - "'stdout_lines' in result_cmd" + - "'stderr' in result_cmd" + - "'stderr_lines' in result_cmd" - - name: Execute in a present container (argv) - docker_container_exec: - container: "{{ cname }}" - argv: - - /bin/sh - - '-c' - - ls -a - register: result_argv + - name: Execute in a present container (argv) + docker_container_exec: + container: "{{ cname }}" + argv: + - /bin/sh + - '-c' + - ls -a + register: result_argv - - assert: - that: - - result_argv.rc == 0 - - "'stdout' in result_argv" - - "'stdout_lines' in result_argv" - - "'stderr' in result_argv" - - "'stderr_lines' in result_argv" - - result_cmd.stdout == result_argv.stdout + - assert: + that: + - result_argv.rc == 0 + - "'stdout' in result_argv" + - "'stdout_lines' in result_argv" + - "'stderr' in result_argv" + - "'stderr_lines' in result_argv" + - result_cmd.stdout == result_argv.stdout - - name: Execute in a present container (cat without stdin) - docker_container_exec: - container: "{{ cname }}" - argv: - - /bin/sh - - '-c' - - cat - register: result + - name: Execute in a present container (cat without stdin) + docker_container_exec: + container: "{{ cname }}" + argv: + - /bin/sh + - '-c' + - cat + register: result - - assert: - that: - - result.rc == 0 - - result.stdout == '' - - result.stdout_lines == [] - - result.stderr == '' - - result.stderr_lines == [] + - assert: + that: + - result.rc == 0 + - result.stdout == '' + - result.stdout_lines == [] + - result.stderr == '' + - result.stderr_lines == [] - - name: Execute in a present container (cat with stdin) - docker_container_exec: - container: "{{ cname }}" - argv: - - /bin/sh - - '-c' - - cat - stdin: Hello world! - strip_empty_ends: false - register: result + - name: Execute in a present container (cat with stdin) + docker_container_exec: + container: "{{ cname }}" + argv: + - /bin/sh + - '-c' + - cat + stdin: Hello world! + strip_empty_ends: false + register: result - - assert: - that: - - result.rc == 0 - - result.stdout == 'Hello world!\n' - - result.stdout_lines == ['Hello world!'] - - result.stderr == '' - - result.stderr_lines == [] + - assert: + that: + - result.rc == 0 + - result.stdout == 'Hello world!\n' + - result.stdout_lines == ['Hello world!'] + - result.stderr == '' + - result.stderr_lines == [] - - name: Execute in a present container (cat with stdin, no newline) - docker_container_exec: - container: "{{ cname }}" - argv: - - /bin/sh - - '-c' - - cat - stdin: Hello world! - stdin_add_newline: false - strip_empty_ends: false - register: result + - name: Execute in a present container (cat with stdin, no newline) + docker_container_exec: + container: "{{ cname }}" + argv: + - /bin/sh + - '-c' + - cat + stdin: Hello world! + stdin_add_newline: false + strip_empty_ends: false + register: result - - assert: - that: - - result.rc == 0 - - result.stdout == 'Hello world!' - - result.stdout_lines == ['Hello world!'] - - result.stderr == '' - - result.stderr_lines == [] + - assert: + that: + - result.rc == 0 + - result.stdout == 'Hello world!' + - result.stdout_lines == ['Hello world!'] + - result.stderr == '' + - result.stderr_lines == [] - - name: Execute in a present container (cat with stdin, newline but stripping) - docker_container_exec: - container: "{{ cname }}" - argv: - - /bin/sh - - '-c' - - cat - stdin: Hello world! - stdin_add_newline: true - strip_empty_ends: true - register: result + - name: Execute in a present container (cat with stdin, newline but stripping) + docker_container_exec: + container: "{{ cname }}" + argv: + - /bin/sh + - '-c' + - cat + stdin: Hello world! + stdin_add_newline: true + strip_empty_ends: true + register: result - - assert: - that: - - result.rc == 0 - - result.stdout == 'Hello world!' - - result.stdout_lines == ['Hello world!'] - - result.stderr == '' - - result.stderr_lines == [] + - assert: + that: + - result.rc == 0 + - result.stdout == 'Hello world!' + - result.stdout_lines == ['Hello world!'] + - result.stderr == '' + - result.stderr_lines == [] - - name: Prepare long string - set_fact: - very_long_string: "{{ 'something long ' * 10000 }}" - very_long_string2: "{{ 'something else ' * 5000 }}" + - name: Prepare long string + set_fact: + very_long_string: "{{ 'something long ' * 10000 }}" + very_long_string2: "{{ 'something else ' * 5000 }}" - - name: Execute in a present container (long stdin) - docker_container_exec: - container: "{{ cname }}" - argv: - - /bin/sh - - '-c' - - cat - stdin: |- - {{ very_long_string }} - {{ very_long_string2 }} - register: result + - name: Execute in a present container (long stdin) + docker_container_exec: + container: "{{ cname }}" + argv: + - /bin/sh + - '-c' + - cat + stdin: |- + {{ very_long_string }} + {{ very_long_string2 }} + register: result - - assert: - that: - - result is changed - - result.rc == 0 - - result.stdout == (very_long_string ~ '\n' ~ very_long_string2) - - result.stdout_lines == [very_long_string, very_long_string2] - - result.stderr == '' - - result.stderr_lines == [] - - "'exec_id' not in result" + - assert: + that: + - result is changed + - result.rc == 0 + - result.stdout == (very_long_string ~ '\n' ~ very_long_string2) + - result.stdout_lines == [very_long_string, very_long_string2] + - result.stderr == '' + - result.stderr_lines == [] + - "'exec_id' not in result" - - name: Execute in a present container (detached) - docker_container_exec: - container: "{{ cname }}" - argv: - - /bin/sh - - '-c' - - sleep 1m - detach: true - register: result + - name: Execute in a present container (detached) + docker_container_exec: + container: "{{ cname }}" + argv: + - /bin/sh + - '-c' + - sleep 1m + detach: true + register: result - - debug: var=result + - debug: var=result - - assert: - that: - - result is changed - - "'rc' not in result" - - "'stdout' not in result" - - "'stderr' not in result" - - result.exec_id is string + - assert: + that: + - result is changed + - "'rc' not in result" + - "'stdout' not in result" + - "'stderr' not in result" + - result.exec_id is string - - name: Execute in a present container (environment variable) - docker_container_exec: - container: "{{ cname }}" - argv: - - /bin/sh - - '-c' - - 'echo "$FOO" ; echo $FOO > /dev/stderr' - env: - FOO: |- - bar - baz - register: result + - name: Execute in a present container (environment variable) + docker_container_exec: + container: "{{ cname }}" + argv: + - /bin/sh + - '-c' + - 'echo "$FOO" ; echo $FOO > /dev/stderr' + env: + FOO: |- + bar + baz + register: result - - assert: - that: - - result.rc == 0 - - result.stdout == 'bar\nbaz' - - result.stdout_lines == ['bar', 'baz'] - - result.stderr == 'bar baz' - - result.stderr_lines == ['bar baz'] + - assert: + that: + - result.rc == 0 + - result.stdout == 'bar\nbaz' + - result.stdout_lines == ['bar', 'baz'] + - result.stderr == 'bar baz' + - result.stderr_lines == ['bar baz'] always: - - name: Cleanup - docker_container: - name: "{{ cname }}" - state: absent - force_kill: true + - name: Cleanup + docker_container: + name: "{{ cname }}" + state: absent + force_kill: true when: docker_api_version is version('1.25', '>=') diff --git a/tests/integration/targets/docker_container_info/tasks/main.yml b/tests/integration/targets/docker_container_info/tasks/main.yml index 2d97e67d..dcc84747 100644 --- a/tests/integration/targets/docker_container_info/tasks/main.yml +++ b/tests/integration/targets/docker_container_info/tasks/main.yml @@ -9,74 +9,74 @@ #################################################################### - block: - - name: Create random container name - set_fact: - cname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}" + - name: Create random container name + set_fact: + cname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}" - - name: Make sure container is not there - docker_container: - name: "{{ cname }}" - state: absent - force_kill: true + - name: Make sure container is not there + docker_container: + name: "{{ cname }}" + state: absent + force_kill: true - - name: Inspect a non-present container - docker_container_info: - name: "{{ cname }}" - register: result + - 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" + - 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: true + - name: Make sure container exists + docker_container: + name: "{{ cname }}" + image: "{{ docker_test_image_alpine }}" + command: '/bin/sh -c "sleep 10m"' + state: started + force_kill: true - - name: Inspect a present container - docker_container_info: - name: "{{ cname }}" - register: result - - name: Dump docker_container_info result - debug: var=result + - 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: true - - 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: "Comparison: use 'docker inspect'" + command: docker inspect "{{ cname }}" + register: docker_inspect + ignore_errors: true + - 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 is truthy" + - assert: + that: + - result.exists + - "'container' in result" + - "result.container is truthy" - - 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 + - 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: true + - name: Cleanup + docker_container: + name: "{{ cname }}" + state: absent + force_kill: true when: docker_api_version is version('1.25', '>=') diff --git a/tests/integration/targets/docker_context_info/tasks/tests/default-context.yml b/tests/integration/targets/docker_context_info/tasks/tests/default-context.yml index 5958d671..1eac0e55 100644 --- a/tests/integration/targets/docker_context_info/tasks/tests/default-context.yml +++ b/tests/integration/targets/docker_context_info/tasks/tests/default-context.yml @@ -51,8 +51,8 @@ - assert: that: - - create_1 is changed - - create_2 is not changed + - create_1 is changed + - create_2 is not changed - name: Inspect container with CLI tool ansible.builtin.command: @@ -78,8 +78,8 @@ - assert: that: - - start_1 is changed - - start_2 is not changed + - start_1 is changed + - start_2 is not changed - name: Inspect container with CLI tool ansible.builtin.command: @@ -107,8 +107,8 @@ - assert: that: - - remove_1 is changed - - remove_2 is not changed + - remove_1 is changed + - remove_2 is not changed - name: Inspect container with CLI tool ansible.builtin.command: diff --git a/tests/integration/targets/docker_host_info/tasks/test_host_info.yml b/tests/integration/targets/docker_host_info/tasks/test_host_info.yml index bbdbf723..14f67bf5 100644 --- a/tests/integration/targets/docker_host_info/tasks/test_host_info.yml +++ b/tests/integration/targets/docker_host_info/tasks/test_host_info.yml @@ -13,379 +13,379 @@ msg: "Using container names '{{ cname }}' and '{{ cname2 }}', and volume name '{{ vname }}'" - block: - - name: Get info on Docker host - docker_host_info: - register: output + - 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 - - output.can_talk_to_docker is true + - 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 + - output.can_talk_to_docker is true - block: - - name: Get info on Docker host with invalid api_version - docker_host_info: - api_version: 1.999.999 - register: output - ignore_errors: true + - name: Get info on Docker host with invalid api_version + docker_host_info: + api_version: 1.999.999 + register: output + ignore_errors: true - - name: assert can_talk_is_docker is false - assert: - that: - - output is failed - - output.can_talk_to_docker is false + - name: assert can_talk_is_docker is false + assert: + that: + - output is failed + - output.can_talk_to_docker is false - block: - - name: Get info on Docker host with invalid docker_host - docker_host_info: - docker_host: tcp://127.0.0.1:80 - register: output - ignore_errors: true + - name: Get info on Docker host with invalid docker_host + docker_host_info: + docker_host: tcp://127.0.0.1:80 + register: output + ignore_errors: true - - name: assert can_talk_is_docker is false - assert: - that: - - output is failed - - output.can_talk_to_docker is false + - name: assert can_talk_is_docker is false + assert: + that: + - output is failed + - output.can_talk_to_docker is false -# 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 running container - docker_container: - image: "{{ docker_test_image_alpine }}" - command: '/bin/sh -c "sleep 10m"' - name: "{{ cname }}" - labels: - key1: value1 - key2: value2 - state: started - register: container_output + # 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 running container + docker_container: + image: "{{ docker_test_image_alpine }}" + command: '/bin/sh -c "sleep 10m"' + name: "{{ cname }}" + labels: + key1: value1 + key2: value2 + state: started + register: container_output - - name: Create running container - docker_container: - image: "{{ docker_test_image_alpine }}" - name: "{{ cname2 }}" - labels: - key2: value2 - key3: value3 - state: stopped - register: container2_output + - name: Create running container + docker_container: + image: "{{ docker_test_image_alpine }}" + name: "{{ cname2 }}" + labels: + key2: value2 + key3: value3 + state: stopped + register: container2_output - - assert: - that: - - container_output is changed - - container2_output is changed + - assert: + that: + - container_output is changed + - container2_output is changed - - name: Create a volume - docker_volume: - name: "{{ vname }}" - register: volume_output + - name: Create a volume + docker_volume: + name: "{{ vname }}" + register: volume_output - - assert: - that: - - volume_output is changed + - assert: + that: + - volume_output is changed - - name: Get info on Docker host and list containers - docker_host_info: - containers: true - register: output + - name: Get info on Docker host and list containers + docker_host_info: + containers: true + 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: 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 matching filters (single label) - docker_host_info: - containers: true - containers_filters: - label: key1=value1 - register: output + - name: Get info on Docker host and list containers matching filters (single label) + docker_host_info: + containers: true + containers_filters: + label: key1=value1 + register: output - - name: assert container is returned when filters are matched (single label) - assert: - that: "output.containers | length == 1" + - name: assert container is returned when filters are matched (single label) + assert: + that: "output.containers | length == 1" - - name: Get info on Docker host and list containers matching filters (multiple labels) - docker_host_info: - containers: true - containers_filters: - label: - - key1=value1 - - key2=value2 - register: output + - name: Get info on Docker host and list containers matching filters (multiple labels) + docker_host_info: + containers: true + containers_filters: + label: + - key1=value1 + - key2=value2 + register: output - - name: assert container is returned when filters are matched (multiple labels) - assert: - that: "output.containers | length == 1" + - name: assert container is returned when filters are matched (multiple labels) + assert: + that: "output.containers | length == 1" - - name: Get info on Docker host and do not list containers which do not match filters - docker_host_info: - containers: true - containers_filters: - label: - - key1=value1 - - key2=value2 - - key3=value3 - register: output + - name: Get info on Docker host and do not list containers which do not match filters + docker_host_info: + containers: true + containers_filters: + label: + - key1=value1 + - key2=value2 + - key3=value3 + register: output - - name: assert no container is returned when filters are not matched - assert: - that: "output.containers | length == 0" + - name: assert no container is returned when filters are not matched + assert: + that: "output.containers | length == 0" - - name: Get info on Docker host and list containers matching filters (single label, not all containers) - docker_host_info: - containers: true - containers_all: false - containers_filters: - label: key2=value2 - register: output + - name: Get info on Docker host and list containers matching filters (single label, not all containers) + docker_host_info: + containers: true + containers_all: false + containers_filters: + label: key2=value2 + register: output - - name: Get info on Docker host and list containers matching filters (single label, all containers) - docker_host_info: - containers: true - containers_all: true - containers_filters: - label: key2=value2 - register: output_all + - name: Get info on Docker host and list containers matching filters (single label, all containers) + docker_host_info: + containers: true + containers_all: true + containers_filters: + label: key2=value2 + register: output_all - - name: assert one resp. two container is returned - assert: - that: - - "output.containers | length == 1" - - "output_all.containers | length == 2" + - name: assert one resp. two container is returned + assert: + that: + - "output.containers | length == 1" + - "output_all.containers | length == 2" - - name: Get info on Docker host and list containers with verbose output - docker_host_info: - containers: true - verbose_output: true - register: output + - name: Get info on Docker host and list containers with verbose output + docker_host_info: + containers: true + verbose_output: true + 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: 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: true - register: output + - name: Get info on Docker host and list images + docker_host_info: + images: true + 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: 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: true - verbose_output: true - register: output + - name: Get info on Docker host and list images with verbose output + docker_host_info: + images: true + verbose_output: true + 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: 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: true - register: output + - name: Get info on Docker host and list networks + docker_host_info: + networks: true + 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: 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: true - verbose_output: true - register: output + - name: Get info on Docker host and list networks with verbose output + docker_host_info: + networks: true + verbose_output: true + 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: 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: true - register: output + - name: Get info on Docker host and list volumes + docker_host_info: + volumes: true + 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: 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: true - verbose_output: true - register: output + - name: Get info on Docker host and list volumes with verbose output + docker_host_info: + volumes: true + verbose_output: true + 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: 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: true - register: output + - name: Get info on Docker host and get disk usage + docker_host_info: + disk_usage: true + register: output - - 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.Images is not defined' - - 'output.disk_usage.Containers is not defined' - - 'output.disk_usage.Volumes is not defined' + - 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.Images is not defined' + - 'output.disk_usage.Containers is not defined' + - 'output.disk_usage.Volumes is not defined' - - name: Get info on Docker host and get disk usage with verbose output - docker_host_info: - disk_usage: true - verbose_output: true - register: output + - name: Get info on Docker host and get disk usage with verbose output + docker_host_info: + disk_usage: true + verbose_output: true + 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 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.Images is sequence' - - 'output.disk_usage.Containers is sequence' - - 'output.disk_usage.Volumes is sequence' + - 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.Images is sequence' + - 'output.disk_usage.Containers is sequence' + - 'output.disk_usage.Volumes is sequence' - - name: Get info on Docker host, disk usage and get all lists together - docker_host_info: - volumes: true - containers: true - networks: true - images: true - disk_usage: true - register: output + - name: Get info on Docker host, disk usage and get all lists together + docker_host_info: + volumes: true + containers: true + networks: true + images: true + disk_usage: true + 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' - - 'output.disk_usage.LayersSize is number' - - 'output.disk_usage.Images is not defined' - - 'output.disk_usage.Containers is not defined' - - 'output.disk_usage.Volumes is not defined' + - 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' + - 'output.disk_usage.LayersSize is number' + - 'output.disk_usage.Images is not defined' + - 'output.disk_usage.Containers is not defined' + - 'output.disk_usage.Volumes is not defined' - - name: Get info on Docker host, disk usage and get all lists together with verbose output - docker_host_info: - volumes: true - containers: true - networks: true - images: true - disk_usage: true - verbose_output: true - register: output + - name: Get info on Docker host, disk usage and get all lists together with verbose output + docker_host_info: + volumes: true + containers: true + networks: true + images: true + disk_usage: true + verbose_output: true + 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' - - 'output.disk_usage.LayersSize is number' - - 'output.disk_usage.Images is sequence' - - 'output.disk_usage.Containers is sequence' - - 'output.disk_usage.Volumes is sequence' + - 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' + - 'output.disk_usage.LayersSize is number' + - 'output.disk_usage.Images is sequence' + - 'output.disk_usage.Containers is sequence' + - 'output.disk_usage.Volumes is sequence' always: - - name: Delete containers - docker_container: - name: "{{ item }}" - state: absent - force_kill: true - loop: - - "{{ cname }}" - - "{{ cname2 }}" + - name: Delete containers + docker_container: + name: "{{ item }}" + state: absent + force_kill: true + loop: + - "{{ cname }}" + - "{{ cname2 }}" - - name: Delete volume - docker_volume: - name: "{{ vname }}" - state: absent + - name: Delete volume + docker_volume: + name: "{{ vname }}" + state: absent diff --git a/tests/integration/targets/docker_image/tasks/tests/basic.yml b/tests/integration/targets/docker_image/tasks/tests/basic.yml index 068e92f4..a10cef0e 100644 --- a/tests/integration/targets/docker_image/tasks/tests/basic.yml +++ b/tests/integration/targets/docker_image/tasks/tests/basic.yml @@ -22,7 +22,7 @@ - assert: that: - - absent_2 is not changed + - absent_2 is not changed - name: Make sure image is there docker_image: @@ -44,8 +44,8 @@ - assert: that: - - present_1 is changed - - present_2 is not changed + - present_1 is changed + - present_2 is not changed - name: Make sure tag is not there docker_image: @@ -83,10 +83,10 @@ - assert: that: - - tag_1 is changed - - tag_2 is not changed - - tag_3 is not changed - - tag_4 is not changed + - tag_1 is changed + - tag_2 is not changed + - tag_3 is not changed + - tag_4 is not changed - name: Cleanup alias tag docker_image: @@ -129,11 +129,11 @@ - assert: that: - - fail_1 is failed - - "'`repository` must not be an image ID' in fail_1.msg" - - fail_2 is failed - - "'Cannot push an image by ID' in fail_2.msg" - - fail_3 is failed - - "'Image name must not be an image ID for source=pull' in fail_3.msg" - - fail_4 is failed - - "'Image name must not be an image ID for source=build' in fail_4.msg" + - fail_1 is failed + - "'`repository` must not be an image ID' in fail_1.msg" + - fail_2 is failed + - "'Cannot push an image by ID' in fail_2.msg" + - fail_3 is failed + - "'Image name must not be an image ID for source=pull' in fail_3.msg" + - fail_4 is failed + - "'Image name must not be an image ID for source=build' in fail_4.msg" diff --git a/tests/integration/targets/docker_image/tasks/tests/docker_image.yml b/tests/integration/targets/docker_image/tasks/tests/docker_image.yml index ffd427fd..138ccb14 100644 --- a/tests/integration/targets/docker_image/tasks/tests/docker_image.yml +++ b/tests/integration/targets/docker_image/tasks/tests/docker_image.yml @@ -61,9 +61,9 @@ - assert: that: - - push_1 is changed - - push_2 is not changed - - push_3 is not changed + - push_1 is changed + - push_2 is not changed + - push_3 is not changed - name: Get facts of local image docker_image_info: @@ -102,11 +102,11 @@ - 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 + - 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: Pull image from test registry (with digest) docker_image: @@ -148,8 +148,8 @@ - assert: that: - - push_1_different is changed - - push_2_different is not changed + - push_1_different is changed + - push_2_different is not changed - name: Tag same image with new tag docker_image: @@ -178,24 +178,24 @@ - 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 + # 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 ###################################################### @@ -241,10 +241,10 @@ - assert: that: - - repository_1 is changed - - repository_2 is not changed - - repository_3 is changed - - repository_4 is not changed + - repository_1 is changed + - repository_2 is not changed + - repository_3 is changed + - repository_4 is not changed - name: Get facts of image docker_image_info: @@ -259,4 +259,4 @@ - assert: that: - - facts_1.images | length == 1 + - facts_1.images | length == 1 diff --git a/tests/integration/targets/docker_image/tasks/tests/options.yml b/tests/integration/targets/docker_image/tasks/tests/options.yml index bce63262..b76e1a61 100644 --- a/tests/integration/targets/docker_image/tasks/tests/options.yml +++ b/tests/integration/targets/docker_image/tasks/tests/options.yml @@ -63,8 +63,8 @@ - assert: that: - - buildargs_1 is changed - - buildargs_2 is not failed and buildargs_2 is not changed + - buildargs_1 is changed + - buildargs_2 is not failed and buildargs_2 is not changed #################################################################### ## build.container_limits ########################################## @@ -102,14 +102,14 @@ - 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)" + # 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 ################################################ @@ -133,9 +133,9 @@ - assert: that: - - dockerfile_1 is changed - - "('FROM ' ~ docker_test_image_alpine) in dockerfile_1.stdout" - - dockerfile_1['image']['Config']['WorkingDir'] == '/newdata' + - dockerfile_1 is changed + - "('FROM ' ~ docker_test_image_alpine) in dockerfile_1.stdout" + - dockerfile_1['image']['Config']['WorkingDir'] == '/newdata' #################################################################### ## build.platform ################################################## @@ -177,8 +177,8 @@ - assert: that: - - platform_1 is changed - - platform_2 is not failed and platform_2 is not changed + - platform_1 is changed + - platform_2 is not failed and platform_2 is not changed #################################################################### ## force ########################################################### @@ -222,8 +222,8 @@ - assert: that: - - force_1 is changed - - force_2 is not changed + - force_1 is changed + - force_2 is not changed #################################################################### ## load path ####################################################### @@ -350,15 +350,15 @@ - 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 not changed + - 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 not changed #################################################################### ## build.path ###################################################### @@ -416,8 +416,8 @@ - assert: that: - - dockerfile_2 is changed - - dockerfile_2.image.Config.WorkingDir == '/first' + - dockerfile_2 is changed + - dockerfile_2.image.Config.WorkingDir == '/first' #################################################################### ## build.etc_hosts ################################################# diff --git a/tests/integration/targets/docker_image_build/tasks/tests/options.yml b/tests/integration/targets/docker_image_build/tasks/tests/options.yml index 77afec21..9135f88f 100644 --- a/tests/integration/targets/docker_image_build/tasks/tests/options.yml +++ b/tests/integration/targets/docker_image_build/tasks/tests/options.yml @@ -51,8 +51,8 @@ - assert: that: - - buildargs_1 is changed - - buildargs_2 is not changed + - buildargs_1 is changed + - buildargs_2 is not changed #################################################################### ## dockerfile ###################################################### @@ -72,9 +72,9 @@ - assert: that: - - dockerfile_1 is changed - - "('FROM ' ~ docker_test_image_alpine) in dockerfile_1.stderr" - - dockerfile_1['image']['Config']['WorkingDir'] == '/newdata' + - dockerfile_1 is changed + - "('FROM ' ~ docker_test_image_alpine) in dockerfile_1.stderr" + - dockerfile_1['image']['Config']['WorkingDir'] == '/newdata' #################################################################### ## platform ######################################################## @@ -106,8 +106,8 @@ - assert: that: - - platform_1 is changed - - platform_2 is not changed + - platform_1 is changed + - platform_2 is not changed #################################################################### ## target ########################################################## @@ -128,8 +128,8 @@ - assert: that: - - dockerfile_2 is changed - - dockerfile_2.image.Config.WorkingDir == '/first' + - dockerfile_2 is changed + - dockerfile_2.image.Config.WorkingDir == '/first' #################################################################### ## etc_hosts ####################################################### diff --git a/tests/integration/targets/docker_image_info/tasks/main.yml b/tests/integration/targets/docker_image_info/tasks/main.yml index 289a9cf1..1ff8b7d3 100644 --- a/tests/integration/targets/docker_image_info/tasks/main.yml +++ b/tests/integration/targets/docker_image_info/tasks/main.yml @@ -9,50 +9,50 @@ #################################################################### - block: - - name: Make sure image is not there - docker_image_remove: - name: "{{ docker_test_image_alpine_different }}" + - name: Make sure image is not there + docker_image_remove: + name: "{{ docker_test_image_alpine_different }}" - - name: Inspect a non-available image - docker_image_info: - name: "{{ docker_test_image_alpine_different }}" - register: result + - name: Inspect a non-available image + docker_image_info: + name: "{{ docker_test_image_alpine_different }}" + register: result - - assert: - that: - - "result.images|length == 0" + - assert: + that: + - "result.images|length == 0" - - name: Make sure images are there - docker_image_pull: - name: "{{ item }}" - loop: - - "{{ docker_test_image_hello_world }}" - - "{{ docker_test_image_alpine }}" + - name: Make sure images are there + docker_image_pull: + name: "{{ item }}" + 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 + - 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" + - 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 + - name: Inspect multiple images + docker_image_info: + name: + - "{{ docker_test_image_hello_world }}" + - "{{ docker_test_image_alpine }}" + register: result - - debug: var=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" + - 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_api_version is version('1.25', '>=') diff --git a/tests/integration/targets/docker_image_pull/tasks/tests/basic.yml b/tests/integration/targets/docker_image_pull/tasks/tests/basic.yml index de337917..998549e4 100644 --- a/tests/integration/targets/docker_image_pull/tasks/tests/basic.yml +++ b/tests/integration/targets/docker_image_pull/tasks/tests/basic.yml @@ -117,55 +117,55 @@ - assert: that: - - present_1_check is changed - - present_1_check.actions | length == 1 - - present_1_check.actions[0] == ('Pulled image ' ~ image_name) - - present_1_check.diff.before.exists is false - - present_1_check.diff.after.id == 'unknown' - - present_1 is changed - - present_1.actions | length == 1 - - present_1.actions[0] == ('Pulled image ' ~ image_name) - - present_1.diff.before.exists is false - - present_1.diff.after.id is string - - present_2_check is changed - - present_2_check.actions | length == 1 - - present_2_check.actions[0] == ('Pulled image ' ~ image_name) - - present_2_check.diff.before.id == present_1.diff.after.id - - present_2_check.diff.after.id == 'unknown' - - present_2 is not changed - - present_2.actions | length == 1 - - present_2.actions[0] == ('Pulled image ' ~ image_name) - - present_2.diff.before.id == present_1.diff.after.id - - present_2.diff.after.id == present_1.diff.after.id - - present_3_check is changed - - present_3_check.actions | length == 1 - - present_3_check.actions[0] == ('Pulled image ' ~ image_name) - - present_3_check.diff.before.id == present_1.diff.after.id - - present_3_check.diff.after.id == 'unknown' - - present_3 is changed - - present_3.actions | length == 1 - - present_3.actions[0] == ('Pulled image ' ~ image_name) - - present_3.diff.before.id == present_1.diff.after.id - - present_3.diff.after.id != present_1.diff.after.id - - present_3.diff.after.id is string - - present_4_check is not changed - - present_4_check.actions | length == 0 - - present_4_check.diff.before.id == present_3.diff.after.id - - present_4_check.diff.after.id == present_3.diff.after.id - - present_4 is not changed - - present_4.actions | length == 0 - - present_4.diff.before.id == present_3.diff.after.id - - present_4.diff.after.id == present_3.diff.after.id - - present_5_check is changed - - present_5_check.actions | length == 1 - - present_5_check.actions[0] == ('Pulled image ' ~ image_name) - - present_5_check.diff.before.id == present_3.diff.after.id - - present_5_check.diff.after.id == 'unknown' - - present_5 is changed - - present_5.actions | length == 1 - - present_5.actions[0] == ('Pulled image ' ~ image_name) - - present_5.diff.before.id == present_3.diff.after.id - - present_5.diff.after.id == present_1.diff.after.id + - present_1_check is changed + - present_1_check.actions | length == 1 + - present_1_check.actions[0] == ('Pulled image ' ~ image_name) + - present_1_check.diff.before.exists is false + - present_1_check.diff.after.id == 'unknown' + - present_1 is changed + - present_1.actions | length == 1 + - present_1.actions[0] == ('Pulled image ' ~ image_name) + - present_1.diff.before.exists is false + - present_1.diff.after.id is string + - present_2_check is changed + - present_2_check.actions | length == 1 + - present_2_check.actions[0] == ('Pulled image ' ~ image_name) + - present_2_check.diff.before.id == present_1.diff.after.id + - present_2_check.diff.after.id == 'unknown' + - present_2 is not changed + - present_2.actions | length == 1 + - present_2.actions[0] == ('Pulled image ' ~ image_name) + - present_2.diff.before.id == present_1.diff.after.id + - present_2.diff.after.id == present_1.diff.after.id + - present_3_check is changed + - present_3_check.actions | length == 1 + - present_3_check.actions[0] == ('Pulled image ' ~ image_name) + - present_3_check.diff.before.id == present_1.diff.after.id + - present_3_check.diff.after.id == 'unknown' + - present_3 is changed + - present_3.actions | length == 1 + - present_3.actions[0] == ('Pulled image ' ~ image_name) + - present_3.diff.before.id == present_1.diff.after.id + - present_3.diff.after.id != present_1.diff.after.id + - present_3.diff.after.id is string + - present_4_check is not changed + - present_4_check.actions | length == 0 + - present_4_check.diff.before.id == present_3.diff.after.id + - present_4_check.diff.after.id == present_3.diff.after.id + - present_4 is not changed + - present_4.actions | length == 0 + - present_4.diff.before.id == present_3.diff.after.id + - present_4.diff.after.id == present_3.diff.after.id + - present_5_check is changed + - present_5_check.actions | length == 1 + - present_5_check.actions[0] == ('Pulled image ' ~ image_name) + - present_5_check.diff.before.id == present_3.diff.after.id + - present_5_check.diff.after.id == 'unknown' + - present_5 is changed + - present_5.actions | length == 1 + - present_5.actions[0] == ('Pulled image ' ~ image_name) + - present_5.diff.before.id == present_3.diff.after.id + - present_5.diff.after.id == present_1.diff.after.id always: - name: cleanup @@ -188,9 +188,9 @@ - assert: that: - - fail_1 is failed - - >- - 'Cannot pull an image by ID' == fail_1.msg - - fail_2 is failed - - >- - '"foo/bar" is not a valid docker tag!' == fail_2.msg + - fail_1 is failed + - >- + 'Cannot pull an image by ID' == fail_1.msg + - fail_2 is failed + - >- + '"foo/bar" is not a valid docker tag!' == fail_2.msg diff --git a/tests/integration/targets/docker_image_pull/tasks/tests/image-ids.yml b/tests/integration/targets/docker_image_pull/tasks/tests/image-ids.yml index bdbc93a2..77552943 100644 --- a/tests/integration/targets/docker_image_pull/tasks/tests/image-ids.yml +++ b/tests/integration/targets/docker_image_pull/tasks/tests/image-ids.yml @@ -35,20 +35,20 @@ - assert: that: - - present_1 is changed - - present_1.actions | length == 1 - - present_1.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v1) - - present_1.diff.before.exists is false - - present_1.diff.after.id is string - - present_2 is not changed - - present_2.actions | length == 1 - - present_2.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v1) - - present_2.diff.before.id == present_1.diff.after.id - - present_2.diff.after.id == present_1.diff.after.id - - present_3 is not changed - - present_3.actions | length == 0 - - present_3.diff.before.id == present_1.diff.after.id - - present_3.diff.after.id == present_1.diff.after.id + - present_1 is changed + - present_1.actions | length == 1 + - present_1.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v1) + - present_1.diff.before.exists is false + - present_1.diff.after.id is string + - present_2 is not changed + - present_2.actions | length == 1 + - present_2.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v1) + - present_2.diff.before.id == present_1.diff.after.id + - present_2.diff.after.id == present_1.diff.after.id + - present_3 is not changed + - present_3.actions | length == 0 + - present_3.diff.before.id == present_1.diff.after.id + - present_3.diff.after.id == present_1.diff.after.id - name: Pull image 2 (check mode) docker_image_pull: @@ -67,17 +67,17 @@ - assert: that: - - present_4 is changed - - present_4.actions | length == 1 - - present_4.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v2) - - present_4.diff.before.exists is false - - present_4.diff.after.id == 'unknown' - - present_5 is changed - - present_5.actions | length == 1 - - present_5.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v2) - - present_5.diff.before.exists is false - - present_5.diff.after.id != present_1.diff.after.id - - present_5.diff.after.id is string + - present_4 is changed + - present_4.actions | length == 1 + - present_4.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v2) + - present_4.diff.before.exists is false + - present_4.diff.after.id == 'unknown' + - present_5 is changed + - present_5.actions | length == 1 + - present_5.actions[0] == ('Pulled image ' ~ docker_test_image_digest_base ~ ':sha256:' ~ docker_test_image_digest_v2) + - present_5.diff.before.exists is false + - present_5.diff.after.id != present_1.diff.after.id + - present_5.diff.after.id is string always: - name: cleanup diff --git a/tests/integration/targets/docker_image_pull/tasks/tests/registry.yml b/tests/integration/targets/docker_image_pull/tasks/tests/registry.yml index 2edc3b62..bb4298bd 100644 --- a/tests/integration/targets/docker_image_pull/tasks/tests/registry.yml +++ b/tests/integration/targets/docker_image_pull/tasks/tests/registry.yml @@ -103,24 +103,24 @@ - assert: that: - - pull_1_check is changed - - pull_1_check.diff.before.exists is false - - pull_1_check.diff.after.id == 'unknown' - - pull_1 is changed - - pull_1.diff.before.exists is false - - pull_1.diff.after.id == facts_1.images[0].Id - - pull_2_check is not changed - - pull_2_check.diff.before.id == facts_1.images[0].Id - - pull_2_check.diff.before == pull_2.diff.after - - pull_2 is not changed - - pull_2.diff.before.id == facts_1.images[0].Id - - pull_2.diff.before == pull_2.diff.after - - pull_3_check is changed - - pull_3_check.diff.before.id == facts_1.images[0].Id - - pull_3_check.diff.after.id == 'unknown' - - pull_3 is not changed - - pull_3.diff.before.id == facts_1.images[0].Id - - pull_3.diff.before == pull_2.diff.after - - facts_1.images | length == 1 - - facts_2.images | length == 0 - - facts_3.images | length == 1 + - pull_1_check is changed + - pull_1_check.diff.before.exists is false + - pull_1_check.diff.after.id == 'unknown' + - pull_1 is changed + - pull_1.diff.before.exists is false + - pull_1.diff.after.id == facts_1.images[0].Id + - pull_2_check is not changed + - pull_2_check.diff.before.id == facts_1.images[0].Id + - pull_2_check.diff.before == pull_2.diff.after + - pull_2 is not changed + - pull_2.diff.before.id == facts_1.images[0].Id + - pull_2.diff.before == pull_2.diff.after + - pull_3_check is changed + - pull_3_check.diff.before.id == facts_1.images[0].Id + - pull_3_check.diff.after.id == 'unknown' + - pull_3 is not changed + - pull_3.diff.before.id == facts_1.images[0].Id + - pull_3.diff.before == pull_2.diff.after + - facts_1.images | length == 1 + - facts_2.images | length == 0 + - facts_3.images | length == 1 diff --git a/tests/integration/targets/docker_image_push/tasks/tests/basic.yml b/tests/integration/targets/docker_image_push/tasks/tests/basic.yml index 15ed8744..bbbfc551 100644 --- a/tests/integration/targets/docker_image_push/tasks/tests/basic.yml +++ b/tests/integration/targets/docker_image_push/tasks/tests/basic.yml @@ -43,18 +43,18 @@ - assert: that: - - fail_1 is failed - - >- - 'Cannot find image registry.example.com:5000/foo/bar:baz' == fail_1.msg - - fail_2 is failed - - >- - 'Cannot push an image by ID' == fail_2.msg - - fail_3 is failed - - >- - 'Cannot push an image by digest' == fail_3.msg - - fail_4 is failed - - >- - '"foo/bar" is not a valid docker tag!' == fail_4.msg - - fail_5 is failed - - >- - '"foo bar" is not a valid docker tag!' == fail_5.msg + - fail_1 is failed + - >- + 'Cannot find image registry.example.com:5000/foo/bar:baz' == fail_1.msg + - fail_2 is failed + - >- + 'Cannot push an image by ID' == fail_2.msg + - fail_3 is failed + - >- + 'Cannot push an image by digest' == fail_3.msg + - fail_4 is failed + - >- + '"foo/bar" is not a valid docker tag!' == fail_4.msg + - fail_5 is failed + - >- + '"foo bar" is not a valid docker tag!' == fail_5.msg diff --git a/tests/integration/targets/docker_login/tasks/tests/docker_login.yml b/tests/integration/targets/docker_login/tasks/tests/docker_login.yml index efb3efc1..6b3c4086 100644 --- a/tests/integration/targets/docker_login/tasks/tests/docker_login.yml +++ b/tests/integration/targets/docker_login/tasks/tests/docker_login.yml @@ -4,147 +4,147 @@ # SPDX-License-Identifier: GPL-3.0-or-later - block: - - name: Log out server - docker_login: - registry_url: "{{ registry_frontend_address }}" - username: testuser - password: hunter2 - state: absent + - name: Log out server + docker_login: + registry_url: "{{ registry_frontend_address }}" + username: testuser + password: hunter2 + state: absent - - 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: true - check_mode: true + - 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: true + check_mode: true - - name: Log in with wrong password - docker_login: - registry_url: "{{ registry_frontend_address }}" - username: testuser - password: "1234" - state: present - register: login_failed - ignore_errors: true + - name: Log in with wrong password + docker_login: + registry_url: "{{ registry_frontend_address }}" + username: testuser + password: "1234" + state: present + register: login_failed + ignore_errors: true - - 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: 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: true + - name: Log in (check mode) + docker_login: + registry_url: "{{ registry_frontend_address }}" + username: testuser + password: hunter2 + state: present + register: login_1 + check_mode: true - - name: Log in - docker_login: - registry_url: "{{ registry_frontend_address }}" - username: testuser - password: hunter2 - state: present - register: login_2 + - 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: 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) + 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: true + - name: Log in (idempotent, check mode) + docker_login: + registry_url: "{{ registry_frontend_address }}" + username: testuser + password: hunter2 + state: present + register: login_4 + check_mode: true - - 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: 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: true - check_mode: true + - 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: true + check_mode: true - - 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: true + - 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: true - - 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: 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: true + - name: Log out (check mode) + docker_login: + registry_url: "{{ registry_frontend_address }}" + state: absent + register: logout_1 + check_mode: true - - name: Log out - docker_login: - registry_url: "{{ registry_frontend_address }}" - state: absent - register: logout_2 + - 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) + 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: true + - name: Log out (idempotent, check mode) + docker_login: + registry_url: "{{ registry_frontend_address }}" + state: absent + register: logout_4 + check_mode: true - - 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 + - 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/tests/integration/targets/docker_login/tasks/tests/multiple-servers.yml b/tests/integration/targets/docker_login/tasks/tests/multiple-servers.yml index 7ffd0978..1d79f5e7 100644 --- a/tests/integration/targets/docker_login/tasks/tests/multiple-servers.yml +++ b/tests/integration/targets/docker_login/tasks/tests/multiple-servers.yml @@ -4,58 +4,58 @@ # SPDX-License-Identifier: GPL-3.0-or-later - block: - - name: Log out server 1 - docker_login: - registry_url: "{{ registry_frontend_address }}" - username: testuser - password: hunter2 - state: absent + - 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 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 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 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 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: 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 + - 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/tests/integration/targets/docker_network/tasks/tests/basic.yml b/tests/integration/targets/docker_network/tasks/tests/basic.yml index 1a419c73..28aa0082 100644 --- a/tests/integration/targets/docker_network/tasks/tests/basic.yml +++ b/tests/integration/targets/docker_network/tasks/tests/basic.yml @@ -22,9 +22,9 @@ command: /bin/sleep 10m state: started loop: - - "{{ cname_1 }}" - - "{{ cname_2 }}" - - "{{ cname_3 }}" + - "{{ cname_1 }}" + - "{{ cname_2 }}" + - "{{ cname_3 }}" loop_control: loop_var: container_name @@ -41,7 +41,7 @@ name: "{{ nname_1 }}" state: present connected: - - "{{ cname_1 }}" + - "{{ cname_1 }}" register: networks_2 - name: Connect network to containers 1 (idempotency) @@ -49,7 +49,7 @@ name: "{{ nname_1 }}" state: present connected: - - "{{ cname_1 }}" + - "{{ cname_1 }}" register: networks_2_idem - name: Connect network to containers 1 and 2 @@ -57,8 +57,8 @@ name: "{{ nname_1 }}" state: present connected: - - "{{ cname_1 }}" - - "{{ cname_2 }}" + - "{{ cname_1 }}" + - "{{ cname_2 }}" register: networks_3 - name: Connect network to containers 1 and 2 (idempotency) @@ -66,8 +66,8 @@ name: "{{ nname_1 }}" state: present connected: - - "{{ cname_1 }}" - - "{{ cname_2 }}" + - "{{ cname_1 }}" + - "{{ cname_2 }}" register: networks_3_idem - name: Connect network to container 3 @@ -75,7 +75,7 @@ name: "{{ nname_1 }}" state: present connected: - - "{{ cname_3 }}" + - "{{ cname_3 }}" appends: true register: networks_4 @@ -84,7 +84,7 @@ name: "{{ nname_1 }}" state: present connected: - - "{{ cname_3 }}" + - "{{ cname_3 }}" appends: true register: networks_4_idem @@ -93,8 +93,8 @@ name: "{{ nname_1 }}" state: present connected: - - "{{ cname_2 }}" - - "{{ cname_3 }}" + - "{{ cname_2 }}" + - "{{ cname_3 }}" register: networks_5 - name: Disconnect network from container 1 (idempotency) @@ -102,8 +102,8 @@ name: "{{ nname_1 }}" state: present connected: - - "{{ cname_2 }}" - - "{{ cname_3 }}" + - "{{ cname_2 }}" + - "{{ cname_3 }}" register: networks_5_idem - name: Cleanup @@ -113,15 +113,15 @@ - 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 + - 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 #################################################################### @@ -131,8 +131,8 @@ state: absent force_kill: true loop: - - "{{ cname_1 }}" - - "{{ cname_2 }}" - - "{{ cname_3 }}" + - "{{ cname_1 }}" + - "{{ cname_2 }}" + - "{{ cname_3 }}" loop_control: loop_var: container_name diff --git a/tests/integration/targets/docker_network/tasks/tests/ipam.yml b/tests/integration/targets/docker_network/tasks/tests/ipam.yml index 7091e95f..4c74c72d 100644 --- a/tests/integration/targets/docker_network/tasks/tests/ipam.yml +++ b/tests/integration/targets/docker_network/tasks/tests/ipam.yml @@ -200,71 +200,71 @@ #################### 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: 10.26.120.0/24 - - subnet: 10.26.121.0/24 - register: network + - 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: 10.26.120.0/24 + - subnet: 10.26.121.0/24 + register: network - - assert: - that: - - network is changed + - 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: 10.26.121.0/24 - - subnet: 10.26.120.0/24 - register: network + - 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: 10.26.121.0/24 + - subnet: 10.26.120.0/24 + register: network - - assert: - that: - - network is not changed + - 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: 10.26.120.0/24 - - subnet: 10.26.122.0/24 - register: network - diff: true + - 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: 10.26.120.0/24 + - subnet: 10.26.122.0/24 + register: network + diff: true - - assert: - that: - - network is changed - - network.diff.differences | length == 1 + - 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: 10.26.122.0/24 - register: network + - 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: 10.26.122.0/24 + register: network - - assert: - that: - - network is not changed + - assert: + that: + - network is not changed - - name: Cleanup network - docker_network: - name: "{{ nname_ipam_3 }}" - state: absent + - name: Cleanup network + docker_network: + name: "{{ nname_ipam_3 }}" + state: absent when: ansible_facts.virtualization_type != 'docker' and ansible_default_ipv4.alias is defined diff --git a/tests/integration/targets/docker_network/tasks/tests/options.yml b/tests/integration/targets/docker_network/tasks/tests/options.yml index d2e39739..15aa6dbb 100644 --- a/tests/integration/targets/docker_network/tasks/tests/options.yml +++ b/tests/integration/targets/docker_network/tasks/tests/options.yml @@ -40,9 +40,9 @@ - assert: that: - - internal_1 is changed - - internal_2 is not changed - - internal_3 is changed + - internal_1 is changed + - internal_2 is not changed + - internal_3 is changed #################################################################### ## driver_options ################################################## @@ -91,62 +91,62 @@ - 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 + - 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 + 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: 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 | default('127.0.0.1') }}" + - name: swarm + docker_swarm: + state: present + advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}" - # 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 + # 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: true + - name: cleanup network + docker_network: + name: "{{ nname_1 }}" + state: absent + force: true - - assert: - that: - - scope_1 is changed - - scope_2 is not changed - - scope_3 is changed + - assert: + that: + - scope_1 is changed + - scope_2 is not changed + - scope_3 is changed always: - - name: cleanup swarm - docker_swarm: - state: absent - force: true + - name: cleanup swarm + docker_swarm: + state: absent + force: true #################################################################### ## attachable ###################################################### @@ -158,21 +158,21 @@ attachable: true register: attachable_1 ignore_errors: true - + - name: attachable (idempotency) docker_network: name: "{{ nname_1 }}" attachable: true register: attachable_2 ignore_errors: true - + - name: attachable (change) docker_network: name: "{{ nname_1 }}" attachable: false register: attachable_3 ignore_errors: true - + - name: cleanup docker_network: name: "{{ nname_1 }}" @@ -181,9 +181,9 @@ - assert: that: - - attachable_1 is changed - - attachable_2 is not changed - - attachable_3 is changed + - attachable_1 is changed + - attachable_2 is not changed + - attachable_3 is changed #################################################################### ## labels ########################################################## @@ -228,7 +228,7 @@ - assert: that: - - labels_1 is changed - - labels_2 is not changed - - labels_3 is not changed - - labels_4 is changed + - labels_1 is changed + - labels_2 is not changed + - labels_3 is not changed + - labels_4 is changed diff --git a/tests/integration/targets/docker_network/tasks/tests/overlay.yml b/tests/integration/targets/docker_network/tasks/tests/overlay.yml index e936cd60..53a8e5bc 100644 --- a/tests/integration/targets/docker_network/tasks/tests/overlay.yml +++ b/tests/integration/targets/docker_network/tasks/tests/overlay.yml @@ -11,94 +11,94 @@ dnetworks: "{{ dnetworks + [nname_1] }}" - block: - # Overlay networks require swarm initialization before they'll work - - name: swarm - docker_swarm: - state: present - advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}" + # Overlay networks require swarm initialization before they'll work + - name: swarm + docker_swarm: + state: present + advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}" -#################################################################### -## overlay ######################################################### -#################################################################### + #################################################################### + ## overlay ######################################################### + #################################################################### - - name: overlay - docker_network: - name: "{{ nname_1 }}" - driver: overlay - driver_options: - com.docker.network.driver.overlay.vxlanid_list: "257" - register: overlay_1 + - 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 (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: overlay (change) + docker_network: + name: "{{ nname_1 }}" + driver: bridge + register: overlay_3 - - name: cleanup network - docker_network: - name: "{{ nname_1 }}" - state: absent - force: true + - name: cleanup network + docker_network: + name: "{{ nname_1 }}" + state: absent + force: true - - assert: - that: - - overlay_1 is changed - - overlay_2 is not changed - - overlay_3 is changed + - assert: + that: + - overlay_1 is changed + - overlay_2 is not changed + - overlay_3 is changed -#################################################################### -## ingress ######################################################### -#################################################################### + #################################################################### + ## ingress ######################################################### + #################################################################### - - name: cleanup default swarm ingress network - docker_network: - name: ingress - state: absent + - name: cleanup default swarm ingress network + docker_network: + name: ingress + state: absent - - name: ingress - docker_network: - name: "{{ nname_1 }}" - driver: overlay - ingress: true - register: ingress_1 + - name: ingress + docker_network: + name: "{{ nname_1 }}" + driver: overlay + ingress: true + register: ingress_1 - - name: ingress (idempotency) - docker_network: - name: "{{ nname_1 }}" - driver: overlay - ingress: true - register: ingress_2 + - name: ingress (idempotency) + docker_network: + name: "{{ nname_1 }}" + driver: overlay + ingress: true + register: ingress_2 - - name: ingress (change) - docker_network: - name: "{{ nname_1 }}" - driver: overlay - ingress: false - register: ingress_3 + - name: ingress (change) + docker_network: + name: "{{ nname_1 }}" + driver: overlay + ingress: false + register: ingress_3 - - name: cleanup network - docker_network: - name: "{{ nname_1 }}" - state: absent - force: true + - name: cleanup network + docker_network: + name: "{{ nname_1 }}" + state: absent + force: true - - assert: - that: - - ingress_1 is changed - - ingress_2 is not changed - - ingress_3 is changed + - assert: + that: + - ingress_1 is changed + - ingress_2 is not changed + - ingress_3 is changed always: - - name: cleanup swarm - docker_swarm: - state: absent - force: true + - name: cleanup swarm + docker_swarm: + state: absent + force: true diff --git a/tests/integration/targets/docker_network/tasks/tests/substring.yml b/tests/integration/targets/docker_network/tasks/tests/substring.yml index b4b37b27..61b5a8bf 100644 --- a/tests/integration/targets/docker_network/tasks/tests/substring.yml +++ b/tests/integration/targets/docker_network/tasks/tests/substring.yml @@ -30,12 +30,12 @@ name: "{{ network_name }}" state: absent loop: - - "{{ nname_1 }}" - - "{{ nname_2 }}" + - "{{ nname_1 }}" + - "{{ nname_2 }}" loop_control: loop_var: network_name - assert: that: - - networks_1 is changed - - networks_2 is changed + - networks_1 is changed + - networks_2 is changed diff --git a/tests/integration/targets/docker_network_info/tasks/main.yml b/tests/integration/targets/docker_network_info/tasks/main.yml index a12154ca..e31ffa51 100644 --- a/tests/integration/targets/docker_network_info/tasks/main.yml +++ b/tests/integration/targets/docker_network_info/tasks/main.yml @@ -9,70 +9,70 @@ #################################################################### - block: - - name: Create random network name - set_fact: - nname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}" + - name: Create random network name + set_fact: + nname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}" - - name: Make sure network is not there - docker_network: - name: "{{ nname }}" - state: absent - force: true + - name: Make sure network is not there + docker_network: + name: "{{ nname }}" + state: absent + force: true - - name: Inspect a non-present network - docker_network_info: - name: "{{ nname }}" - register: result + - 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" + - assert: + that: + - "not result.exists" + - "'network' in result" + - "result.network is none" - - name: Make sure network exists - docker_network: - name: "{{ nname }}" - state: present + - 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: 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: true - - 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: "Comparison: use 'docker network inspect'" + command: docker network inspect "{{ nname }}" + register: docker_inspect + ignore_errors: true + - 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: true + - name: Cleanup + docker_network: + name: "{{ nname }}" + state: absent + force: true - - assert: - that: - - result.exists - - "'network' in result" - - "result.network is truthy" + - assert: + that: + - result.exists + - "'network' in result" + - "result.network is truthy" - - 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 + - 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_api_version is version('1.25', '>=') diff --git a/tests/integration/targets/docker_node/tasks/main.yml b/tests/integration/targets/docker_node/tasks/main.yml index 68bb5426..c4d3ccf4 100644 --- a/tests/integration/targets/docker_node/tasks/main.yml +++ b/tests/integration/targets/docker_node/tasks/main.yml @@ -10,30 +10,30 @@ # Run the tests - block: - - include_tasks: test_node.yml + - include_tasks: test_node.yml always: - - name: Cleanup (trying) - docker_swarm: - state: absent - force: true - diff: false - ignore_errors: true + - name: Cleanup (trying) + docker_swarm: + state: absent + force: true + diff: false + ignore_errors: true - - name: Restart docker daemon - service: - name: docker - state: restarted - become: true - - name: Wait for docker daemon to be fully restarted - command: docker ps - ignore_errors: true + - name: Restart docker daemon + service: + name: docker + state: restarted + become: true + - name: Wait for docker daemon to be fully restarted + command: docker ps + ignore_errors: true - - name: Cleanup - docker_swarm: - state: absent - force: true - diff: false + - name: Cleanup + docker_swarm: + state: absent + force: true + diff: false when: docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=') diff --git a/tests/integration/targets/docker_node/tasks/test_node.yml b/tests/integration/targets/docker_node/tasks/test_node.yml index 41ee1837..100983e5 100644 --- a/tests/integration/targets/docker_node/tasks/test_node.yml +++ b/tests/integration/targets/docker_node/tasks/test_node.yml @@ -4,841 +4,841 @@ # SPDX-License-Identifier: GPL-3.0-or-later - 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: true - 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: ")) is truthy' - - 'output.swarm_facts.JoinTokens.Manager is truthy' - - 'output.swarm_facts.JoinTokens.Worker is truthy' - - - 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: true - 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: true - 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: true - register: set_as_worker_1 - - - name: Try to set node as worker - docker_node: - hostname: "{{ nodeid }}" - role: worker - ignore_errors: true - 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")) is truthy' - -#################################################################### -## Set node as pasued ############################################## -#################################################################### - - - name: Try to set node availability as paused (check) - docker_node: - hostname: "{{ nodeid }}" - availability: pause - check_mode: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - 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: true - register: output_add_del_overlap_labels_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_labels_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_labels_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: true - register: output_add_del_overlap_labels_4 - - - name: assert adding or updating and removing overlapping labels from swarm node - assert: - that: - - 'output_add_del_overlap_labels_1 is changed' - - 'output_add_del_overlap_labels_2 is changed' - - 'output_add_del_overlap_labels_3 is not changed' - - 'output_add_del_overlap_labels_4 is not changed' - - 'output_add_del_overlap_labels_2.node.Spec.Labels | length == 3' - - '"label7" not in output_add_del_overlap_labels_2.node.Spec.Labels' - - 'output_add_del_overlap_labels_2.node.Spec.Labels.label6 == "value6666"' - - 'output_add_del_overlap_labels_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: true - 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: true - 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: true - 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: true - register: output_remove_labels_4 - - - name: assert removing all labels 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' + - 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: true + 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: ")) is truthy' + - 'output.swarm_facts.JoinTokens.Manager is truthy' + - 'output.swarm_facts.JoinTokens.Worker is truthy' + + - 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: true + 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: true + 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: true + register: set_as_worker_1 + + - name: Try to set node as worker + docker_node: + hostname: "{{ nodeid }}" + role: worker + ignore_errors: true + 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")) is truthy' + + #################################################################### + ## Set node as pasued ############################################## + #################################################################### + + - name: Try to set node availability as paused (check) + docker_node: + hostname: "{{ nodeid }}" + availability: pause + check_mode: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + 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: true + register: output_add_del_overlap_labels_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_labels_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_labels_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: true + register: output_add_del_overlap_labels_4 + + - name: assert adding or updating and removing overlapping labels from swarm node + assert: + that: + - 'output_add_del_overlap_labels_1 is changed' + - 'output_add_del_overlap_labels_2 is changed' + - 'output_add_del_overlap_labels_3 is not changed' + - 'output_add_del_overlap_labels_4 is not changed' + - 'output_add_del_overlap_labels_2.node.Spec.Labels | length == 3' + - '"label7" not in output_add_del_overlap_labels_2.node.Spec.Labels' + - 'output_add_del_overlap_labels_2.node.Spec.Labels.label6 == "value6666"' + - 'output_add_del_overlap_labels_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: true + 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: true + 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: true + 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: true + register: output_remove_labels_4 + + - name: assert removing all labels 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 + - name: Cleanup + docker_swarm: + state: absent + force: true diff --git a/tests/integration/targets/docker_node_info/tasks/test_node_info.yml b/tests/integration/targets/docker_node_info/tasks/test_node_info.yml index 7bfd588f..97cf334b 100644 --- a/tests/integration/targets/docker_node_info/tasks/test_node_info.yml +++ b/tests/integration/targets/docker_node_info/tasks/test_node_info.yml @@ -4,89 +4,89 @@ # SPDX-License-Identifier: GPL-3.0-or-later - block: - - name: Make sure we're not already using Docker swarm - docker_swarm: - state: absent - force: true + - 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: true - register: output + - name: Try to get docker_node_info when docker is not running in swarm mode + docker_node_info: + ignore_errors: true + 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: 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 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: ")) is truthy' - - 'output.swarm_facts.JoinTokens.Manager is truthy' - - 'output.swarm_facts.JoinTokens.Worker is truthy' + - name: assert changed when create a new swarm cluster + assert: + that: + - 'output is changed' + - '(output.actions[0] | regex_search("New Swarm cluster created: ")) is truthy' + - 'output.swarm_facts.JoinTokens.Manager is truthy' + - 'output.swarm_facts.JoinTokens.Worker is truthy' - - name: Try to get docker_node_info when docker is running in swarm mode and as manager - docker_node_info: - register: output + - 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: 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: true - register: output + - name: Try to get docker_node_info using the self parameter + docker_node_info: + self: true + 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: 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: 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: 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: 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: 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: 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' + - 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 + - name: Cleanup + docker_swarm: + state: absent + force: true diff --git a/tests/integration/targets/docker_plugin/tasks/tests/basic.yml b/tests/integration/targets/docker_plugin/tasks/tests/basic.yml index 8ea6058c..970b1cc8 100644 --- a/tests/integration/targets/docker_plugin/tasks/tests/basic.yml +++ b/tests/integration/targets/docker_plugin/tasks/tests/basic.yml @@ -126,22 +126,22 @@ - assert: that: - - create_1_check is changed - - create_1 is changed - - create_2_check is not changed - - create_2 is not changed - - create_3_check is changed - - create_3 is changed - - create_4_check is not changed - - create_4 is not changed - - absent_1_check is changed - - absent_1 is changed - - absent_2_check is not changed - - absent_2 is not changed - - absent_3_check is changed - - absent_3 is changed - - absent_4_check is not changed - - absent_4 is not changed + - create_1_check is changed + - create_1 is changed + - create_2_check is not changed + - create_2 is not changed + - create_3_check is changed + - create_3 is changed + - create_4_check is not changed + - create_4 is not changed + - absent_1_check is changed + - absent_1 is changed + - absent_2_check is not changed + - absent_2 is not changed + - absent_3_check is changed + - absent_3 is changed + - absent_4_check is not changed + - absent_4 is not changed ############ Plugin_Options ############ ######################################## @@ -186,7 +186,7 @@ - assert: that: - - create_1 is changed - - create_2 is not changed - - update_1 is changed - - update_2 is not changed + - create_1 is changed + - create_2 is not changed + - update_1 is changed + - update_2 is not changed diff --git a/tests/integration/targets/docker_plugin/tasks/tests/basic_with_alias.yml b/tests/integration/targets/docker_plugin/tasks/tests/basic_with_alias.yml index c26b188a..4d1aa14e 100644 --- a/tests/integration/targets/docker_plugin/tasks/tests/basic_with_alias.yml +++ b/tests/integration/targets/docker_plugin/tasks/tests/basic_with_alias.yml @@ -66,14 +66,14 @@ - assert: that: - - create_1 is changed - - create_2 is not changed - - create_3 is changed - - create_4 is not changed - - absent_1 is changed - - absent_2 is not changed - - absent_3 is changed - - absent_4 is not changed + - create_1 is changed + - create_2 is not changed + - create_3 is changed + - create_4 is not changed + - absent_1 is changed + - absent_2 is not changed + - absent_3 is changed + - absent_4 is not changed - name: Cleanup plugin with an alias docker_plugin: diff --git a/tests/integration/targets/docker_prune/tasks/main.yml b/tests/integration/targets/docker_prune/tasks/main.yml index 8c1309bc..36881f86 100644 --- a/tests/integration/targets/docker_prune/tasks/main.yml +++ b/tests/integration/targets/docker_prune/tasks/main.yml @@ -15,159 +15,159 @@ vname: "{{ 'ansible-volume-%0x' % ((2**32) | random) }}" - block: - # Create objects to be pruned - - name: Create container (without volume) - docker_container: - name: "{{ cname }}" - image: "{{ docker_test_image_hello_world }}" - state: present - register: container - - name: Create network - docker_network: - name: "{{ nname }}" - state: present - register: network - - name: Create named volume - docker_volume: - name: "{{ vname }}" - state: present - register: volume - - name: Create anonymous volume - command: docker volume create - register: volume_anon + # Create objects to be pruned + - name: Create container (without volume) + docker_container: + name: "{{ cname }}" + image: "{{ docker_test_image_hello_world }}" + state: present + register: container + - name: Create network + docker_network: + name: "{{ nname }}" + state: present + register: network + - name: Create named volume + docker_volume: + name: "{{ vname }}" + state: present + register: volume + - name: Create anonymous volume + command: docker volume create + register: volume_anon - - name: List volumes - command: docker volume list + - name: List volumes + command: docker volume list - # Prune objects - - name: Prune everything - docker_prune: - containers: true - images: true - networks: true - volumes: true - builder_cache: true - register: result - - # Analyze result - - name: Show results - debug: - var: result - - name: General checks - assert: - that: - - result is changed - # 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_anon.stdout in result.volumes - - "'volumes_space_reclaimed' in result" - # builder_cache - - "'builder_cache_space_reclaimed' in result" - - name: API-version specific volumes check (API version before 1.42) - assert: - that: - # For API version 1.41 and before, pruning always considers all volumes - - volume.volume.Name in result.volumes - when: docker_api_version is version('1.42', '<') - - name: API-version specific volumes check (API version 1.42+) - assert: - that: - # For API version 1.41 and before, pruning considers only anonymous volumes, - # so our named container is not removed - - volume.volume.Name not in result.volumes - when: docker_api_version is version('1.42', '>=') - - # Prune objects again - - name: Prune everything again (should have no change) - docker_prune: - containers: true - images: true - networks: true - volumes: true - builder_cache: true - register: result - - # Analyze result - - name: Show results - debug: - var: result - - name: General checks - assert: - that: - - result is not changed - # containers - - result.containers == [] - - result.containers_space_reclaimed == 0 - # images - - result.images == [] - - result.images_space_reclaimed == 0 - # networks - - result.networks == [] - # volumes - - result.volumes == [] - # builder_cache - - result.builder_cache_space_reclaimed == 0 - - # Test with filters - - name: Prune with filters - docker_prune: - images: true - images_filters: - dangling: true - register: result - - - name: Show results - debug: - var: result - - - name: Prune build cache (API version 1.39+) - when: docker_api_version is version('1.39', '>=') - block: - - name: Prune build cache with option - docker_prune: - builder_cache: true - builder_cache_all: true - builder_cache_filters: - until: 10m - builder_cache_keep_storage: 1MB - register: result - - - name: Show results - debug: - var: result - - - name: Check results - assert: - that: - - "'builder_cache_space_reclaimed' in result" - - "'builder_cache_caches_deleted' in result" - - - name: Prune volumes with all filter (API version 1.42+) - when: docker_api_version is version('1.42', '>=') - block: - - name: Prune with filters + # Prune objects + - name: Prune everything docker_prune: + containers: true + images: true + networks: true volumes: true - volumes_filters: - all: true + builder_cache: true register: result + # Analyze result - name: Show results debug: var: result - - - name: Check results + - name: General checks assert: that: - result is changed - - volume.volume.Name in result.volumes + # 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_anon.stdout in result.volumes - "'volumes_space_reclaimed' in result" + # builder_cache + - "'builder_cache_space_reclaimed' in result" + - name: API-version specific volumes check (API version before 1.42) + assert: + that: + # For API version 1.41 and before, pruning always considers all volumes + - volume.volume.Name in result.volumes + when: docker_api_version is version('1.42', '<') + - name: API-version specific volumes check (API version 1.42+) + assert: + that: + # For API version 1.41 and before, pruning considers only anonymous volumes, + # so our named container is not removed + - volume.volume.Name not in result.volumes + when: docker_api_version is version('1.42', '>=') + + # Prune objects again + - name: Prune everything again (should have no change) + docker_prune: + containers: true + images: true + networks: true + volumes: true + builder_cache: true + register: result + + # Analyze result + - name: Show results + debug: + var: result + - name: General checks + assert: + that: + - result is not changed + # containers + - result.containers == [] + - result.containers_space_reclaimed == 0 + # images + - result.images == [] + - result.images_space_reclaimed == 0 + # networks + - result.networks == [] + # volumes + - result.volumes == [] + # builder_cache + - result.builder_cache_space_reclaimed == 0 + + # Test with filters + - name: Prune with filters + docker_prune: + images: true + images_filters: + dangling: true + register: result + + - name: Show results + debug: + var: result + + - name: Prune build cache (API version 1.39+) + when: docker_api_version is version('1.39', '>=') + block: + - name: Prune build cache with option + docker_prune: + builder_cache: true + builder_cache_all: true + builder_cache_filters: + until: 10m + builder_cache_keep_storage: 1MB + register: result + + - name: Show results + debug: + var: result + + - name: Check results + assert: + that: + - "'builder_cache_space_reclaimed' in result" + - "'builder_cache_caches_deleted' in result" + + - name: Prune volumes with all filter (API version 1.42+) + when: docker_api_version is version('1.42', '>=') + block: + - name: Prune with filters + docker_prune: + volumes: true + volumes_filters: + all: true + register: result + + - name: Show results + debug: + var: result + + - name: Check results + assert: + that: + - result is changed + - volume.volume.Name in result.volumes + - "'volumes_space_reclaimed' in result" when: docker_api_version is version('1.25', '>=') diff --git a/tests/integration/targets/docker_secret/tasks/test_secrets.yml b/tests/integration/targets/docker_secret/tasks/test_secrets.yml index 2615b640..1763cb8c 100644 --- a/tests/integration/targets/docker_secret/tasks/test_secrets.yml +++ b/tests/integration/targets/docker_secret/tasks/test_secrets.yml @@ -4,219 +4,219 @@ # SPDX-License-Identifier: GPL-3.0-or-later - block: - - name: Make sure we're not already using Docker swarm - docker_swarm: - state: absent - force: true + - 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 | default('127.0.0.1') }}" + - name: Create a Swarm cluster + docker_swarm: + state: present + advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}" - - name: Parameter name should be required - docker_secret: - state: present - ignore_errors: true - register: output + - name: Parameter name should be required + docker_secret: + state: present + ignore_errors: true + register: output - - name: assert failure when called with no name - assert: - that: - - 'output.failed' - - 'output.msg == "missing required arguments: name"' + - 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: true - register: output + - name: Test parameters + docker_secret: + name: foo + state: present + ignore_errors: true + register: output - - name: assert failure when called with no data - assert: - that: - - 'output.failed' - - 'output.msg == "state is present but any of the following are missing: data, data_src"' + - name: assert failure when called with no data + assert: + that: + - 'output.failed' + - 'output.msg == "state is present but any of the following are missing: data, data_src"' - - name: Create secret - docker_secret: - name: db_password - data: opensesame! - state: present - register: output + - 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: Create variable secret_id + set_fact: + secret_id: "{{ output.secret_id }}" - - name: Inspect secret - command: "docker secret inspect {{ secret_id }}" - register: inspect - ignore_errors: true + - name: Inspect secret + command: "docker secret inspect {{ secret_id }}" + register: inspect + ignore_errors: true - - debug: var=inspect + - 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: 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: 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: assert create secret is idempotent + assert: + that: + - not output.changed - - name: Write secret into file - copy: - dest: "{{ remote_tmp_dir }}/data" - content: |- - opensesame! + - name: Write secret into file + copy: + dest: "{{ remote_tmp_dir }}/data" + content: |- + opensesame! - - name: Create secret again (from file) - docker_secret: - name: db_password - data_src: "{{ remote_tmp_dir }}/data" - state: present - register: output + - name: Create secret again (from file) + docker_secret: + name: db_password + data_src: "{{ remote_tmp_dir }}/data" + state: present + register: output - - name: assert create secret is idempotent - assert: - that: - - not output.changed + - 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: 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: 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: 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: assert secret was updated + assert: + that: + - output.changed + - output.secret_id != secret_id - - name: Remove secret - docker_secret: - name: db_password - state: absent + - 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: true + - name: Check that secret is removed + command: "docker secret inspect {{ secret_id }}" + register: output + ignore_errors: true - - name: assert secret was removed - assert: - that: - - output.failed + - name: assert secret was removed + assert: + that: + - output.failed -# Rolling update + # Rolling update - - name: Create rolling secret - docker_secret: - name: rolling_password - data: opensesame! - rolling_versions: true - state: present - register: original_output + - name: Create rolling secret + docker_secret: + name: rolling_password + data: opensesame! + rolling_versions: true + state: present + register: original_output - - name: Create variable secret_id - set_fact: - secret_id: "{{ original_output.secret_id }}" + - name: Create variable secret_id + set_fact: + secret_id: "{{ original_output.secret_id }}" - - name: Inspect secret - command: "docker secret inspect {{ secret_id }}" - register: inspect - ignore_errors: true + - name: Inspect secret + command: "docker secret inspect {{ secret_id }}" + register: inspect + ignore_errors: true - - debug: var=inspect + - debug: var=inspect - - name: assert secret creation succeeded - assert: - that: - - "'rolling_password' in inspect.stdout" - - "'ansible_key' in inspect.stdout" - - "'ansible_version' in inspect.stdout" - - original_output.secret_name == 'rolling_password_v1' - when: inspect is not failed - - assert: - that: - - "'is too new. Maximum supported API version is' in inspect.stderr" - when: inspect is failed + - name: assert secret creation succeeded + assert: + that: + - "'rolling_password' in inspect.stdout" + - "'ansible_key' in inspect.stdout" + - "'ansible_version' in inspect.stdout" + - original_output.secret_name == 'rolling_password_v1' + 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: rolling_password - data: newpassword! - rolling_versions: true - state: present - register: new_output + - name: Create secret again + docker_secret: + name: rolling_password + data: newpassword! + rolling_versions: true + state: present + register: new_output - - name: assert that new version is created - assert: - that: - - new_output.changed - - new_output.secret_id != original_output.secret_id - - new_output.secret_name != original_output.secret_name - - new_output.secret_name == 'rolling_password_v2' + - name: assert that new version is created + assert: + that: + - new_output.changed + - new_output.secret_id != original_output.secret_id + - new_output.secret_name != original_output.secret_name + - new_output.secret_name == 'rolling_password_v2' - - name: Remove rolling secrets - docker_secret: - name: rolling_password - rolling_versions: true - state: absent + - name: Remove rolling secrets + docker_secret: + name: rolling_password + rolling_versions: true + state: absent - - name: Check that secret is removed - command: "docker secret inspect {{ original_output.secret_id }}" - register: output - ignore_errors: true + - name: Check that secret is removed + command: "docker secret inspect {{ original_output.secret_id }}" + register: output + ignore_errors: true - - name: assert secret was removed - assert: - that: - - output.failed + - name: assert secret was removed + assert: + that: + - output.failed - - name: Check that secret is removed - command: "docker secret inspect {{ new_output.secret_id }}" - register: output - ignore_errors: true + - name: Check that secret is removed + command: "docker secret inspect {{ new_output.secret_id }}" + register: output + ignore_errors: true - - name: assert secret was removed - assert: - that: - - output.failed + - name: assert secret was removed + assert: + that: + - output.failed always: - - name: Remove Swarm cluster - docker_swarm: - state: absent - force: true + - name: Remove Swarm cluster + docker_swarm: + state: absent + force: true diff --git a/tests/integration/targets/docker_stack/tasks/test_stack.yml b/tests/integration/targets/docker_stack/tasks/test_stack.yml index 9f2d170e..ff66e531 100644 --- a/tests/integration/targets/docker_stack/tasks/test_stack.yml +++ b/tests/integration/targets/docker_stack/tasks/test_stack.yml @@ -4,114 +4,114 @@ # SPDX-License-Identifier: GPL-3.0-or-later - block: - - name: Make sure we're not already using Docker swarm - docker_swarm: - state: absent - force: true + - 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 | default('127.0.0.1') }}" + - name: Create a Swarm cluster + docker_swarm: + state: present + advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}" - - name: install docker_stack python requirements - pip: - name: jsondiff,pyyaml + - name: install docker_stack python requirements + pip: + name: jsondiff,pyyaml - - name: Create a stack without name - register: output - docker_stack: - state: present - ignore_errors: true + - name: Create a stack without name + register: output + docker_stack: + state: present + ignore_errors: true - - name: assert failure when name not set - assert: - that: - - output is failed - - 'output.msg == "missing required arguments: name"' + - 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: true + - name: Create a stack without compose + register: output + docker_stack: + name: test_stack + ignore_errors: true - - 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: 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: Ensure stack is absent + register: output + docker_stack: + state: absent + name: test_stack + absent_retries: 30 - - name: Template compose files - template: - src: "{{item}}" - dest: "{{remote_tmp_dir}}/" - with_items: - - stack_compose_base.yml - - stack_compose_overrides.yml + - name: Template compose files + template: + src: "{{item}}" + dest: "{{remote_tmp_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: - - "{{remote_tmp_dir}}/stack_compose_base.yml" + - name: Create stack with compose file + register: output + docker_stack: + state: present + name: test_stack + compose: + - "{{remote_tmp_dir}}/stack_compose_base.yml" - - name: assert test_stack changed on stack creation with compose file - assert: - that: - - output is changed + - 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 + # 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: 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: 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: 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 + - name: assert state=absent idempotency + assert: + that: + - output is not changed always: - - name: Remove a Swarm cluster - docker_swarm: - state: absent - force: true + - name: Remove a Swarm cluster + docker_swarm: + state: absent + force: true diff --git a/tests/integration/targets/docker_stack/templates/stack_compose_base.yml b/tests/integration/targets/docker_stack/templates/stack_compose_base.yml index 03603327..86b89bb3 100644 --- a/tests/integration/targets/docker_stack/templates/stack_compose_base.yml +++ b/tests/integration/targets/docker_stack/templates/stack_compose_base.yml @@ -5,6 +5,6 @@ version: '3' services: - busybox: - image: "{{ docker_test_image_busybox }}" - command: sleep 3600 + busybox: + image: "{{ docker_test_image_busybox }}" + command: sleep 3600 diff --git a/tests/integration/targets/docker_stack/templates/stack_compose_overrides.yml b/tests/integration/targets/docker_stack/templates/stack_compose_overrides.yml index 8743f1e9..16991c48 100644 --- a/tests/integration/targets/docker_stack/templates/stack_compose_overrides.yml +++ b/tests/integration/targets/docker_stack/templates/stack_compose_overrides.yml @@ -5,6 +5,6 @@ version: '3' services: - busybox: - environment: - envvar: value + busybox: + environment: + envvar: value diff --git a/tests/integration/targets/docker_stack/vars/main.yml b/tests/integration/targets/docker_stack/vars/main.yml index a668012f..b0d58cf8 100644 --- a/tests/integration/targets/docker_stack/vars/main.yml +++ b/tests/integration/targets/docker_stack/vars/main.yml @@ -4,17 +4,17 @@ # SPDX-License-Identifier: GPL-3.0-or-later stack_compose_base: - version: '3' - services: - busybox: - image: "{{ docker_test_image_busybox }}" - command: sleep 3600 + version: '3' + services: + busybox: + image: "{{ docker_test_image_busybox }}" + command: sleep 3600 stack_compose_overrides: - version: '3' - services: - busybox: - environment: - envvar: value + version: '3' + services: + busybox: + environment: + envvar: value stack_update_expected_diff: '{"test_stack_busybox": {"TaskTemplate": {"ContainerSpec": {"Env": ["envvar=value"]}}}}' diff --git a/tests/integration/targets/docker_stack_info/tasks/test_stack_info.yml b/tests/integration/targets/docker_stack_info/tasks/test_stack_info.yml index cca26c80..48dfeb6f 100644 --- a/tests/integration/targets/docker_stack_info/tasks/test_stack_info.yml +++ b/tests/integration/targets/docker_stack_info/tasks/test_stack_info.yml @@ -4,75 +4,75 @@ # SPDX-License-Identifier: GPL-3.0-or-later - block: - - name: Make sure we're not already using Docker swarm - docker_swarm: - state: absent - force: true + - 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: 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 response from daemon: This node is not a swarm manager" in output.msg' + - name: Assert failure when called when swarm is not running + assert: + that: + - 'output is failed' + - '"Error response from daemon: This node is not a swarm manager" in output.msg' - - name: Create a swarm cluster - docker_swarm: - state: present - advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}" + - name: Create a swarm cluster + docker_swarm: + state: present + advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}" - - name: Get docker_stack_info when docker is running and not stack available - docker_stack_info: - register: output + - 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: Assert stack facts + assert: + that: + - 'output.results | type_debug == "list"' + - 'output.results | length == 0' - - name: Template compose files - template: - src: "{{ item }}" - dest: "{{ remote_tmp_dir }}/" - with_items: - - stack_compose_base.yml - - stack_compose_overrides.yml + - name: Template compose files + template: + src: "{{ item }}" + dest: "{{ remote_tmp_dir }}/" + with_items: + - stack_compose_base.yml + - stack_compose_overrides.yml - - name: Install docker_stack python requirements - pip: - name: jsondiff,pyyaml + - 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: - - "{{ remote_tmp_dir }}/stack_compose_base.yml" + - name: Create stack with compose file + register: output + docker_stack: + state: present + name: test_stack + compose: + - "{{ remote_tmp_dir }}/stack_compose_base.yml" - - name: Assert test_stack changed on stack creation with compose file - assert: - that: - - output is changed + - 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: 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].Services == "1"' + - name: assert stack facts + assert: + that: + - 'output.results | type_debug == "list"' + - 'output.results[0].Name == "test_stack"' + - 'output.results[0].Services == "1"' always: - - name: Cleanup - docker_swarm: - state: absent - force: true + - name: Cleanup + docker_swarm: + state: absent + force: true diff --git a/tests/integration/targets/docker_stack_info/templates/stack_compose_base.yml b/tests/integration/targets/docker_stack_info/templates/stack_compose_base.yml index 03603327..86b89bb3 100644 --- a/tests/integration/targets/docker_stack_info/templates/stack_compose_base.yml +++ b/tests/integration/targets/docker_stack_info/templates/stack_compose_base.yml @@ -5,6 +5,6 @@ version: '3' services: - busybox: - image: "{{ docker_test_image_busybox }}" - command: sleep 3600 + busybox: + image: "{{ docker_test_image_busybox }}" + command: sleep 3600 diff --git a/tests/integration/targets/docker_stack_info/templates/stack_compose_overrides.yml b/tests/integration/targets/docker_stack_info/templates/stack_compose_overrides.yml index 8743f1e9..16991c48 100644 --- a/tests/integration/targets/docker_stack_info/templates/stack_compose_overrides.yml +++ b/tests/integration/targets/docker_stack_info/templates/stack_compose_overrides.yml @@ -5,6 +5,6 @@ version: '3' services: - busybox: - environment: - envvar: value + busybox: + environment: + envvar: value diff --git a/tests/integration/targets/docker_stack_info/vars/main.yml b/tests/integration/targets/docker_stack_info/vars/main.yml index a668012f..b0d58cf8 100644 --- a/tests/integration/targets/docker_stack_info/vars/main.yml +++ b/tests/integration/targets/docker_stack_info/vars/main.yml @@ -4,17 +4,17 @@ # SPDX-License-Identifier: GPL-3.0-or-later stack_compose_base: - version: '3' - services: - busybox: - image: "{{ docker_test_image_busybox }}" - command: sleep 3600 + version: '3' + services: + busybox: + image: "{{ docker_test_image_busybox }}" + command: sleep 3600 stack_compose_overrides: - version: '3' - services: - busybox: - environment: - envvar: value + version: '3' + services: + busybox: + environment: + envvar: value stack_update_expected_diff: '{"test_stack_busybox": {"TaskTemplate": {"ContainerSpec": {"Env": ["envvar=value"]}}}}' diff --git a/tests/integration/targets/docker_stack_task_info/tasks/test_stack_task_info.yml b/tests/integration/targets/docker_stack_task_info/tasks/test_stack_task_info.yml index cb905d5c..c7a710cb 100644 --- a/tests/integration/targets/docker_stack_task_info/tasks/test_stack_task_info.yml +++ b/tests/integration/targets/docker_stack_task_info/tasks/test_stack_task_info.yml @@ -4,82 +4,82 @@ # SPDX-License-Identifier: GPL-3.0-or-later - block: - - name: Make sure we're not already using Docker swarm - docker_swarm: - state: absent - force: true + - 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: 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 response from daemon: This node is not a swarm manager" in output.msg' + - name: Assert failure when called when swarm is not running + assert: + that: + - 'output is failed' + - '"Error response from daemon: This node is not a swarm manager" in output.msg' - - name: Create a swarm cluster - docker_swarm: - state: present - advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}" + - name: Create a swarm cluster + docker_swarm: + state: present + advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}" - - name: Get docker_stack_info when docker is running and not stack available - docker_stack_info: - register: output + - 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: Assert stack facts + assert: + that: + - 'output.results | type_debug == "list"' + - 'output.results | length == 0' - - name: Template compose files - template: - src: "{{ item }}" - dest: "{{ remote_tmp_dir }}/" - with_items: - - stack_compose_base.yml - - stack_compose_overrides.yml + - name: Template compose files + template: + src: "{{ item }}" + dest: "{{ remote_tmp_dir }}/" + with_items: + - stack_compose_base.yml + - stack_compose_overrides.yml - - name: Install docker_stack python requirements - pip: - name: jsondiff,pyyaml + - 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: - - "{{ remote_tmp_dir }}/stack_compose_base.yml" + - name: Create stack with compose file + register: output + docker_stack: + state: present + name: test_stack + compose: + - "{{ remote_tmp_dir }}/stack_compose_base.yml" - - name: Assert test_stack changed on stack creation with compose file - assert: - that: - - output is changed + - 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: 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_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: 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"' + - 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 diff --git a/tests/integration/targets/docker_stack_task_info/templates/stack_compose_base.yml b/tests/integration/targets/docker_stack_task_info/templates/stack_compose_base.yml index 03603327..86b89bb3 100644 --- a/tests/integration/targets/docker_stack_task_info/templates/stack_compose_base.yml +++ b/tests/integration/targets/docker_stack_task_info/templates/stack_compose_base.yml @@ -5,6 +5,6 @@ version: '3' services: - busybox: - image: "{{ docker_test_image_busybox }}" - command: sleep 3600 + busybox: + image: "{{ docker_test_image_busybox }}" + command: sleep 3600 diff --git a/tests/integration/targets/docker_stack_task_info/templates/stack_compose_overrides.yml b/tests/integration/targets/docker_stack_task_info/templates/stack_compose_overrides.yml index 8743f1e9..16991c48 100644 --- a/tests/integration/targets/docker_stack_task_info/templates/stack_compose_overrides.yml +++ b/tests/integration/targets/docker_stack_task_info/templates/stack_compose_overrides.yml @@ -5,6 +5,6 @@ version: '3' services: - busybox: - environment: - envvar: value + busybox: + environment: + envvar: value diff --git a/tests/integration/targets/docker_stack_task_info/vars/main.yml b/tests/integration/targets/docker_stack_task_info/vars/main.yml index a668012f..b0d58cf8 100644 --- a/tests/integration/targets/docker_stack_task_info/vars/main.yml +++ b/tests/integration/targets/docker_stack_task_info/vars/main.yml @@ -4,17 +4,17 @@ # SPDX-License-Identifier: GPL-3.0-or-later stack_compose_base: - version: '3' - services: - busybox: - image: "{{ docker_test_image_busybox }}" - command: sleep 3600 + version: '3' + services: + busybox: + image: "{{ docker_test_image_busybox }}" + command: sleep 3600 stack_compose_overrides: - version: '3' - services: - busybox: - environment: - envvar: value + version: '3' + services: + busybox: + environment: + envvar: value stack_update_expected_diff: '{"test_stack_busybox": {"TaskTemplate": {"ContainerSpec": {"Env": ["envvar=value"]}}}}' diff --git a/tests/integration/targets/docker_swarm/tasks/tests/basic.yml b/tests/integration/targets/docker_swarm/tasks/tests/basic.yml index 46fc28af..d5c1f344 100644 --- a/tests/integration/targets/docker_swarm/tasks/tests/basic.yml +++ b/tests/integration/targets/docker_swarm/tasks/tests/basic.yml @@ -18,8 +18,8 @@ - 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"' + - '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: @@ -30,8 +30,8 @@ - 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"' + - 'output.failed' + - 'output.msg == "state is remove but all of the following are missing: node_id"' #################################################################### ## Creation ######################################################## @@ -87,27 +87,27 @@ - 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: ")) is truthy' - - 'output_2.swarm_facts.JoinTokens.Manager is truthy' - - 'output_2.swarm_facts.JoinTokens.Worker is truthy' - - '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' + - '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: ")) is truthy' + - 'output_2.swarm_facts.JoinTokens.Manager is truthy' + - 'output_2.swarm_facts.JoinTokens.Worker is truthy' + - '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 ######################################################### @@ -146,18 +146,18 @@ - 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' + - '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/tests/integration/targets/docker_swarm/tasks/tests/options-ca.yml b/tests/integration/targets/docker_swarm/tasks/tests/options-ca.yml index 304be8db..ea118106 100644 --- a/tests/integration/targets/docker_swarm/tasks/tests/options-ca.yml +++ b/tests/integration/targets/docker_swarm/tasks/tests/options-ca.yml @@ -8,126 +8,126 @@ - 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: '{{ remote_tmp_dir }}/ansible_{{ key }}.key' - size: 2048 - mode: '0666' - - name: Generate CSR - loop: - - key1 - - key2 - loop_control: - loop_var: key - community.crypto.openssl_csr: - path: '{{ remote_tmp_dir }}/ansible_{{ key }}.csr' - privatekey_path: '{{ remote_tmp_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.x509_certificate: - path: '{{ remote_tmp_dir }}/ansible_{{ key }}.pem' - privatekey_path: '{{ remote_tmp_dir }}/ansible_{{ key }}.key' - csr_path: '{{ remote_tmp_dir }}/ansible_{{ key }}.csr' - provider: selfsigned - - name: Load certificates - slurp: - src: '{{ remote_tmp_dir }}/{{ item }}' - loop: - - ansible_key1.pem - - ansible_key2.pem - register: ansible_certificates - - name: Load certificate keys - slurp: - src: '{{ remote_tmp_dir }}/{{ item }}' - loop: - - ansible_key1.key - - ansible_key2.key - register: ansible_keys - - 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: '{{ ansible_certificates.results[0].content | b64decode }}' - signing_ca_key: '{{ ansible_keys.results[0].content | b64decode }}' - 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: '{{ ansible_certificates.results[0].content | b64decode }}' - signing_ca_key: '{{ ansible_keys.results[0].content | b64decode }}' - timeout: 120 - diff: true - register: output_2 - ignore_errors: true - - name: Private key - debug: msg="{{ ansible_keys.results[0].content | b64decode }}" - - name: Cert - debug: msg="{{ ansible_certificates.results[0].content | b64decode }}" - - 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: '{{ ansible_certificates.results[1].content | b64decode }}' - signing_ca_key: '{{ ansible_keys.results[1].content | b64decode }}' - 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: '{{ ansible_certificates.results[1].content | b64decode }}' - signing_ca_key: '{{ ansible_keys.results[1].content | b64decode }}' - 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: ")) is truthy' - - 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: ")) is truthy' - - 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 + - name: Generate privatekey + loop: + - key1 + - key2 + loop_control: + loop_var: key + community.crypto.openssl_privatekey: + path: '{{ remote_tmp_dir }}/ansible_{{ key }}.key' + size: 2048 + mode: '0666' + - name: Generate CSR + loop: + - key1 + - key2 + loop_control: + loop_var: key + community.crypto.openssl_csr: + path: '{{ remote_tmp_dir }}/ansible_{{ key }}.csr' + privatekey_path: '{{ remote_tmp_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.x509_certificate: + path: '{{ remote_tmp_dir }}/ansible_{{ key }}.pem' + privatekey_path: '{{ remote_tmp_dir }}/ansible_{{ key }}.key' + csr_path: '{{ remote_tmp_dir }}/ansible_{{ key }}.csr' + provider: selfsigned + - name: Load certificates + slurp: + src: '{{ remote_tmp_dir }}/{{ item }}' + loop: + - ansible_key1.pem + - ansible_key2.pem + register: ansible_certificates + - name: Load certificate keys + slurp: + src: '{{ remote_tmp_dir }}/{{ item }}' + loop: + - ansible_key1.key + - ansible_key2.key + register: ansible_keys + - 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: '{{ ansible_certificates.results[0].content | b64decode }}' + signing_ca_key: '{{ ansible_keys.results[0].content | b64decode }}' + 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: '{{ ansible_certificates.results[0].content | b64decode }}' + signing_ca_key: '{{ ansible_keys.results[0].content | b64decode }}' + timeout: 120 + diff: true + register: output_2 + ignore_errors: true + - name: Private key + debug: msg="{{ ansible_keys.results[0].content | b64decode }}" + - name: Cert + debug: msg="{{ ansible_certificates.results[0].content | b64decode }}" + - 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: '{{ ansible_certificates.results[1].content | b64decode }}' + signing_ca_key: '{{ ansible_keys.results[1].content | b64decode }}' + 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: '{{ ansible_certificates.results[1].content | b64decode }}' + signing_ca_key: '{{ ansible_keys.results[1].content | b64decode }}' + 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: ")) is truthy' + - 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: ")) is truthy' + - 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/tests/integration/targets/docker_swarm/tasks/tests/options.yml b/tests/integration/targets/docker_swarm/tasks/tests/options.yml index 24b46873..65c20573 100644 --- a/tests/integration/targets/docker_swarm/tasks/tests/options.yml +++ b/tests/integration/targets/docker_swarm/tasks/tests/options.yml @@ -81,30 +81,30 @@ - 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' + - '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 @@ -118,9 +118,9 @@ - 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" + - 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', '<') #################################################################### @@ -181,36 +181,36 @@ - 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' + - '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" + - 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', '<') #################################################################### @@ -265,30 +265,30 @@ - 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' + - '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 ################################################### @@ -342,30 +342,30 @@ - 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' + - '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 ################################################## @@ -419,30 +419,30 @@ - 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' + - '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 ############################################## @@ -495,30 +495,30 @@ - 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' + - '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 ########################################################## @@ -648,64 +648,64 @@ - 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' + - '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" + - 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', '<') #################################################################### @@ -759,30 +759,30 @@ - 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' + - '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 ############################################################ @@ -816,15 +816,15 @@ - 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' + - '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 ################################################ @@ -877,30 +877,30 @@ - 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' + - '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 ############################################ @@ -938,22 +938,22 @@ - 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' + - '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 ############################################# @@ -991,22 +991,22 @@ - 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' + - '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 ############################################### @@ -1059,30 +1059,30 @@ - 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' + - '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 #################################### @@ -1135,29 +1135,29 @@ - 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' + - '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/tests/integration/targets/docker_swarm/tasks/tests/remote-addr-pool.yml b/tests/integration/targets/docker_swarm/tasks/tests/remote-addr-pool.yml index 66f422e5..b065f865 100644 --- a/tests/integration/targets/docker_swarm/tasks/tests/remote-addr-pool.yml +++ b/tests/integration/targets/docker_swarm/tasks/tests/remote-addr-pool.yml @@ -31,9 +31,9 @@ - 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"]' + - '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', '>=') @@ -41,8 +41,8 @@ - name: assert default_addr_pool failed when unsupported assert: that: - - 'output_1 is failed' - - "'Minimum version required' in output_1.msg" + - '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', '<') @@ -77,9 +77,9 @@ - name: assert subnet_size assert: that: - - 'output_1 is changed' - - 'output_2 is not changed' - - 'output_2.swarm_facts.SubnetSize == 26' + - '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', '>=') @@ -87,8 +87,8 @@ - name: assert subnet_size failed when unsupported assert: that: - - output_1 is failed - - "'Minimum version required' in output_1.msg" + - 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', '<') diff --git a/tests/integration/targets/docker_swarm_info/tasks/test_swarm_info.yml b/tests/integration/targets/docker_swarm_info/tasks/test_swarm_info.yml index 3f081904..78fd9c6a 100644 --- a/tests/integration/targets/docker_swarm_info/tasks/test_swarm_info.yml +++ b/tests/integration/targets/docker_swarm_info/tasks/test_swarm_info.yml @@ -4,191 +4,191 @@ # SPDX-License-Identifier: GPL-3.0-or-later - block: - - name: Make sure we're not already using Docker swarm - docker_swarm: - state: absent - force: true + - 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: true - register: output + - name: Try to get docker_swarm_info when docker is not running in swarm mode + docker_swarm_info: + ignore_errors: true + 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"' - - 'output.can_talk_to_docker == true' - - 'output.docker_swarm_active == false' - - 'output.docker_swarm_manager == false' - - 'output.swarm_unlock_key is not defined' + - 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"' + - '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: 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: ")) is truthy' - - 'output.swarm_facts.JoinTokens.Manager is truthy' - - 'output.swarm_facts.JoinTokens.Worker is truthy' + - name: assert changed when create a new swarm cluster + assert: + that: + - 'output is changed' + - '(output.actions[0] | regex_search("New Swarm cluster created: ")) is truthy' + - 'output.swarm_facts.JoinTokens.Manager is truthy' + - 'output.swarm_facts.JoinTokens.Worker is truthy' - - name: Try to get docker_swarm_info when docker is running in swarm mode and as manager - docker_swarm_info: - register: output + - 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 is truthy' - - 'output.swarm_facts.JoinTokens.Worker is truthy' - - 'output.swarm_facts.ID is truthy' - - 'output.can_talk_to_docker == true' - - 'output.docker_swarm_active == true' - - 'output.docker_swarm_manager == true' - - 'output.swarm_unlock_key is not defined' + - name: assert creding docker swarm facts + assert: + that: + - 'output.swarm_facts.JoinTokens.Manager is truthy' + - 'output.swarm_facts.JoinTokens.Worker is truthy' + - 'output.swarm_facts.ID is truthy' + - '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: true - register: output + - 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: true + register: output - - name: assert reading swarm facts with list of nodes option - assert: - that: - - 'output.swarm_facts.JoinTokens.Manager is truthy' - - 'output.swarm_facts.JoinTokens.Worker is truthy' - - 'output.swarm_facts.ID is truthy' - - '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: assert reading swarm facts with list of nodes option + assert: + that: + - 'output.swarm_facts.JoinTokens.Manager is truthy' + - 'output.swarm_facts.JoinTokens.Worker is truthy' + - 'output.swarm_facts.ID is truthy' + - '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: 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: true - verbose_output: true - register: output + - 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: true + verbose_output: true + register: output - - name: assert reading swarm facts with list of nodes and versbose output options - assert: - that: - - 'output.swarm_facts.JoinTokens.Manager is truthy' - - 'output.swarm_facts.JoinTokens.Worker is truthy' - - 'output.swarm_facts.ID is truthy' - - 'output.nodes[0].ID is string' - - 'output.nodes[0].CreatedAt is truthy' - - 'output.can_talk_to_docker == true' - - 'output.docker_swarm_active == true' - - 'output.docker_swarm_manager == true' - - 'output.swarm_unlock_key is not defined' + - name: assert reading swarm facts with list of nodes and versbose output options + assert: + that: + - 'output.swarm_facts.JoinTokens.Manager is truthy' + - 'output.swarm_facts.JoinTokens.Worker is truthy' + - 'output.swarm_facts.ID is truthy' + - 'output.nodes[0].ID is string' + - 'output.nodes[0].CreatedAt is truthy' + - '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: true - nodes_filters: - name: "{{ localnodename }}" - register: output + - name: Try to get docker_swarm_info and list of nodes with filters providing existing node name + docker_swarm_info: + nodes: true + 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 is truthy' - - 'output.swarm_facts.JoinTokens.Worker is truthy' - - 'output.swarm_facts.ID is truthy' - - '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: assert reading reading swarm facts and using node filter (random node name) + assert: + that: + - 'output.swarm_facts.JoinTokens.Manager is truthy' + - 'output.swarm_facts.JoinTokens.Worker is truthy' + - 'output.swarm_facts.ID is truthy' + - '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: 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: true - nodes_filters: - name: "{{ randomnodename }}" - register: output + - name: Try to get docker_swarm_info and list of nodes with filters providing non-existing random node name + docker_swarm_info: + nodes: true + 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 is truthy' - - 'output.swarm_facts.JoinTokens.Worker is truthy' - - 'output.swarm_facts.ID is truthy' - - '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: assert reading reading swarm facts and using node filter (random node name) + assert: + that: + - 'output.swarm_facts.JoinTokens.Manager is truthy' + - 'output.swarm_facts.JoinTokens.Worker is truthy' + - 'output.swarm_facts.ID is truthy' + - '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: true - register: output - ignore_errors: true + - name: Try to get docker_swarm_info and swarm_unlock_key on non a unlocked swarm + docker_swarm_info: + unlock_key: true + register: output + ignore_errors: true - - 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: 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: true + - 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: true - - name: Try to get docker_swarm_info and swarm_unlock_key - docker_swarm_info: - unlock_key: true - register: output - ignore_errors: true + - name: Try to get docker_swarm_info and swarm_unlock_key + docker_swarm_info: + unlock_key: true + register: output + ignore_errors: true - - 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', '<') + - 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 + - name: Cleanup + docker_swarm: + state: absent + force: true diff --git a/tests/integration/targets/docker_swarm_service/tasks/tests/configs.yml b/tests/integration/targets/docker_swarm_service/tasks/tests/configs.yml index 9f2fa8c3..db90320e 100644 --- a/tests/integration/targets/docker_swarm_service/tasks/tests/configs.yml +++ b/tests/integration/targets/docker_swarm_service/tasks/tests/configs.yml @@ -185,23 +185,23 @@ - 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 - - configs_9 is changed - - configs_10 is not failed - - configs_11 is changed + - 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 + - configs_9 is changed + - configs_10 is not failed + - configs_11 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" + - 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', '<') #################################################################### @@ -217,10 +217,10 @@ configs: - config_id: "{{ config_result_1.config_id|default('') }}" config_name: "{{ config_name_1 }}" - uid: 1000 + uid: 1000 register: configs_1 ignore_errors: true - + - name: configs (uid int idempotency) docker_swarm_service: name: "{{ service_name }}" @@ -230,7 +230,7 @@ configs: - config_id: "{{ config_result_1.config_id|default('') }}" config_name: "{{ config_name_1 }}" - uid: 1000 + uid: 1000 register: configs_2 ignore_errors: true @@ -243,10 +243,10 @@ configs: - config_id: "{{ config_result_1.config_id|default('') }}" config_name: "{{ config_name_1 }}" - uid: 1002 + uid: 1002 register: configs_3 ignore_errors: true - + - name: configs (uid str) docker_swarm_service: name: "{{ service_name }}" @@ -280,17 +280,17 @@ diff: false - assert: that: - - configs_1 is changed - - configs_2 is not changed - - configs_3 is changed - - configs_4 is changed - - configs_5 is not changed + - 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" + - 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', '<') @@ -307,10 +307,10 @@ configs: - config_id: "{{ config_result_1.config_id|default('') }}" config_name: "{{ config_name_1 }}" - gid: 1000 + gid: 1000 register: configs_1 ignore_errors: true - + - name: configs (gid int idempotency) docker_swarm_service: name: "{{ service_name }}" @@ -320,7 +320,7 @@ configs: - config_id: "{{ config_result_1.config_id|default('') }}" config_name: "{{ config_name_1 }}" - gid: 1000 + gid: 1000 register: configs_2 ignore_errors: true @@ -333,10 +333,10 @@ configs: - config_id: "{{ config_result_1.config_id|default('') }}" config_name: "{{ config_name_1 }}" - gid: 1002 + gid: 1002 register: configs_3 ignore_errors: true - + - name: configs (gid str) docker_swarm_service: name: "{{ service_name }}" @@ -370,17 +370,17 @@ diff: false - assert: that: - - configs_1 is changed - - configs_2 is not changed - - configs_3 is changed - - configs_4 is changed - - configs_5 is not changed + - 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" + - 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', '<') #################################################################### @@ -396,7 +396,7 @@ configs: - config_id: "{{ config_result_1.config_id|default('') }}" config_name: "{{ config_name_1 }}" - mode: 0600 + mode: "0600" register: configs_1 ignore_errors: true @@ -409,7 +409,7 @@ configs: - config_id: "{{ config_result_1.config_id|default('') }}" config_name: "{{ config_name_1 }}" - mode: 0600 + mode: "0600" register: configs_2 ignore_errors: true @@ -422,7 +422,7 @@ configs: - config_id: "{{ config_result_1.config_id|default('') }}" config_name: "{{ config_name_1 }}" - mode: 0777 + mode: "0777" register: configs_3 ignore_errors: true @@ -433,15 +433,15 @@ diff: false - assert: that: - - configs_1 is changed - - configs_2 is not changed - - configs_3 is changed + - 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" + - 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', '<') #################################################################### diff --git a/tests/integration/targets/docker_swarm_service/tasks/tests/mounts.yml b/tests/integration/targets/docker_swarm_service/tasks/tests/mounts.yml index 7605d9fc..1eaca6e4 100644 --- a/tests/integration/targets/docker_swarm_service/tasks/tests/mounts.yml +++ b/tests/integration/targets/docker_swarm_service/tasks/tests/mounts.yml @@ -462,8 +462,8 @@ 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" + - mounts_tmpfs_size_1 is failed + - "'Minimum version required' in mounts_tmpfs_size_1.msg" when: docker_py_version is version('2.6.0', '<') #################################################################### @@ -480,7 +480,7 @@ - source: "{{ volume_name_1 }}" target: "/tmp/{{ volume_name_1 }}" type: "tmpfs" - tmpfs_mode: 0444 + tmpfs_mode: "0444" register: mounts_tmpfs_mode_1 ignore_errors: true @@ -494,7 +494,7 @@ - source: "{{ volume_name_1 }}" target: "/tmp/{{ volume_name_1 }}" type: "tmpfs" - tmpfs_mode: 0444 + tmpfs_mode: "0444" register: mounts_tmpfs_mode_2 ignore_errors: true @@ -508,7 +508,7 @@ - source: "{{ volume_name_1 }}" target: "/tmp/{{ volume_name_1 }}" type: "tmpfs" - tmpfs_mode: 0777 + tmpfs_mode: "0777" register: mounts_tmpfs_mode_3 ignore_errors: true @@ -526,8 +526,8 @@ 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" + - mounts_tmpfs_size_1 is failed + - "'Minimum version required' in mounts_tmpfs_size_1.msg" when: docker_py_version is version('2.6.0', '<') #################################################################### @@ -586,8 +586,8 @@ 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" + - mounts_tmpfs_source_1 is failed + - "'Minimum version required' in mounts_tmpfs_source_1.msg" when: docker_py_version is version('2.6.0', '<') #################################################################### diff --git a/tests/integration/targets/docker_swarm_service/tasks/tests/networks.yml b/tests/integration/targets/docker_swarm_service/tasks/tests/networks.yml index f57824f9..123658f2 100644 --- a/tests/integration/targets/docker_swarm_service/tasks/tests/networks.yml +++ b/tests/integration/targets/docker_swarm_service/tasks/tests/networks.yml @@ -213,14 +213,14 @@ - assert: that: - - networks_4.rebuilt == false - - networks_7.rebuilt == false + - 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 + - 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', '<') #################################################################### diff --git a/tests/integration/targets/docker_swarm_service/tasks/tests/options.yml b/tests/integration/targets/docker_swarm_service/tasks/tests/options.yml index 7b206698..385f655a 100644 --- a/tests/integration/targets/docker_swarm_service/tasks/tests/options.yml +++ b/tests/integration/targets/docker_swarm_service/tasks/tests/options.yml @@ -325,8 +325,8 @@ when: docker_py_version is version('2.6.0', '>=') - assert: that: - - dns_1 is failed - - "'Minimum version required' in dns_1.msg" + - dns_1 is failed + - "'Minimum version required' in dns_1.msg" when: docker_py_version is version('2.6.0', '<') #################################################################### @@ -418,8 +418,8 @@ when: docker_py_version is version('2.6.0', '>=') - assert: that: - - dns_options_1 is failed - - "'Minimum version required' in dns_options_1.msg" + - dns_options_1 is failed + - "'Minimum version required' in dns_options_1.msg" when: docker_py_version is version('2.6.0', '<') #################################################################### @@ -511,8 +511,8 @@ when: docker_py_version is version('2.6.0', '>=') - assert: that: - - dns_search_1 is failed - - "'Minimum version required' in dns_search_1.msg" + - dns_search_1 is failed + - "'Minimum version required' in dns_search_1.msg" when: docker_py_version is version('2.6.0', '<') #################################################################### @@ -563,8 +563,8 @@ when: docker_py_version is version('3.0.0', '>=') - assert: that: - - endpoint_mode_1 is failed - - "'Minimum version required' in endpoint_mode_1.msg" + - endpoint_mode_1 is failed + - "'Minimum version required' in endpoint_mode_1.msg" when: docker_py_version is version('3.0.0', '<') #################################################################### @@ -755,13 +755,13 @@ - 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 + - 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 ################################################### @@ -806,8 +806,8 @@ when: docker_py_version is version('2.1.0', '>=') - assert: that: - - force_update_1 is failed - - "'Minimum version required' in force_update_1.msg" + - force_update_1 is failed + - "'Minimum version required' in force_update_1.msg" when: docker_py_version is version('2.1.0', '<') #################################################################### @@ -889,17 +889,17 @@ - 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 + - 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_py_version is version('2.6.0', '>=') - assert: that: - - groups_1 is failed - - "'Minimum version required' in groups_1.msg" + - groups_1 is failed + - "'Minimum version required' in groups_1.msg" when: docker_py_version is version('2.6.0', '<') #################################################################### @@ -1033,20 +1033,20 @@ - 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 + - 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" + - 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', '<') ################################################################### @@ -1097,8 +1097,8 @@ when: docker_py_version is version('2.2.0', '>=') - assert: that: - - hostname_1 is failed - - "'Minimum version required' in hostname_1.msg" + - hostname_1 is failed + - "'Minimum version required' in hostname_1.msg" when: docker_py_version is version('2.2.0', '<') ################################################################### @@ -1154,8 +1154,8 @@ when: docker_py_version is version('2.6.0', '>=') - assert: that: - - hosts_1 is failed - - "'Minimum version required' in hosts_1.msg" + - hosts_1 is failed + - "'Minimum version required' in hosts_1.msg" when: docker_py_version is version('2.6.0', '<') @@ -1352,9 +1352,9 @@ - assert: that: - - stop_grace_period_1 is changed - - stop_grace_period_2 is not changed - - stop_grace_period_3 is changed + - stop_grace_period_1 is changed + - stop_grace_period_2 is not changed + - stop_grace_period_3 is changed #################################################################### ## stop_signal ##################################################### @@ -1398,14 +1398,14 @@ - assert: that: - - stop_signal_1 is changed - - stop_signal_2 is not changed - - stop_signal_3 is changed + - 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" + - 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', '<') #################################################################### @@ -1593,8 +1593,8 @@ when: docker_py_version is version('3.0.0', '>=') - assert: that: - - publish_1 is failed - - "'Minimum version required' in publish_1.msg" + - publish_1 is failed + - "'Minimum version required' in publish_1.msg" when: docker_py_version is version('3.0.0', '<') ################################################################### @@ -1645,8 +1645,8 @@ 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" + - 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', '<') ################################################################### @@ -1790,8 +1790,8 @@ when: docker_py_version is version('2.4.0', '>=') - assert: that: - - tty_1 is failed - - "'Minimum version required' in tty_1.msg" + - tty_1 is failed + - "'Minimum version required' in tty_1.msg" when: docker_py_version is version('2.4.0', '<') ################################################################### @@ -1873,9 +1873,9 @@ - assert: that: - - working_dir_1 is changed - - working_dir_2 is not changed - - working_dir_3 is changed + - working_dir_1 is changed + - working_dir_2 is not changed + - working_dir_3 is changed #################################################################### ## init ############################################################ @@ -1920,8 +1920,8 @@ - assert: that: - - init_1 is failed - - "('version is ' ~ docker_api_version ~'. Minimum version required is 1.37') in hosts_1.msg" + - 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', '<') #################################################################### @@ -1935,9 +1935,9 @@ resolve_image: false init: true cap_add: - - sys_time + - sys_time cap_drop: - - all + - all register: capabilities_1 ignore_errors: true @@ -1948,9 +1948,9 @@ resolve_image: false init: true cap_add: - - sys_time + - sys_time cap_drop: - - all + - all register: capabilities_2 ignore_errors: true diff: true @@ -1963,7 +1963,7 @@ init: true cap_add: [] cap_drop: - - all + - all register: capabilities_3 ignore_errors: true diff: true @@ -1975,9 +1975,9 @@ resolve_image: false init: true cap_add: - - setgid + - setgid cap_drop: - - all + - all register: capabilities_4 ignore_errors: true diff: true @@ -1990,16 +1990,16 @@ - assert: that: - - capabilities_1 is changed - - capabilities_2 is not changed - - capabilities_3 is changed - - capabilities_4 is changed + - capabilities_1 is changed + - capabilities_2 is not changed + - capabilities_3 is changed + - capabilities_4 is changed when: docker_api_version is version('1.41', '>=') and docker_py_version is version('5.0.3', '>=') - assert: that: - - capabilities_1 is failed - - > - (('version is ' ~ docker_py_version ~ ' ') in capabilities_1.msg and 'Minimum version required is 5.0.3 ' in capabilities_1.msg) - or (('Docker API version is ' ~ docker_api_version ~ '. ') in capabilities_1.msg and 'Minimum version required is 1.41 ' in capabilities_1.msg) + - capabilities_1 is failed + - > + (('version is ' ~ docker_py_version ~ ' ') in capabilities_1.msg and 'Minimum version required is 5.0.3 ' in capabilities_1.msg) + or (('Docker API version is ' ~ docker_api_version ~ '. ') in capabilities_1.msg and 'Minimum version required is 1.41 ' in capabilities_1.msg) when: docker_api_version is version('1.41', '<') or docker_py_version is version('5.0.3', '<') diff --git a/tests/integration/targets/docker_swarm_service/tasks/tests/placement.yml b/tests/integration/targets/docker_swarm_service/tasks/tests/placement.yml index 30ed155b..a9156e99 100644 --- a/tests/integration/targets/docker_swarm_service/tasks/tests/placement.yml +++ b/tests/integration/targets/docker_swarm_service/tasks/tests/placement.yml @@ -90,8 +90,8 @@ 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" + - 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', '<') #################################################################### @@ -200,8 +200,8 @@ 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" + - 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', '<') #################################################################### @@ -256,6 +256,6 @@ when: docker_api_version is version('1.40', '>=') and docker_py_version is version('4.4.3', '>=') - assert: that: - - replicas_max_per_node_1 is failed - - "'Minimum version required' in replicas_max_per_node_1.msg" + - replicas_max_per_node_1 is failed + - "'Minimum version required' in replicas_max_per_node_1.msg" when: docker_api_version is version('1.40', '<') or docker_py_version is version('4.4.3', '<') diff --git a/tests/integration/targets/docker_swarm_service/tasks/tests/secrets.yml b/tests/integration/targets/docker_swarm_service/tasks/tests/secrets.yml index 2af5076f..8e32007a 100644 --- a/tests/integration/targets/docker_swarm_service/tasks/tests/secrets.yml +++ b/tests/integration/targets/docker_swarm_service/tasks/tests/secrets.yml @@ -199,8 +199,8 @@ when: docker_py_version is version('2.4.0', '>=') - assert: that: - - secrets_1 is failed - - "'Minimum version required' in secrets_1.msg" + - secrets_1 is failed + - "'Minimum version required' in secrets_1.msg" when: docker_py_version is version('2.4.0', '<') #################################################################### @@ -288,8 +288,8 @@ when: docker_py_version is version('2.4.0', '>=') - assert: that: - - secrets_1 is failed - - "'Minimum version required' in secrets_1.msg" + - secrets_1 is failed + - "'Minimum version required' in secrets_1.msg" when: docker_py_version is version('2.4.0', '<') #################################################################### @@ -377,8 +377,8 @@ when: docker_py_version is version('2.4.0', '>=') - assert: that: - - secrets_1 is failed - - "'Minimum version required' in secrets_1.msg" + - secrets_1 is failed + - "'Minimum version required' in secrets_1.msg" when: docker_py_version is version('2.4.0', '<') #################################################################### @@ -394,7 +394,7 @@ secrets: - secret_id: "{{ secret_result_1.secret_id|default('') }}" secret_name: "{{ secret_name_1 }}" - mode: 0600 + mode: "0600" register: secrets_1 ignore_errors: true @@ -407,7 +407,7 @@ secrets: - secret_id: "{{ secret_result_1.secret_id|default('') }}" secret_name: "{{ secret_name_1 }}" - mode: 0600 + mode: "0600" register: secrets_2 ignore_errors: true @@ -420,7 +420,7 @@ secrets: - secret_id: "{{ secret_result_1.secret_id|default('') }}" secret_name: "{{ secret_name_1 }}" - mode: 0777 + mode: "0777" register: secrets_3 ignore_errors: true @@ -438,8 +438,8 @@ when: docker_py_version is version('2.4.0', '>=') - assert: that: - - secrets_1 is failed - - "'Minimum version required' in secrets_1.msg" + - secrets_1 is failed + - "'Minimum version required' in secrets_1.msg" when: docker_py_version is version('2.4.0', '<') #################################################################### diff --git a/tests/integration/targets/docker_swarm_service/tasks/tests/update_config.yml b/tests/integration/targets/docker_swarm_service/tasks/tests/update_config.yml index fb335a03..24ce8abc 100644 --- a/tests/integration/targets/docker_swarm_service/tasks/tests/update_config.yml +++ b/tests/integration/targets/docker_swarm_service/tasks/tests/update_config.yml @@ -189,8 +189,8 @@ when: 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" + - update_max_failure_ratio_1 is failed + - "'Minimum version required' in update_max_failure_ratio_1.msg" when: docker_py_version is version('2.1.0', '<') ################################################################### @@ -244,8 +244,8 @@ when: docker_py_version is version('2.1.0', '>=') - assert: that: - - update_monitor_1 is failed - - "'Minimum version required' in update_monitor_1.msg" + - update_monitor_1 is failed + - "'Minimum version required' in update_monitor_1.msg" when: docker_py_version is version('2.1.0', '<') ################################################################### @@ -299,8 +299,8 @@ 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" + - 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', '<') ################################################################### diff --git a/tests/integration/targets/docker_swarm_service_info/tasks/test_docker_swarm_service_info.yml b/tests/integration/targets/docker_swarm_service_info/tasks/test_docker_swarm_service_info.yml index ee191138..fbabb5b0 100644 --- a/tests/integration/targets/docker_swarm_service_info/tasks/test_docker_swarm_service_info.yml +++ b/tests/integration/targets/docker_swarm_service_info/tasks/test_docker_swarm_service_info.yml @@ -12,60 +12,60 @@ service_name: "{{ service_base_name ~ '-1' }}" - block: - - name: Make sure we're not already using Docker swarm - docker_swarm: - state: absent - force: true + - 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: true - register: output + - 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: true + 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: 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 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: 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: 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: 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: 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: 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' + - name: assert reading reading service info + assert: + that: + - 'output.service is none' + - 'output.exists == false' always: - name: Remove services diff --git a/tests/integration/targets/docker_volume/tasks/tests/basic.yml b/tests/integration/targets/docker_volume/tasks/tests/basic.yml index e032eddc..9f20f11e 100644 --- a/tests/integration/targets/docker_volume/tasks/tests/basic.yml +++ b/tests/integration/targets/docker_volume/tasks/tests/basic.yml @@ -50,12 +50,12 @@ - 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 + - 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 ################################################## @@ -109,10 +109,10 @@ - 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_1 is changed + - driver_options_2 is not changed + - driver_options_3 is not changed + - driver_options_4 is changed #################################################################### ## labels ########################################################## @@ -181,11 +181,11 @@ - assert: that: - - driver_labels_invalid is failed - - driver_labels_invalid.msg == "The value 1.0 for 'foo' of labels is not a string or something than can be safely converted to a string!" - - 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 + - driver_labels_invalid is failed + - driver_labels_invalid.msg == "The value 1.0 for 'foo' of labels is not a string or something than can be safely converted to a string!" + - 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/tests/integration/targets/docker_volume_info/tasks/main.yml b/tests/integration/targets/docker_volume_info/tasks/main.yml index fc0a385c..fbbbddee 100644 --- a/tests/integration/targets/docker_volume_info/tasks/main.yml +++ b/tests/integration/targets/docker_volume_info/tasks/main.yml @@ -9,67 +9,67 @@ #################################################################### - block: - - name: Create random volume name - set_fact: - cname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}" + - name: Create random volume name + set_fact: + cname: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}" - - name: Make sure volume is not there - docker_volume: - name: "{{ cname }}" - state: absent + - 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 + - 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" + - assert: + that: + - "not result.exists" + - "'volume' in result" + - "result.volume is none" - - name: Make sure volume exists - docker_volume: - name: "{{ cname }}" + - 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: 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: true - - 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: "Comparison: use 'docker volume inspect'" + command: docker volume inspect "{{ cname }}" + register: docker_volume_inspect + ignore_errors: true + - 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 + - name: Cleanup + docker_volume: + name: "{{ cname }}" + state: absent - - assert: - that: - - result.exists - - "'volume' in result" - - "result.volume is truthy" + - assert: + that: + - result.exists + - "'volume' in result" + - "result.volume is truthy" - - 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 + - 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 when: docker_api_version is version('1.25', '>=') diff --git a/tests/integration/targets/generic_connection_tests/tasks/main.yml b/tests/integration/targets/generic_connection_tests/tasks/main.yml index 63600e62..3992410b 100644 --- a/tests/integration/targets/generic_connection_tests/tasks/main.yml +++ b/tests/integration/targets/generic_connection_tests/tasks/main.yml @@ -13,103 +13,36 @@ daemon_nginx_frontend: '{{ "ansible-docker-test-daemon-frontend-%0x" % ((2**32) | random) }}' - block: - - name: Create volume for config files - docker_volume: - name: '{{ daemon_nginx_frontend }}' - state: present + - name: Create volume for config files + docker_volume: + name: '{{ daemon_nginx_frontend }}' + state: present - - name: Create container for nginx frontend for daemon - docker_container: - state: stopped - name: '{{ daemon_nginx_frontend }}' - image: "{{ docker_test_image_registry_nginx }}" - volumes: - - '{{ daemon_nginx_frontend }}:/etc/nginx/' - - '/var/run/docker.sock:/var/run/docker.sock' - 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: Create container for nginx frontend for daemon + docker_container: + state: stopped + name: '{{ daemon_nginx_frontend }}' + image: "{{ docker_test_image_registry_nginx }}" + volumes: + - '{{ daemon_nginx_frontend }}:/etc/nginx/' + - '/var/run/docker.sock:/var/run/docker.sock' + 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 config files - copy: - src: "{{ item }}" - dest: "{{ remote_tmp_dir }}/{{ item }}" - mode: "0644" - loop: - - nginx.conf - - - name: Copy static files into volume - docker_container_copy_into: - container: '{{ daemon_nginx_frontend }}' - path: '{{ remote_tmp_dir }}/{{ item }}' - container_path: '/etc/nginx/{{ item }}' - owner_id: 0 - group_id: 0 - loop: - - nginx.conf - register: can_copy_files - ignore_errors: true - - - when: can_copy_files is not failed - block: - - - name: Create private keys - community.crypto.openssl_privatekey: - path: '{{ remote_tmp_dir }}/{{ item }}.key' - type: ECC - curve: secp256r1 - force: true + - name: Copy config files + copy: + src: "{{ item }}" + dest: "{{ remote_tmp_dir }}/{{ item }}" + mode: "0644" loop: - - cert - - ca + - nginx.conf - - name: Create CSR for CA certificate - community.crypto.openssl_csr: - path: '{{ remote_tmp_dir }}/ca.csr' - privatekey_path: '{{ remote_tmp_dir }}/ca.key' - subject: - commonName: Ansible test CA for Docker HTTPS connection tests - useCommonNameForSAN: false - basic_constraints: - - 'CA:TRUE' - basic_constraints_critical: true - key_usage: - - digitalSignature - - Certificate Sign - key_usage_critical: true - extended_key_usage: - - serverAuth # the same as "TLS Web Server Authentication" - extended_key_usage_critical: true - - - name: Create CA certificate - community.crypto.x509_certificate: - path: '{{ remote_tmp_dir }}/ca.pem' - csr_path: '{{ remote_tmp_dir }}/ca.csr' - privatekey_path: '{{ remote_tmp_dir }}/ca.key' - provider: selfsigned - - - name: Create CSR for frontend certificate - community.crypto.openssl_csr: - path: '{{ remote_tmp_dir }}/cert.csr' - privatekey_path: '{{ remote_tmp_dir }}/cert.key' - subject_alt_name: - - DNS:daemon-tls.ansible.com - subject_alt_name_critical: true - - - name: Create frontend certificate - community.crypto.x509_certificate: - path: '{{ remote_tmp_dir }}/cert.pem' - csr_path: '{{ remote_tmp_dir }}/cert.csr' - privatekey_path: '{{ remote_tmp_dir }}/cert.key' - ownca_path: '{{ remote_tmp_dir }}/ca.pem' - ownca_privatekey_path: '{{ remote_tmp_dir }}/ca.key' - provider: ownca - - - name: Copy dynamic files into volume + - name: Copy static files into volume docker_container_copy_into: container: '{{ daemon_nginx_frontend }}' path: '{{ remote_tmp_dir }}/{{ item }}' @@ -117,91 +50,158 @@ owner_id: 0 group_id: 0 loop: - - ca.pem - - cert.pem - - cert.key + - nginx.conf + register: can_copy_files + ignore_errors: true - - name: Start nginx frontend for daemon - docker_container: - name: '{{ daemon_nginx_frontend }}' - state: started - register: nginx_container + - when: can_copy_files is not failed + block: - - name: Output nginx container network settings - debug: - var: nginx_container.container.NetworkSettings + - name: Create private keys + community.crypto.openssl_privatekey: + path: '{{ remote_tmp_dir }}/{{ item }}.key' + type: ECC + curve: secp256r1 + force: true + loop: + - cert + - ca - - name: Get proxied daemon URLs - set_fact: - docker_daemon_frontend_https: "https://{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:5000" - docker_daemon_frontend_http: "http://{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:6000" + - name: Create CSR for CA certificate + community.crypto.openssl_csr: + path: '{{ remote_tmp_dir }}/ca.csr' + privatekey_path: '{{ remote_tmp_dir }}/ca.key' + subject: + commonName: Ansible test CA for Docker HTTPS connection tests + useCommonNameForSAN: false + basic_constraints: + - 'CA:TRUE' + basic_constraints_critical: true + key_usage: + - digitalSignature + - Certificate Sign + key_usage_critical: true + extended_key_usage: + - serverAuth # the same as "TLS Web Server Authentication" + extended_key_usage_critical: true - - name: Wait for registry frontend - uri: - url: '{{ docker_daemon_frontend_http }}/version' - register: result - until: result is success - retries: 5 - delay: 1 + - name: Create CA certificate + community.crypto.x509_certificate: + path: '{{ remote_tmp_dir }}/ca.pem' + csr_path: '{{ remote_tmp_dir }}/ca.csr' + privatekey_path: '{{ remote_tmp_dir }}/ca.key' + provider: selfsigned - - name: Get docker daemon information directly - docker_host_info: - register: output_direct + - name: Create CSR for frontend certificate + community.crypto.openssl_csr: + path: '{{ remote_tmp_dir }}/cert.csr' + privatekey_path: '{{ remote_tmp_dir }}/cert.key' + subject_alt_name: + - DNS:daemon-tls.ansible.com + subject_alt_name_critical: true - - name: Show direct host info - debug: - var: output_direct.host_info | sanitize_host_info + - name: Create frontend certificate + community.crypto.x509_certificate: + path: '{{ remote_tmp_dir }}/cert.pem' + csr_path: '{{ remote_tmp_dir }}/cert.csr' + privatekey_path: '{{ remote_tmp_dir }}/cert.key' + ownca_path: '{{ remote_tmp_dir }}/ca.pem' + ownca_privatekey_path: '{{ remote_tmp_dir }}/ca.key' + provider: ownca - - name: Get docker daemon information via HTTP - docker_host_info: - docker_host: '{{ docker_daemon_frontend_http }}' - register: output_http + - name: Copy dynamic files into volume + docker_container_copy_into: + container: '{{ daemon_nginx_frontend }}' + path: '{{ remote_tmp_dir }}/{{ item }}' + container_path: '/etc/nginx/{{ item }}' + owner_id: 0 + group_id: 0 + loop: + - ca.pem + - cert.pem + - cert.key - - name: Show HTTP host info - debug: - var: output_http.host_info | sanitize_host_info + - name: Start nginx frontend for daemon + docker_container: + name: '{{ daemon_nginx_frontend }}' + state: started + register: nginx_container - - name: Check that information matches - assert: - that: - - (output_direct.host_info | sanitize_host_info) == (output_http.host_info | sanitize_host_info) + - name: Output nginx container network settings + debug: + var: nginx_container.container.NetworkSettings - - name: Get docker daemon information via HTTPS - docker_host_info: - docker_host: '{{ docker_daemon_frontend_https }}' - tls_hostname: daemon-tls.ansible.com - ca_cert: '{{ remote_tmp_dir }}/ca.pem' - tls: true - validate_certs: true - register: output_https + - name: Get proxied daemon URLs + set_fact: + docker_daemon_frontend_https: "https://{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:5000" + docker_daemon_frontend_http: "http://{{ nginx_container.container.NetworkSettings.Networks[current_container_network_ip].IPAddress if current_container_network_ip else nginx_container.container.NetworkSettings.IPAddress }}:6000" - - name: Show HTTPS host info - debug: - var: output_https.host_info | sanitize_host_info + - name: Wait for registry frontend + uri: + url: '{{ docker_daemon_frontend_http }}/version' + register: result + until: result is success + retries: 5 + delay: 1 - - name: Check that information matches - assert: - that: - - (output_direct.host_info | sanitize_host_info) == (output_https.host_info | sanitize_host_info) + - name: Get docker daemon information directly + docker_host_info: + register: output_direct + + - name: Show direct host info + debug: + var: output_direct.host_info | sanitize_host_info + + - name: Get docker daemon information via HTTP + docker_host_info: + docker_host: '{{ docker_daemon_frontend_http }}' + register: output_http + + - name: Show HTTP host info + debug: + var: output_http.host_info | sanitize_host_info + + - name: Check that information matches + assert: + that: + - (output_direct.host_info | sanitize_host_info) == (output_http.host_info | sanitize_host_info) + + - name: Get docker daemon information via HTTPS + docker_host_info: + docker_host: '{{ docker_daemon_frontend_https }}' + tls_hostname: daemon-tls.ansible.com + ca_cert: '{{ remote_tmp_dir }}/ca.pem' + tls: true + validate_certs: true + register: output_https + + - name: Show HTTPS host info + debug: + var: output_https.host_info | sanitize_host_info + + - name: Check that information matches + assert: + that: + - (output_direct.host_info | sanitize_host_info) == (output_https.host_info | sanitize_host_info) always: - - name: Obtain logs from the nginx frontend - command: docker logs {{ daemon_nginx_frontend }} - register: output - ignore_errors: true - - debug: - var: output.stdout_lines - ignore_errors: true + - name: Obtain logs from the nginx frontend + command: docker logs {{ daemon_nginx_frontend }} + register: output + ignore_errors: true + - debug: + var: output.stdout_lines + ignore_errors: true - - name: Remove container - docker_container: - state: absent - name: '{{ daemon_nginx_frontend }}' - force_kill: true - ignore_errors: true + - name: Remove container + docker_container: + state: absent + name: '{{ daemon_nginx_frontend }}' + force_kill: true + ignore_errors: true - - name: Remove volume - docker_volume: - name: '{{ daemon_nginx_frontend }}' - state: absent - ignore_errors: true + - name: Remove volume + docker_volume: + name: '{{ daemon_nginx_frontend }}' + state: absent + ignore_errors: true diff --git a/tests/integration/targets/inventory_docker_containers/playbooks/test_inventory_1.yml b/tests/integration/targets/inventory_docker_containers/playbooks/test_inventory_1.yml index 976b25b2..d1c5c84b 100644 --- a/tests/integration/targets/inventory_docker_containers/playbooks/test_inventory_1.yml +++ b/tests/integration/targets/inventory_docker_containers/playbooks/test_inventory_1.yml @@ -25,15 +25,15 @@ # will be other containers. - inventory_hostname.startswith('ansible-docker-test-docker-inventory-container-') block: - - name: Run raw command - raw: ls / - register: output + - 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" + - 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/tests/integration/targets/inventory_docker_machine/playbooks/test_inventory_1.yml b/tests/integration/targets/inventory_docker_machine/playbooks/test_inventory_1.yml index fb58718d..21fdc000 100644 --- a/tests/integration/targets/inventory_docker_machine/playbooks/test_inventory_1.yml +++ b/tests/integration/targets/inventory_docker_machine/playbooks/test_inventory_1.yml @@ -6,40 +6,40 @@ - hosts: 127.0.0.1 gather_facts: false 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: 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 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 + - name: verify Docker Machine env + command: docker-machine env --shell=sh vm + register: result - - debug: var=result.stdout + - 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" + - 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: false tasks: - - name: do something to verify that accept-new ssh setting was applied by the docker-machine inventory plugin - raw: uname -a - register: result + - 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 + - debug: var=result.stdout - hosts: 127.0.0.1 gather_facts: false @@ -49,7 +49,7 @@ 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 }}" + - 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/tests/integration/targets/setup_docker/tasks/Debian.yml b/tests/integration/targets/setup_docker/tasks/Debian.yml index 2a3e3cae..d1953d18 100644 --- a/tests/integration/targets/setup_docker/tasks/Debian.yml +++ b/tests/integration/targets/setup_docker/tasks/Debian.yml @@ -23,28 +23,28 @@ state: present - block: - - name: Prevent service restart - copy: - content: exit 101 - dest: /usr/sbin/policy-rc.d - backup: true - mode: '0755' - register: policy_rc_d + - 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 + - name: Install Docker CE + apt: + name: '{{ docker_packages if needs_docker_daemon else docker_cli_packages }}' + state: present 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: 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' + - 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/tests/integration/targets/setup_docker/tasks/main.yml b/tests/integration/targets/setup_docker/tasks/main.yml index 54c27e43..4b8313b7 100644 --- a/tests/integration/targets/setup_docker/tasks/main.yml +++ b/tests/integration/targets/setup_docker/tasks/main.yml @@ -90,66 +90,66 @@ msg: "Docker CLI version: {{ docker_cli_version }}; Docker API version: {{ docker_api_version }}" - block: - # Cleanup docker daemon - - name: Show all containers - command: 'docker ps --no-trunc --format {% raw %}"{{.Names}}"{% endraw %}' + # Cleanup docker daemon + - name: Show all containers + command: 'docker ps --no-trunc --format {% raw %}"{{.Names}}"{% endraw %}' - - name: "Remove all ansible-docker-test-* docker containers" - shell: 'docker ps --no-trunc --format {% raw %}"{{.Names}}"{% endraw %} | grep "^ansible-docker-test-" | xargs -r docker rm -f' - register: docker_containers - retries: 3 - delay: 3 - until: docker_containers is success - ignore_errors: true + - name: "Remove all ansible-docker-test-* docker containers" + shell: 'docker ps --no-trunc --format {% raw %}"{{.Names}}"{% endraw %} | grep "^ansible-docker-test-" | xargs -r docker rm -f' + register: docker_containers + retries: 3 + delay: 3 + until: docker_containers is success + ignore_errors: true - - name: "Remove all ansible-docker-test-* docker volumes" - shell: 'docker volume ls --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-docker-test-" | xargs -r docker volume rm -f' - register: docker_volumes - ignore_errors: true + - name: "Remove all ansible-docker-test-* docker volumes" + shell: 'docker volume ls --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-docker-test-" | xargs -r docker volume rm -f' + register: docker_volumes + ignore_errors: true - - name: "Remove all ansible-docker-test-* docker networks" - shell: 'docker network ls --no-trunc --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-docker-test-" | xargs -r docker network rm' - register: docker_networks - ignore_errors: true + - name: "Remove all ansible-docker-test-* docker networks" + shell: 'docker network ls --no-trunc --format {% raw %}"{{.Name}}"{% endraw %} | grep "^ansible-docker-test-" | xargs -r docker network rm' + register: docker_networks + ignore_errors: true - - 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([]) }}" + - 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: true + # List all existing docker resources + - name: List all docker containers + command: docker ps --no-trunc -a + register: docker_containers + ignore_errors: true - - name: List all docker volumes - command: docker volume ls - register: docker_volumes - ignore_errors: true + - name: List all docker volumes + command: docker volume ls + register: docker_volumes + ignore_errors: true - - name: List all docker networks - command: docker network ls --no-trunc - register: docker_networks - ignore_errors: true + - name: List all docker networks + command: docker network ls --no-trunc + register: docker_networks + ignore_errors: true - - name: List all docker images - command: docker images --no-trunc -a - register: docker_images - ignore_errors: true + - name: List all docker images + command: docker images --no-trunc -a + register: docker_images + ignore_errors: true - - 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([]) }}" + - 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', '>') diff --git a/tests/integration/targets/setup_docker_compose_v2/tasks/setup.yml b/tests/integration/targets/setup_docker_compose_v2/tasks/setup.yml index 3da96a33..5bdecd15 100644 --- a/tests/integration/targets/setup_docker_compose_v2/tasks/setup.yml +++ b/tests/integration/targets/setup_docker_compose_v2/tasks/setup.yml @@ -17,34 +17,34 @@ - "{{ role_path }}/vars" - block: - - 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" + - 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" - - name: Install Python on Whales - pip: - state: present - name: python-on-whales - extra_args: "-c {{ remote_constraints }}" + - name: Install Python on Whales + pip: + state: present + name: python-on-whales + extra_args: "-c {{ remote_constraints }}" - - name: Register docker-compose version - command: "docker compose version --short" - register: docker_compose_version + - name: Register docker-compose version + command: "docker compose version --short" + register: docker_compose_version - - name: Declare docker-compose version - set_fact: - docker_compose_version: "{{ docker_compose_version.stdout }}" + - name: Declare docker-compose version + set_fact: + docker_compose_version: "{{ docker_compose_version.stdout }}" - - name: Declare docker-compose as existing - set_fact: - has_docker_compose: '{{ docker_compose_version is version("2.0", ">=") }}' + - name: Declare docker-compose as existing + set_fact: + has_docker_compose: '{{ docker_compose_version is version("2.0", ">=") }}' when: not skip_docker_compose diff --git a/tests/integration/targets/setup_docker_registry/meta/main.yml b/tests/integration/targets/setup_docker_registry/meta/main.yml index f13fc1ad..22aa405a 100644 --- a/tests/integration/targets/setup_docker_registry/meta/main.yml +++ b/tests/integration/targets/setup_docker_registry/meta/main.yml @@ -4,8 +4,8 @@ # SPDX-License-Identifier: GPL-3.0-or-later dependencies: - #- setup_docker -- done in setup.yml, to work around cleanup problems! - #- setup_docker_current_container_network_ip + # - setup_docker -- done in setup.yml, to work around cleanup problems! + # - setup_docker_current_container_network_ip - setup_docker_python_deps - setup_openssl - setup_remote_tmp_dir diff --git a/tests/integration/targets/setup_docker_registry/tasks/setup-frontend.yml b/tests/integration/targets/setup_docker_registry/tasks/setup-frontend.yml index 25bb2029..2f2a500e 100644 --- a/tests/integration/targets/setup_docker_registry/tasks/setup-frontend.yml +++ b/tests/integration/targets/setup_docker_registry/tasks/setup-frontend.yml @@ -18,9 +18,9 @@ # `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' + - '{{ docker_registry_container_name_registry }}:real-registry' volumes: - - '{{ docker_registry_container_name_frontend }}:/etc/nginx/' + - '{{ docker_registry_container_name_frontend }}:/etc/nginx/' network_mode: '{{ current_container_network_ip | default(omit, true) }}' networks: >- {{ @@ -35,8 +35,8 @@ dest: "{{ remote_tmp_dir }}/{{ item }}" mode: "0644" loop: - - nginx.conf - - nginx.htpasswd + - nginx.conf + - nginx.htpasswd - name: Copy static files into volume docker_container_copy_into: @@ -46,74 +46,74 @@ owner_id: 0 group_id: 0 loop: - - nginx.conf - - nginx.htpasswd + - nginx.conf + - nginx.htpasswd register: can_copy_files ignore_errors: true - when: can_copy_files is not failed block: - - name: Create private key for frontend certificate - community.crypto.openssl_privatekey: - path: '{{ remote_tmp_dir }}/cert.key' - type: ECC - curve: secp256r1 - force: true + - name: Create private key for frontend certificate + community.crypto.openssl_privatekey: + path: '{{ remote_tmp_dir }}/cert.key' + type: ECC + curve: secp256r1 + force: true - - name: Create CSR for frontend certificate - community.crypto.openssl_csr: - path: '{{ remote_tmp_dir }}/cert.csr' - privatekey_path: '{{ remote_tmp_dir }}/cert.key' - subject_alt_name: - - DNS:test-registry.ansible.com + - name: Create CSR for frontend certificate + community.crypto.openssl_csr: + path: '{{ remote_tmp_dir }}/cert.csr' + privatekey_path: '{{ remote_tmp_dir }}/cert.key' + subject_alt_name: + - DNS:test-registry.ansible.com - - name: Create frontend certificate - community.crypto.x509_certificate: - path: '{{ remote_tmp_dir }}/cert.pem' - csr_path: '{{ remote_tmp_dir }}/cert.csr' - privatekey_path: '{{ remote_tmp_dir }}/cert.key' - provider: selfsigned + - name: Create frontend certificate + community.crypto.x509_certificate: + path: '{{ remote_tmp_dir }}/cert.pem' + csr_path: '{{ remote_tmp_dir }}/cert.csr' + privatekey_path: '{{ remote_tmp_dir }}/cert.key' + provider: selfsigned - - name: Copy dynamic files into volume - docker_container_copy_into: - container: '{{ docker_registry_container_name_frontend }}' - path: '{{ remote_tmp_dir }}/{{ item }}' - container_path: '/etc/nginx/{{ item }}' - owner_id: 0 - group_id: 0 - loop: - - cert.pem - - cert.key + - name: Copy dynamic files into volume + docker_container_copy_into: + container: '{{ docker_registry_container_name_frontend }}' + path: '{{ remote_tmp_dir }}/{{ item }}' + container_path: '/etc/nginx/{{ item }}' + owner_id: 0 + group_id: 0 + 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: 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: 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: 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 + - 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' diff --git a/tests/integration/targets/setup_docker_registry/tasks/setup.yml b/tests/integration/targets/setup_docker_registry/tasks/setup.yml index 454c6604..2c738905 100644 --- a/tests/integration/targets/setup_docker_registry/tasks/setup.yml +++ b/tests/integration/targets/setup_docker_registry/tasks/setup.yml @@ -30,12 +30,12 @@ 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_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 }}' + - '{{ 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 }} @@ -47,42 +47,42 @@ 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: 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 }} + - 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 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_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 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 }}' + - 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 }}" + # 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/tests/unit/requirements.yml b/tests/unit/requirements.yml index e91ea474..c66f4e78 100644 --- a/tests/unit/requirements.yml +++ b/tests/unit/requirements.yml @@ -4,5 +4,5 @@ # SPDX-License-Identifier: GPL-3.0-or-later collections: -- community.internal_test_tools -- community.library_inventory_filtering_v1 + - community.internal_test_tools + - community.library_inventory_filtering_v1