From f7823ea626f82dcb1e9963899d630b6478895fbf Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Fri, 18 Oct 2024 21:01:49 +0200 Subject: [PATCH] Prepare 4.0.0 release. (#971) --- .azure-pipelines/azure-pipelines.yml | 56 - .github/workflows/ansible-test.yml | 112 +- .github/workflows/ee.yml | 13 - README.md | 4 +- changelogs/fragments/4.0.0.yml | 9 + galaxy.yml | 2 +- meta/runtime.yml | 5 +- plugins/connection/docker_api.py | 1 - plugins/doc_fragments/docker.py | 31 +- plugins/inventory/docker_containers.py | 1 - plugins/inventory/docker_swarm.py | 10 - plugins/module_utils/common.py | 15 - plugins/module_utils/common_api.py | 3 - .../module_utils/module_container/module.py | 38 +- plugins/module_utils/util.py | 6 - plugins/module_utils/version.py | 13 +- plugins/modules/docker_compose.py | 1248 ----------------- plugins/modules/docker_compose_v2.py | 1 - plugins/modules/docker_container.py | 25 +- .../targets/docker_compose/aliases | 6 - .../targets/docker_compose/meta/main.yml | 8 - .../targets/docker_compose/tasks/main.yml | 53 - .../targets/docker_compose/tasks/run-test.yml | 7 - .../docker_compose/tasks/tests/options.yml | 243 ---- .../docker_compose/tasks/tests/start-stop.yml | 233 --- .../tasks/tests/image-ids.yml | 2 + .../docker_container/tasks/tests/network.yml | 10 +- .../docker_container/tasks/tests/options.yml | 11 +- .../setup_docker_compose_v1/defaults/main.yml | 15 - .../setup_docker_compose_v1/meta/main.yml | 8 - .../setup_docker_compose_v1/tasks/Alpine.yml | 9 - .../tasks/Archlinux.yml | 9 - .../setup_docker_compose_v1/tasks/Debian.yml | 9 - .../setup_docker_compose_v1/tasks/Fedora.yml | 10 - .../tasks/RedHat-7.yml | 9 - .../tasks/RedHat-8.yml | 9 - .../tasks/RedHat-9.yml | 9 - .../setup_docker_compose_v1/tasks/Suse.yml | 12 - .../setup_docker_compose_v1/tasks/main.yml | 16 - .../setup_docker_compose_v1/tasks/setup.yml | 79 -- .../setup_docker_compose_v1/vars/Alpine.yml | 13 - .../vars/Archlinux.yml | 11 - .../setup_docker_compose_v1/vars/CentOS-8.yml | 6 - .../vars/Debian-11.yml | 8 - .../vars/Debian-12.yml | 8 - .../setup_docker_compose_v1/vars/RedHat-7.yml | 10 - .../setup_docker_compose_v1/vars/RedHat-8.yml | 6 - .../setup_docker_compose_v1/vars/RedHat-9.yml | 6 - .../setup_docker_compose_v1/vars/Suse-py2.yml | 6 - .../setup_docker_compose_v1/vars/Suse-py3.yml | 6 - .../vars/Ubuntu-14.yml | 9 - .../vars/Ubuntu-16.yml | 6 - .../vars/Ubuntu-18.yml | 6 - .../setup_docker_compose_v1/vars/Ubuntu.yml | 6 - .../setup_docker_compose_v1/vars/default.yml | 4 - tests/sanity/ignore-2.11.txt | 14 - tests/sanity/ignore-2.11.txt.license | 3 - tests/sanity/ignore-2.12.txt | 6 - tests/sanity/ignore-2.12.txt.license | 3 - tests/sanity/ignore-2.13.txt | 4 - tests/sanity/ignore-2.13.txt.license | 3 - tests/sanity/ignore-2.14.txt | 3 - tests/sanity/ignore-2.14.txt.license | 3 - 63 files changed, 42 insertions(+), 2468 deletions(-) create mode 100644 changelogs/fragments/4.0.0.yml delete mode 100644 plugins/modules/docker_compose.py delete mode 100644 tests/integration/targets/docker_compose/aliases delete mode 100644 tests/integration/targets/docker_compose/meta/main.yml delete mode 100644 tests/integration/targets/docker_compose/tasks/main.yml delete mode 100644 tests/integration/targets/docker_compose/tasks/run-test.yml delete mode 100644 tests/integration/targets/docker_compose/tasks/tests/options.yml delete mode 100644 tests/integration/targets/docker_compose/tasks/tests/start-stop.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/defaults/main.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/meta/main.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/tasks/Alpine.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/tasks/Archlinux.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/tasks/Debian.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/tasks/Fedora.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/tasks/RedHat-7.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/tasks/RedHat-8.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/tasks/RedHat-9.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/tasks/Suse.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/tasks/main.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/tasks/setup.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/Alpine.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/Archlinux.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/CentOS-8.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/Debian-11.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/Debian-12.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/RedHat-7.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/RedHat-8.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/RedHat-9.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/Suse-py2.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/Suse-py3.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu-14.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu-16.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu-18.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu.yml delete mode 100644 tests/integration/targets/setup_docker_compose_v1/vars/default.yml delete mode 100644 tests/sanity/ignore-2.11.txt delete mode 100644 tests/sanity/ignore-2.11.txt.license delete mode 100644 tests/sanity/ignore-2.12.txt delete mode 100644 tests/sanity/ignore-2.12.txt.license delete mode 100644 tests/sanity/ignore-2.13.txt delete mode 100644 tests/sanity/ignore-2.13.txt.license delete mode 100644 tests/sanity/ignore-2.14.txt delete mode 100644 tests/sanity/ignore-2.14.txt.license diff --git a/.azure-pipelines/azure-pipelines.yml b/.azure-pipelines/azure-pipelines.yml index 6c18a277..0d37dfa9 100644 --- a/.azure-pipelines/azure-pipelines.yml +++ b/.azure-pipelines/azure-pipelines.yml @@ -99,17 +99,6 @@ stages: test: '2.16/sanity/1' - name: Units test: '2.16/units/1' - - stage: Ansible_2_15 - displayName: Sanity & Units 2.15 - dependsOn: [] - jobs: - - template: templates/matrix.yml - parameters: - targets: - - name: Sanity - test: '2.15/sanity/1' - - name: Units - test: '2.15/units/1' ### Docker - stage: Docker_devel @@ -131,7 +120,6 @@ stages: groups: - 4 - 5 - # - 6 -- some images no longer work with docker-compose v1 - stage: Docker_2_18 displayName: Docker 2.18 dependsOn: [] @@ -145,7 +133,6 @@ stages: groups: - 4 - 5 - # - 6 -- some images no longer work with docker-compose v1 - stage: Docker_2_17 displayName: Docker 2.17 dependsOn: [] @@ -163,7 +150,6 @@ stages: groups: - 4 - 5 - - 6 - stage: Docker_2_16 displayName: Docker 2.16 dependsOn: [] @@ -183,23 +169,6 @@ stages: groups: - 4 - 5 - - 6 - - stage: Docker_2_15 - displayName: Docker 2.15 - dependsOn: [] - jobs: - - template: templates/matrix.yml - parameters: - testFormat: 2.15/linux/{0} - targets: - - name: Fedora 37 - test: fedora37 - - name: CentOS 7 - test: centos7 - groups: - - 4 - - 5 - - 6 ### Community Docker - stage: Docker_community_devel @@ -219,7 +188,6 @@ stages: groups: - 4 - 5 - - 6 ### Remote - stage: Remote_devel @@ -238,7 +206,6 @@ stages: - 3 - 4 - 5 - # - 6 -- Docker 26 no longer works with docker-compose v1 - stage: Remote_2_18 displayName: Remote 2.18 dependsOn: [] @@ -255,7 +222,6 @@ stages: - 3 - 4 - 5 - # - 6 -- Docker 26 no longer works with docker-compose v1 - stage: Remote_2_17 displayName: Remote 2.17 dependsOn: [] @@ -272,7 +238,6 @@ stages: - 3 - 4 - 5 - # - 6 -- Docker 26 no longer works with docker-compose v1 - stage: Remote_2_16 displayName: Remote 2.16 dependsOn: [] @@ -286,24 +251,6 @@ stages: # Currently always hangs in group 2 # - name: RHEL 8.8 # test: rhel/8.8 - groups: - - 1 - - 2 - - 3 - - 4 - - 5 - - stage: Remote_2_15 - displayName: Remote 2.15 - dependsOn: [] - jobs: - - template: templates/matrix.yml - parameters: - testFormat: 2.15/{0} - targets: - - name: RHEL 9.1 - test: rhel/9.1 - - name: RHEL 8.7 - test: rhel/8.7 - name: RHEL 7.9 test: rhel/7.9 groups: @@ -322,17 +269,14 @@ stages: - Ansible_2_18 - Ansible_2_17 - Ansible_2_16 - - Ansible_2_15 - Remote_devel - Remote_2_18 - Remote_2_17 - Remote_2_16 - - Remote_2_15 - Docker_devel - Docker_2_18 - Docker_2_17 - Docker_2_16 - - Docker_2_15 - Docker_community_devel jobs: - template: templates/coverage.yml diff --git a/.github/workflows/ansible-test.yml b/.github/workflows/ansible-test.yml index 3afb663a..6a5072cd 100644 --- a/.github/workflows/ansible-test.yml +++ b/.github/workflows/ansible-test.yml @@ -29,10 +29,7 @@ jobs: strategy: matrix: ansible: - - '2.11' - - '2.12' - - '2.13' - - '2.14' + - '2.15' # Ansible-test on various stable branches does not yet work well with cgroups v2. # Since ubuntu-latest now uses Ubuntu 22.04, we need to fall back to the ubuntu-20.04 # image for these stable branches. The list of branches where this is necessary will @@ -71,10 +68,7 @@ jobs: fail-fast: true matrix: ansible: - - '2.11' - - '2.12' - - '2.13' - - '2.14' + - '2.15' steps: - name: Perform unit testing against Ansible version ${{ matrix.ansible }} @@ -118,107 +112,15 @@ jobs: exclude: - ansible: '' include: - # 2.11 - - ansible: '2.11' - docker: alpine3 + # 2.15 + - ansible: '2.15' + docker: fedora37 python: '' target: azp/4/ - extra-constraints: urllib3 < 2.0.0 - - ansible: '2.11' - docker: alpine3 + - ansible: '2.15' + docker: fedora37 python: '' target: azp/5/ - - ansible: '2.11' - docker: alpine3 - python: '' - target: azp/6/ - # 2.12 - - ansible: '2.12' - docker: fedora33 - python: '' - target: azp/4/ - - ansible: '2.12' - docker: fedora33 - python: '' - target: azp/5/ - - ansible: '2.12' - docker: fedora33 - python: '' - target: azp/6/ - - ansible: '2.12' - docker: fedora34 - python: '' - target: azp/4/ - - ansible: '2.12' - docker: fedora34 - python: '' - target: azp/5/ - - ansible: '2.12' - docker: fedora34 - python: '' - target: azp/6/ - - ansible: '2.12' - docker: ubuntu1804 - python: '' - target: azp/4/ - - ansible: '2.12' - docker: ubuntu1804 - python: '' - target: azp/5/ - - ansible: '2.12' - docker: ubuntu1804 - python: '' - target: azp/6/ - # 2.13 - - ansible: '2.13' - docker: fedora35 - python: '' - target: azp/4/ - - ansible: '2.13' - docker: fedora35 - python: '' - target: azp/5/ - - ansible: '2.13' - docker: fedora35 - python: '' - target: azp/6/ - - ansible: '2.13' - docker: opensuse15py2 - python: '' - target: azp/4/ - - ansible: '2.13' - docker: opensuse15py2 - python: '' - target: azp/5/ - - ansible: '2.13' - docker: opensuse15py2 - python: '' - target: azp/6/ - - ansible: '2.13' - docker: alpine3 - python: '' - target: azp/4/ - - ansible: '2.13' - docker: alpine3 - python: '' - target: azp/5/ - - ansible: '2.13' - docker: alpine3 - python: '' - target: azp/6/ - # 2.14 - - ansible: '2.14' - docker: alpine3 - python: '' - target: azp/4/ - - ansible: '2.14' - docker: alpine3 - python: '' - target: azp/5/ - - ansible: '2.14' - docker: alpine3 - python: '' - target: azp/6/ steps: - name: Perform integration testing against Ansible version ${{ matrix.ansible }} under Python ${{ matrix.python }} diff --git a/.github/workflows/ee.yml b/.github/workflows/ee.yml index adc5f555..fd9c7cc6 100644 --- a/.github/workflows/ee.yml +++ b/.github/workflows/ee.yml @@ -57,19 +57,6 @@ jobs: ansible_runner: ansible-runner base_image: quay.io/rockylinux/rockylinux:9 pre_base: '"#"' - - name: ansible-core 2.14 @ CentOS Stream 9 - ansible_core: https://github.com/ansible/ansible/archive/stable-2.14.tar.gz - ansible_runner: ansible-runner - base_image: quay.io/centos/centos:stream9 - pre_base: '"#"' - - name: ansible-core 2.13 @ RHEL UBI 8 - ansible_core: https://github.com/ansible/ansible/archive/stable-2.13.tar.gz - ansible_runner: ansible-runner - other_deps: |2 - python_interpreter: - package_system: python39 python39-pip python39-wheel python39-cryptography - base_image: docker.io/redhat/ubi8:latest - pre_base: '"#"' runs-on: ubuntu-latest steps: - name: Check out code diff --git a/README.md b/README.md index 6ac0e545..fe36c868 100644 --- a/README.md +++ b/README.md @@ -37,9 +37,7 @@ For more information about communication, see the [Ansible communication guide]( ## Tested with Ansible -Tested with the current ansible-core 2.11, ansible-core 2.12, ansible-core 2.13, ansible-core 2.14, ansible-core 2.15, ansible-core 2.16, ansible-core 2.17, and ansible-core 2.18 releases, and the current development version of ansible-core. Ansible/ansible-base versions before 2.11.0 are not supported. - -Please note that Ansible 2.9 and ansible-base 2.10 are no longer supported. If you need to use them, use community.docker 2.x.y. Also note that this collection does not work with ansible-core 2.11 (this includes ansible-base and Ansible 2.9) on Python 3.12+. +Tested with the current ansible-core 2.15, ansible-core 2.16, ansible-core 2.17, and ansible-core 2.18 releases, and the current development version of ansible-core. Ansible/ansible-base versions before 2.15.0 are not supported. ## External requirements diff --git a/changelogs/fragments/4.0.0.yml b/changelogs/fragments/4.0.0.yml new file mode 100644 index 00000000..dc0e6ed6 --- /dev/null +++ b/changelogs/fragments/4.0.0.yml @@ -0,0 +1,9 @@ +release_summary: Major release with removed deprecated features. +removed_features: + - "The collection no longer supports ansible-core 2.11, 2.12, 2.13, and 2.14. You need ansible-core 2.15.0 or newer to use community.docker 4.x.y (https://github.com/ansible-collections/community.docker/pull/971)." + - "The docker_compose module has been removed. Please migrate to community.docker.docker_compose_v2 (https://github.com/ansible-collections/community.docker/pull/971)." + - "various modules and plugins - remove the ``ssl_version`` option (https://github.com/ansible-collections/community.docker/pull/971)." + - "docker_container - the ``ignore_image`` option has been removed. Use ``image: ignore`` in ``comparisons`` instead (https://github.com/ansible-collections/community.docker/pull/971)." + - "docker_container - the ``purge_networks`` option has been removed. Use ``networks: strict`` in ``comparisons`` instead and make sure that ``networks`` is specified (https://github.com/ansible-collections/community.docker/pull/971)." +breaking_changes: + - "docker_container - the default of ``image_name_mismatch`` changed from ``ignore`` to ``recreate`` (https://github.com/ansible-collections/community.docker/pull/971)." diff --git a/galaxy.yml b/galaxy.yml index 64c8010b..8bee89cd 100644 --- a/galaxy.yml +++ b/galaxy.yml @@ -7,7 +7,7 @@ namespace: community name: docker -version: 3.13.2 +version: 4.0.0 readme: README.md authors: - Ansible Docker Working Group diff --git a/meta/runtime.yml b/meta/runtime.yml index 150d93f1..e228ab55 100644 --- a/meta/runtime.yml +++ b/meta/runtime.yml @@ -3,10 +3,9 @@ # 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 -requires_ansible: '>=2.11.0' +requires_ansible: '>=2.15.0' action_groups: docker: - - docker_compose - docker_compose_v2 - docker_compose_v2_exec - docker_compose_v2_pull @@ -47,6 +46,6 @@ action_groups: plugin_routing: modules: docker_compose: - deprecation: + tombstone: removal_version: 4.0.0 warning_text: This module uses docker-compose v1, which is End of Life since July 2022. Please migrate to community.docker.docker_compose_v2. diff --git a/plugins/connection/docker_api.py b/plugins/connection/docker_api.py index d5bd3b6a..1c3fc652 100644 --- a/plugins/connection/docker_api.py +++ b/plugins/connection/docker_api.py @@ -21,7 +21,6 @@ notes: with Python's C(SSLSocket)s. See U(https://github.com/ansible-collections/community.docker/issues/605) for more information. extends_documentation_fragment: - community.docker.docker.api_documentation - - community.docker.docker.ssl_version_deprecation - community.docker.docker.var_names options: remote_user: diff --git a/plugins/doc_fragments/docker.py b/plugins/doc_fragments/docker.py index c79620e7..b2e21393 100644 --- a/plugins/doc_fragments/docker.py +++ b/plugins/doc_fragments/docker.py @@ -71,14 +71,6 @@ options: the file C(key.pem) from the directory specified in the environment variable E(DOCKER_CERT_PATH) will be used. type: path aliases: [ tls_client_key, key_path ] - ssl_version: - description: - - Provide a valid SSL version number. Default value determined by L(SSL Python module, https://docs.python.org/3/library/ssl.html). - - If the value is not specified in the task, the value of environment variable E(DOCKER_SSL_VERSION) will be - used instead. - - B(Note:) this option is no longer supported for Docker SDK for Python 7.0.0+. Specifying it with Docker SDK for - Python 7.0.0 or newer will lead to an error. - type: str tls: description: - Secure the connection to the API by using TLS without verifying the authenticity of the Docker host @@ -110,7 +102,7 @@ options: notes: - Connect to the Docker daemon by providing parameters with each task or by defining environment variables. - You can define E(DOCKER_HOST), E(DOCKER_TLS_HOSTNAME), E(DOCKER_API_VERSION), E(DOCKER_CERT_PATH), E(DOCKER_SSL_VERSION), + You can define E(DOCKER_HOST), E(DOCKER_TLS_HOSTNAME), E(DOCKER_API_VERSION), E(DOCKER_CERT_PATH), E(DOCKER_TLS), E(DOCKER_TLS_VERIFY) and E(DOCKER_TIMEOUT). If you are using docker machine, run the script shipped with the product that sets up the environment. It will set these variables for you. See U(https://docs.docker.com/machine/reference/env/) for more details. @@ -148,9 +140,6 @@ options: client_key: vars: - name: ansible_docker_client_key - ssl_version: - vars: - - name: ansible_docker_ssl_version tls: vars: - name: ansible_docker_tls @@ -250,12 +239,6 @@ options: the file C(key.pem) from the directory specified in the environment variable E(DOCKER_CERT_PATH) will be used. type: path aliases: [ tls_client_key, key_path ] - ssl_version: - description: - - Provide a valid SSL version number. Default value determined by L(SSL Python module, https://docs.python.org/3/library/ssl.html). - - If the value is not specified in the task, the value of environment variable E(DOCKER_SSL_VERSION) will be - used instead. - type: str tls: description: - Secure the connection to the API by using TLS without verifying the authenticity of the Docker host @@ -286,7 +269,7 @@ options: notes: - Connect to the Docker daemon by providing parameters with each task or by defining environment variables. - You can define E(DOCKER_HOST), E(DOCKER_TLS_HOSTNAME), E(DOCKER_API_VERSION), E(DOCKER_CERT_PATH), E(DOCKER_SSL_VERSION), + You can define E(DOCKER_HOST), E(DOCKER_TLS_HOSTNAME), E(DOCKER_API_VERSION), E(DOCKER_CERT_PATH), E(DOCKER_TLS), E(DOCKER_TLS_VERIFY) and E(DOCKER_TIMEOUT). If you are using docker machine, run the script shipped with the product that sets up the environment. It will set these variables for you. See U(https://docs.docker.com/machine/reference/env/) for more details. @@ -394,13 +377,3 @@ notes: - This module does B(not) use the L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) to communicate with the Docker daemon. It directly calls the Docker CLI program. ''' - - # DEPRECATED: this will be removed from community.docker 4.0.0! Use with care! - SSL_VERSION_DEPRECATION = ''' -options: - ssl_version: - deprecated: - why: This was necessary a long time ago to handle problems with older TLS/SSL versions. It is no longer necessary nowadays. - version: 4.0.0 - alternatives: None. -''' diff --git a/plugins/inventory/docker_containers.py b/plugins/inventory/docker_containers.py index fc1977dc..5e27d59b 100644 --- a/plugins/inventory/docker_containers.py +++ b/plugins/inventory/docker_containers.py @@ -21,7 +21,6 @@ author: extends_documentation_fragment: - ansible.builtin.constructed - community.docker.docker.api_documentation - - community.docker.docker.ssl_version_deprecation - community.library_inventory_filtering_v1.inventory_filter description: - Reads inventories from the Docker API. diff --git a/plugins/inventory/docker_swarm.py b/plugins/inventory/docker_swarm.py index c0f97d9f..f613bfe2 100644 --- a/plugins/inventory/docker_swarm.py +++ b/plugins/inventory/docker_swarm.py @@ -77,15 +77,6 @@ DOCUMENTATION = r''' description: When verifying the authenticity of the Docker host server, provide the expected name of the server. type: str - ssl_version: - description: - - Provide a valid SSL version number. Default value determined - by L(SSL Python module, https://docs.python.org/3/library/ssl.html). - type: str - deprecated: - why: This was necessary a long time ago to handle problems with SSL versions. It is no longer necessary nowadays. - version: 4.0.0 - alternatives: None. api_version: description: - The version of the Docker API running on the Docker Host. @@ -197,7 +188,6 @@ class InventoryModule(BaseInventoryPlugin, Constructable): tls_hostname=self.get_option('tls_hostname'), api_version=self.get_option('api_version'), timeout=self.get_option('timeout'), - ssl_version=self.get_option('ssl_version'), use_ssh_client=self.get_option('use_ssh_client'), debug=None, ) diff --git a/plugins/module_utils/common.py b/plugins/module_utils/common.py index d1dcf3e6..436598df 100644 --- a/plugins/module_utils/common.py +++ b/plugins/module_utils/common.py @@ -122,18 +122,6 @@ if not HAS_DOCKER_PY: def _get_tls_config(fail_function, **kwargs): - if 'ssl_version' in kwargs and LooseVersion(docker_version) >= LooseVersion('7.0.0b1'): - ssl_version = kwargs.pop('ssl_version') - if ssl_version is not None: - fail_function( - "ssl_version is not compatible with Docker SDK for Python 7.0.0+. You are using" - " Docker SDK for Python {docker_py_version}. The ssl_version option (value: {ssl_version})" - " has either been set directly or with the environment variable DOCKER_SSL_VERSION." - " Make sure it is not set, or switch to an older version of Docker SDK for Python.".format( - docker_py_version=docker_version, - ssl_version=ssl_version, - ) - ) if 'assert_hostname' in kwargs and LooseVersion(docker_version) >= LooseVersion('7.0.0b1'): assert_hostname = kwargs.pop('assert_hostname') if assert_hostname is not None: @@ -174,7 +162,6 @@ def get_connect_params(auth, fail_function): tls_config = dict( verify=True, assert_hostname=auth['tls_hostname'], - ssl_version=auth['ssl_version'], fail_function=fail_function, ) if auth['cert_path'] and auth['key_path']: @@ -186,7 +173,6 @@ def get_connect_params(auth, fail_function): # TLS without verification tls_config = dict( verify=False, - ssl_version=auth['ssl_version'], fail_function=fail_function, ) if auth['cert_path'] and auth['key_path']: @@ -334,7 +320,6 @@ class AnsibleDockerClientBase(Client): cacert_path=self._get_value('cacert_path', params['ca_path'], 'DOCKER_CERT_PATH', None, type='str'), cert_path=self._get_value('cert_path', params['client_cert'], 'DOCKER_CERT_PATH', None, type='str'), key_path=self._get_value('key_path', params['client_key'], 'DOCKER_CERT_PATH', None, type='str'), - ssl_version=self._get_value('ssl_version', params['ssl_version'], 'DOCKER_SSL_VERSION', None, type='str'), tls=self._get_value('tls', params['tls'], 'DOCKER_TLS', DEFAULT_TLS, type='bool'), tls_verify=self._get_value('tls_verfy', params['validate_certs'], 'DOCKER_TLS_VERIFY', DEFAULT_TLS_VERIFY, type='bool'), diff --git a/plugins/module_utils/common_api.py b/plugins/module_utils/common_api.py index b5ea42fa..80d39461 100644 --- a/plugins/module_utils/common_api.py +++ b/plugins/module_utils/common_api.py @@ -83,7 +83,6 @@ def get_connect_params(auth_data, fail_function): tls_config = dict( verify=True, assert_hostname=auth_data['tls_hostname'], - ssl_version=auth_data['ssl_version'], fail_function=fail_function, ) if auth_data['cert_path'] and auth_data['key_path']: @@ -95,7 +94,6 @@ def get_connect_params(auth_data, fail_function): # TLS without verification tls_config = dict( verify=False, - ssl_version=auth_data['ssl_version'], fail_function=fail_function, ) if auth_data['cert_path'] and auth_data['key_path']: @@ -205,7 +203,6 @@ class AnsibleDockerClientBase(Client): cacert_path=self._get_value('cacert_path', params['ca_path'], 'DOCKER_CERT_PATH', None, type='str'), cert_path=self._get_value('cert_path', params['client_cert'], 'DOCKER_CERT_PATH', None, type='str'), key_path=self._get_value('key_path', params['client_key'], 'DOCKER_CERT_PATH', None, type='str'), - ssl_version=self._get_value('ssl_version', params['ssl_version'], 'DOCKER_SSL_VERSION', None, type='str'), tls=self._get_value('tls', params['tls'], 'DOCKER_TLS', DEFAULT_TLS, type='bool'), tls_verify=self._get_value('tls_verfy', params['validate_certs'], 'DOCKER_TLS_VERIFY', DEFAULT_TLS_VERIFY, type='bool'), diff --git a/plugins/module_utils/module_container/module.py b/plugins/module_utils/module_container/module.py index c97170a3..70dd1aba 100644 --- a/plugins/module_utils/module_container/module.py +++ b/plugins/module_utils/module_container/module.py @@ -135,11 +135,6 @@ class ContainerManager(DockerBaseClass): comp_aliases[option_name] = option_name for alias in option.ansible_aliases: comp_aliases[alias] = option_name - # Process legacy ignore options - if self.module.params['ignore_image']: - self.all_options['image'].comparison = 'ignore' - if self.module.params['purge_networks']: - self.all_options['networks'].comparison = 'strict' # Process comparisons specified by user if self.module.params.get('comparisons'): # If '*' appears in comparisons, process it first @@ -184,11 +179,6 @@ class ContainerManager(DockerBaseClass): for option in self.all_options.values(): if option.copy_comparison_from is not None: option.comparison = self.all_options[option.copy_comparison_from].comparison - # Check legacy values - if self.module.params['ignore_image'] and self.all_options['image'].comparison != 'ignore': - self.module.warn('The ignore_image option has been overridden by the comparisons option!') - if self.module.params['purge_networks'] and self.all_options['networks'].comparison != 'strict': - self.module.warn('The purge_networks option has been overridden by the comparisons option!') def _update_params(self): if self.param_networks_cli_compatible is True and self.module.params['networks'] and self.module.params['network_mode'] is None: @@ -332,20 +322,9 @@ class ContainerManager(DockerBaseClass): image_different = False if self.all_options['image'].comparison == 'strict': image_different = self._image_is_different(image, container) - if self.param_image_name_mismatch != 'ignore' and self.param_image is not None and self.param_image != container.image_name: - if self.param_image_name_mismatch == 'recreate': - different = True - self.diff_tracker.add('image_name', parameter=self.param_image, active=container.image_name) - else: - # The default has been deprecated! - self.module.deprecate( - 'The default value "ignore" for image_name_mismatch has been deprecated and will change to "recreate"' - ' in community.docker 4.0.0. In the current situation, this would cause the container to be recreated' - ' since the current container\'s image name "{active}" does not match the desired image name "{parameter}".'.format( - parameter=self.param_image, active=container.image_name), - version='4.0.0', - collection_name='community.docker', - ) + if self.param_image_name_mismatch == 'recreate' and self.param_image is not None and self.param_image != container.image_name: + different = True + self.diff_tracker.add('image_name', parameter=self.param_image, active=container.image_name) if image_different or different or self.param_recreate: self.diff_tracker.merge(differences) self.diff['differences'] = differences.get_legacy_docker_container_diffs() @@ -704,13 +683,6 @@ class ContainerManager(DockerBaseClass): updated_container = self._add_networks(container, network_differences) purge_networks = self.all_options['networks'].comparison == 'strict' and self.module.params['networks'] is not None - if not purge_networks and self.module.params['purge_networks']: - purge_networks = True - self.module.deprecate( - 'The purge_networks option is used while networks is not specified. In this case purge_networks=true cannot' - ' be replaced by `networks: strict` in comparisons, which is necessary once purge_networks is removed.' - ' Please modify the docker_container invocation by adding `networks: []`', - version='4.0.0', collection_name='community.docker') if purge_networks: has_extra_networks, extra_networks = self.has_extra_networks(container) if has_extra_networks: @@ -890,11 +862,10 @@ def run_module(engine_driver): command_handling=dict(type='str', choices=['compatibility', 'correct'], default='correct'), default_host_ip=dict(type='str'), force_kill=dict(type='bool', default=False, aliases=['forcekill']), - ignore_image=dict(type='bool', default=False, removed_in_version='4.0.0', removed_from_collection='community.docker'), image=dict(type='str'), image_comparison=dict(type='str', choices=['desired-image', 'current-image'], default='desired-image'), image_label_mismatch=dict(type='str', choices=['ignore', 'fail'], default='ignore'), - image_name_mismatch=dict(type='str', choices=['ignore', 'recreate']), + image_name_mismatch=dict(type='str', choices=['ignore', 'recreate'], default='recreate'), keep_volumes=dict(type='bool', default=True), kill_signal=dict(type='str'), name=dict(type='str', required=True), @@ -903,7 +874,6 @@ def run_module(engine_driver): paused=dict(type='bool'), pull=dict(type='raw', choices=['never', 'missing', 'always', True, False], default='missing'), pull_check_mode_behavior=dict(type='str', choices=['image_not_present', 'always'], default='image_not_present'), - purge_networks=dict(type='bool', default=False, removed_in_version='4.0.0', removed_from_collection='community.docker'), recreate=dict(type='bool', default=False), removal_wait_timeout=dict(type='float'), restart=dict(type='bool', default=False), diff --git a/plugins/module_utils/util.py b/plugins/module_utils/util.py index 9235e34d..1c472a78 100644 --- a/plugins/module_utils/util.py +++ b/plugins/module_utils/util.py @@ -29,12 +29,6 @@ DOCKER_COMMON_ARGS = dict( ca_path=dict(type='path', aliases=['ca_cert', 'tls_ca_cert', 'cacert_path']), client_cert=dict(type='path', aliases=['tls_client_cert', 'cert_path']), client_key=dict(type='path', aliases=['tls_client_key', 'key_path']), - ssl_version=dict( - type='str', - fallback=(env_fallback, ['DOCKER_SSL_VERSION']), - removed_in_version='4.0.0', - removed_from_collection='community.docker', - ), tls=dict(type='bool', default=DEFAULT_TLS, fallback=(env_fallback, ['DOCKER_TLS'])), use_ssh_client=dict(type='bool', default=False), validate_certs=dict(type='bool', default=DEFAULT_TLS_VERIFY, fallback=(env_fallback, ['DOCKER_TLS_VERIFY']), aliases=['tls_verify']), diff --git a/plugins/module_utils/version.py b/plugins/module_utils/version.py index 5184d70e..586b694b 100644 --- a/plugins/module_utils/version.py +++ b/plugins/module_utils/version.py @@ -10,15 +10,4 @@ from __future__ import absolute_import, division, print_function __metaclass__ = type -# Once we drop support for ansible-core 2.11, we can remove the try/except. - -from ansible.module_utils.six import raise_from - -try: - from ansible.module_utils.compat.version import LooseVersion, StrictVersion # noqa: F401, pylint: disable=unused-import -except ImportError: - try: - from distutils.version import LooseVersion, StrictVersion # noqa: F401, pylint: disable=unused-import - except ImportError as exc: - msg = 'To use this plugin or module with ansible-core 2.11, you need to use Python < 3.12 with distutils.version present' - raise_from(ImportError(msg), exc) +from ansible.module_utils.compat.version import LooseVersion, StrictVersion # noqa: F401, pylint: disable=unused-import diff --git a/plugins/modules/docker_compose.py b/plugins/modules/docker_compose.py deleted file mode 100644 index dcba5adf..00000000 --- a/plugins/modules/docker_compose.py +++ /dev/null @@ -1,1248 +0,0 @@ -#!/usr/bin/python -# -# Copyright 2016 Red Hat | Ansible -# 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 - -from __future__ import absolute_import, division, print_function -__metaclass__ = type - - -DOCUMENTATION = ''' - -module: docker_compose - -short_description: Manage multi-container Docker applications with Docker Compose V1 - -deprecated: - removed_in: 4.0.0 - why: This module uses docker-compose v1, which is End of Life since July 2022. - alternative: Migrate to M(community.docker.docker_compose_v2) - -author: "Chris Houseknecht (@chouseknecht)" - -description: - - Uses Docker Compose to start, shutdown and scale services. B(This module requires docker-compose < 2.0.0.) - Use the M(community.docker.docker_compose_v2) module for using the modern Docker compose CLI plugin. - - Configuration can be read from a C(docker-compose.yml) or C(docker-compose.yaml) file or inline using the O(definition) option. - - See the examples for more details. - - Supports check mode. - - This module was called C(docker_service) before Ansible 2.8. The usage did not change. - -extends_documentation_fragment: - - community.docker.docker - - community.docker.docker.docker_py_1_documentation - - community.docker.attributes - - community.docker.attributes.actiongroup_docker - -attributes: - check_mode: - support: full - diff_mode: - support: none - -options: - project_src: - description: - - Path to a directory containing a C(docker-compose.yml) or C(docker-compose.yaml) file. - - Mutually exclusive with O(definition). - - Required when no O(definition) is provided. - type: path - project_name: - description: - - Provide a project name. If not provided, the project name is taken from the basename of O(project_src). - - Required when O(definition) is provided. - type: str - env_file: - description: - - By default environment files are loaded from a C(.env) file located directly under the O(project_src) directory. - - O(env_file) can be used to specify the path of a custom environment file instead. - - The path is relative to the O(project_src) directory. - - Requires C(docker-compose) version 1.25.0 or greater. - - "Note: C(docker-compose) versions C(<=1.28) load the env file from the current working directory of the - C(docker-compose) command rather than O(project_src)." - type: path - version_added: 1.9.0 - files: - description: - - List of Compose file names relative to O(project_src). Overrides C(docker-compose.yml) or C(docker-compose.yaml). - - Files are loaded and merged in the order given. - type: list - elements: path - profiles: - description: - - List of profiles to enable when starting services. - - Equivalent to C(docker-compose --profile). - - Requires C(docker-compose) version 1.28.0 or greater. - type: list - elements: str - version_added: 1.8.0 - state: - description: - - Desired state of the project. - - Specifying V(present) is the same as running C(docker-compose up) resp. C(docker-compose stop) (with O(stopped=true)) resp. C(docker-compose restart) - (with O(restarted=true)). - - Specifying V(absent) is the same as running C(docker-compose down). - type: str - default: present - choices: - - absent - - present - services: - description: - - When O(state) is V(present) run C(docker-compose up) resp. C(docker-compose stop) (with O(stopped=true)) resp. - C(docker-compose restart) (with O(restarted=true)) on a subset of services. - - If empty, which is the default, the operation will be performed on all services defined in the Compose file (or inline O(definition)). - type: list - elements: str - scale: - description: - - When O(state) is V(present) scale services. Provide a dictionary of key/value pairs where the key - is the name of the service and the value is an integer count for the number of containers. - type: dict - dependencies: - description: - - When O(state) is V(present) specify whether or not to include linked services. - type: bool - default: true - definition: - description: - - Compose file describing one or more services, networks and volumes. - - Mutually exclusive with O(project_src) and O(files). - type: dict - hostname_check: - description: - - Whether or not to check the Docker daemon's hostname against the name provided in the client certificate. - type: bool - default: false - recreate: - description: - - By default containers will be recreated when their configuration differs from the service definition. - - Setting to V(never) ignores configuration differences and leaves existing containers unchanged. - - Setting to V(always) forces recreation of all existing containers. - type: str - default: smart - choices: - - always - - never - - smart - build: - description: - - Use with O(state=present) to always build images prior to starting the application. - - Same as running C(docker-compose build) with the pull option. - - Images will only be rebuilt if Docker detects a change in the Dockerfile or build directory contents. - - Use the O(nocache) option to ignore the image cache when performing the build. - - If an existing image is replaced, services using the image will be recreated unless O(recreate=never). - type: bool - default: false - pull: - description: - - Use with O(state=present) to always pull images prior to starting the application. - - Same as running C(docker-compose pull). - - When a new image is pulled, services using the image will be recreated unless O(recreate=never). - type: bool - default: false - nocache: - description: - - Use with the O(build) option to ignore the cache during the image build process. - type: bool - default: false - remove_images: - description: - - Use with O(state=absent) to remove all images or only local images. - type: str - choices: - - 'all' - - 'local' - remove_volumes: - description: - - Use with O(state=absent) to remove data volumes. - type: bool - default: false - stopped: - description: - - Use with O(state=present) to stop all containers defined in the Compose file. - - If O(services) is defined, only the containers listed there will be stopped. - - Requires C(docker-compose) version 1.17.0 or greater for full support. For older versions, the services will - first be started and then stopped when the service is supposed to be created as stopped. - type: bool - default: false - restarted: - description: - - Use with O(state=present) to restart all containers defined in the Compose file. - - If O(services) is defined, only the containers listed there will be restarted. - type: bool - default: false - remove_orphans: - description: - - Remove containers for services not defined in the Compose file. - type: bool - default: false - timeout: - description: - - Timeout in seconds for container shutdown when attached or when containers are already running. - - By default C(docker-compose) will use a V(10) seconds timeout unless C(default_grace_period) is defined for a - particular service in the O(project_src). - type: int - default: null - use_ssh_client: - description: - - Currently ignored for this module, but might suddenly be supported later on. - -requirements: - - "L(Docker SDK for Python,https://docker-py.readthedocs.io/en/stable/) >= 1.8.0, < 7. Docker SDK for Python 7+ is incompatible to docker-compose v1." - - "docker-compose >= 1.7.0, < 2.0.0" - - "Docker API >= 1.25" - - "PyYAML >= 3.11" - -seealso: - - module: community.docker.docker_compose_v2 -''' - -EXAMPLES = ''' -# Examples use the django example at https://docs.docker.com/compose/django. Follow it to create the -# flask directory - -- name: Run using a project directory - hosts: localhost - gather_facts: false - tasks: - - name: Tear down existing services - community.docker.docker_compose: - project_src: flask - state: absent - - - name: Create and start services - community.docker.docker_compose: - project_src: flask - register: output - - - name: Show results - ansible.builtin.debug: - var: output - - - name: Run `docker-compose up` again - community.docker.docker_compose: - project_src: flask - build: false - register: output - - - name: Show results - ansible.builtin.debug: - var: output - - - ansible.builtin.assert: - that: not output.changed - - - name: Stop all services - community.docker.docker_compose: - project_src: flask - build: false - stopped: true - register: output - - - name: Show results - ansible.builtin.debug: - var: output - - - name: Verify that web and db services are not running - ansible.builtin.assert: - that: - - "not output.services.web.flask_web_1.state.running" - - "not output.services.db.flask_db_1.state.running" - - - name: Restart services - community.docker.docker_compose: - project_src: flask - build: false - restarted: true - register: output - - - name: Show results - ansible.builtin.debug: - var: output - - - name: Verify that web and db services are running - ansible.builtin.assert: - that: - - "output.services.web.flask_web_1.state.running" - - "output.services.db.flask_db_1.state.running" - -- name: Scale the web service to 2 - hosts: localhost - gather_facts: false - tasks: - - name: Scale the web service to two instances - community.docker.docker_compose: - project_src: flask - scale: - web: 2 - register: output - - - name: Show results - ansible.builtin.debug: - var: output - -- name: Run with inline Compose file version 2 - # https://docs.docker.com/compose/compose-file/compose-file-v2/ - hosts: localhost - gather_facts: false - tasks: - - name: Remove flask project - community.docker.docker_compose: - project_src: flask - state: absent - - - name: Start flask project with inline definition - community.docker.docker_compose: - project_name: flask - definition: - version: '2' - services: - db: - image: postgres - web: - build: "{{ playbook_dir }}/flask" - command: "python manage.py runserver 0.0.0.0:8000" - volumes: - - "{{ playbook_dir }}/flask:/code" - ports: - - "8000:8000" - depends_on: - - db - register: output - - - name: Show results - ansible.builtin.debug: - var: output - - - name: Verify that the db and web services are running - ansible.builtin.assert: - that: - - "output.services.web.flask_web_1.state.running" - - "output.services.db.flask_db_1.state.running" - -- name: Run with inline Compose file version 1 - # https://docs.docker.com/compose/compose-file/compose-file-v1/ - hosts: localhost - gather_facts: false - tasks: - - name: Remove flask project - community.docker.docker_compose: - project_src: flask - state: absent - - - name: Start flask project with inline definition - community.docker.docker_compose: - project_name: flask - definition: - db: - image: postgres - web: - build: "{{ playbook_dir }}/flask" - command: "python manage.py runserver 0.0.0.0:8000" - volumes: - - "{{ playbook_dir }}/flask:/code" - ports: - - "8000:8000" - links: - - db - register: output - - - name: Show results - ansible.builtin.debug: - var: output - - - name: Verify that web and db services are running - ansible.builtin.assert: - that: - - "output.services.web.flask_web_1.state.running" - - "output.services.db.flask_db_1.state.running" -''' - -RETURN = ''' -services: - description: - - A dictionary mapping the service's name to a dictionary of containers. - returned: success - type: complex - contains: - container_name: - description: Name of the container. Format is C(project_service_#). - returned: success - type: complex - contains: - cmd: - description: One or more commands to be executed in the container. - returned: success - type: list - elements: str - example: ["postgres"] - image: - description: Name of the image from which the container was built. - returned: success - type: str - example: postgres - labels: - description: Meta data assigned to the container. - returned: success - type: dict - example: {...} - networks: - description: Contains a dictionary for each network to which the container is a member. - returned: success - type: list - elements: dict - contains: - IPAddress: - description: The IP address assigned to the container. - returned: success - type: str - example: 172.17.0.2 - IPPrefixLen: - description: Number of bits used by the subnet. - returned: success - type: int - example: 16 - aliases: - description: Aliases assigned to the container by the network. - returned: success - type: list - elements: str - example: ['db'] - globalIPv6: - description: IPv6 address assigned to the container. - returned: success - type: str - example: '' - globalIPv6PrefixLen: - description: IPv6 subnet length. - returned: success - type: int - example: 0 - links: - description: List of container names to which this container is linked. - returned: success - type: list - elements: str - example: null - macAddress: - description: Mac Address assigned to the virtual NIC. - returned: success - type: str - example: "02:42:ac:11:00:02" - state: - description: Information regarding the current disposition of the container. - returned: success - type: dict - contains: - running: - description: Whether or not the container is up with a running process. - returned: success - type: bool - example: true - status: - description: Description of the running state. - returned: success - type: str - example: running - -actions: - description: Provides the actions to be taken on each service as determined by compose. - returned: when in check mode or O(debug=true) - type: complex - contains: - service_name: - description: Name of the service. - returned: always - type: complex - contains: - pulled_image: - description: Provides image details when a new image is pulled for the service. - returned: on image pull - type: complex - contains: - name: - description: name of the image - returned: always - type: str - id: - description: image hash - returned: always - type: str - built_image: - description: Provides image details when a new image is built for the service. - returned: on image build - type: complex - contains: - name: - description: name of the image - returned: always - type: str - id: - description: image hash - returned: always - type: str - - action: - description: A descriptive name of the action to be performed on the service's containers. - returned: always - type: list - elements: str - contains: - id: - description: the container's long ID - returned: always - type: str - name: - description: the container's name - returned: always - type: str - short_id: - description: the container's short ID - returned: always - type: str -''' - -import os -import re -import sys -import tempfile -import traceback -from contextlib import contextmanager - -from ansible_collections.community.docker.plugins.module_utils.version import LooseVersion - -try: - import yaml - HAS_YAML = True - HAS_YAML_EXC = None -except ImportError as dummy: - HAS_YAML = False - HAS_YAML_EXC = traceback.format_exc() - -try: - from docker.errors import DockerException -except ImportError: - # missing Docker SDK for Python handled in ansible.module_utils.docker.common - pass - -try: - from compose import __version__ as compose_version - from compose.cli.command import project_from_options - from compose.service import NoSuchImageError - from compose.cli.main import convergence_strategy_from_opts, build_action_from_opts, image_type_from_opt - from compose.const import LABEL_SERVICE, LABEL_PROJECT, LABEL_ONE_OFF - HAS_COMPOSE = True - HAS_COMPOSE_EXC = None - MINIMUM_COMPOSE_VERSION = '1.7.0' -except ImportError as dummy: - HAS_COMPOSE = False - HAS_COMPOSE_EXC = traceback.format_exc() - -from ansible.module_utils.common.text.converters import to_native - -from ansible_collections.community.docker.plugins.module_utils.common import ( - AnsibleDockerClient, - RequestException, -) - -from ansible_collections.community.docker.plugins.module_utils.util import ( - DockerBaseClass, -) - - -AUTH_PARAM_MAPPING = { - u'docker_host': u'--host', - u'tls': u'--tls', - u'cacert_path': u'--tlscacert', - u'cert_path': u'--tlscert', - u'key_path': u'--tlskey', - u'tls_verify': u'--tlsverify' -} - - -@contextmanager -def stdout_redirector(path_name): - old_stdout = sys.stdout - fd = open(path_name, 'w') - sys.stdout = fd - try: - yield - finally: - sys.stdout = old_stdout - - -@contextmanager -def stderr_redirector(path_name): - old_fh = sys.stderr - fd = open(path_name, 'w') - sys.stderr = fd - try: - yield - finally: - sys.stderr = old_fh - - -def make_redirection_tempfiles(): - dummy, out_redir_name = tempfile.mkstemp(prefix="ansible") - dummy, err_redir_name = tempfile.mkstemp(prefix="ansible") - return (out_redir_name, err_redir_name) - - -def cleanup_redirection_tempfiles(out_name, err_name): - for i in [out_name, err_name]: - os.remove(i) - - -def get_redirected_output(path_name): - output = [] - with open(path_name, 'r') as fd: - for line in fd: - # strip terminal format/color chars - new_line = re.sub(r'\x1b\[.+m', '', line) - output.append(new_line) - os.remove(path_name) - return output - - -def attempt_extract_errors(exc_str, stdout, stderr): - errors = [l.strip() for l in stderr if l.strip().startswith('ERROR:')] - errors.extend([l.strip() for l in stdout if l.strip().startswith('ERROR:')]) - - warnings = [l.strip() for l in stderr if l.strip().startswith('WARNING:')] - warnings.extend([l.strip() for l in stdout if l.strip().startswith('WARNING:')]) - - # assume either the exception body (if present) or the last warning was the 'most' - # fatal. - - if exc_str.strip(): - msg = exc_str.strip() - elif errors: - msg = errors[-1].encode('utf-8') - else: - msg = 'unknown cause' - - return { - 'warnings': [to_native(w) for w in warnings], - 'errors': [to_native(e) for e in errors], - 'msg': msg, - 'module_stderr': ''.join(stderr), - 'module_stdout': ''.join(stdout) - } - - -def get_failure_info(exc, out_name, err_name=None, msg_format='%s'): - if err_name is None: - stderr = [] - else: - stderr = get_redirected_output(err_name) - stdout = get_redirected_output(out_name) - - reason = attempt_extract_errors(str(exc), stdout, stderr) - reason['msg'] = msg_format % reason['msg'] - return reason - - -class ContainerManager(DockerBaseClass): - - def __init__(self, client): - - super(ContainerManager, self).__init__() - - self.client = client - self.project_src = None - self.files = None - self.project_name = None - self.state = None - self.definition = None - self.hostname_check = None - self.timeout = None - self.remove_images = None - self.remove_orphans = None - self.remove_volumes = None - self.stopped = None - self.restarted = None - self.recreate = None - self.build = None - self.dependencies = None - self.services = None - self.scale = None - self.debug = None - self.pull = None - self.nocache = None - - for key, value in client.module.params.items(): - setattr(self, key, value) - - if self.api_version: - os.environ['COMPOSE_API_VERSION'] = self.api_version - - self.check_mode = client.check_mode - - if not self.debug: - self.debug = client.module._debug - - self.options = dict() - self.options.update(self._get_auth_options()) - self.options[u'--skip-hostname-check'] = (not self.hostname_check) - - if self.project_name: - self.options[u'--project-name'] = self.project_name - - if self.env_file: - self.options[u'--env-file'] = self.env_file - - if self.files: - self.options[u'--file'] = self.files - - if self.profiles: - self.options[u'--profile'] = self.profiles - - if not HAS_COMPOSE: - self.client.fail("Unable to load docker-compose. Try `pip install docker-compose`. Error: %s" % - to_native(HAS_COMPOSE_EXC)) - - if LooseVersion(compose_version) < LooseVersion(MINIMUM_COMPOSE_VERSION): - self.client.fail("Found docker-compose version %s. Minimum required version is %s. " - "Upgrade docker-compose to a min version of %s." % - (compose_version, MINIMUM_COMPOSE_VERSION, MINIMUM_COMPOSE_VERSION)) - - if self.restarted and self.stopped: - self.client.fail("Cannot use restarted and stopped at the same time.") - - self.log("options: ") - self.log(self.options, pretty_print=True) - - if self.definition: - if not HAS_YAML: - self.client.fail("Unable to load yaml. Try `pip install PyYAML`. Error: %s" % to_native(HAS_YAML_EXC)) - - if not self.project_name: - self.client.fail("Parameter error - project_name required when providing definition.") - - self.project_src = tempfile.mkdtemp(prefix="ansible") - compose_file = os.path.join(self.project_src, "docker-compose.yml") - try: - self.log('writing: ') - self.log(yaml.dump(self.definition, default_flow_style=False)) - with open(compose_file, 'w') as f: - f.write(yaml.dump(self.definition, default_flow_style=False)) - except Exception as exc: - self.client.fail("Error writing to %s - %s" % (compose_file, to_native(exc))) - else: - if not self.project_src: - self.client.fail("Parameter error - project_src required.") - - try: - self.log("project_src: %s" % self.project_src) - self.project = project_from_options(self.project_src, self.options) - except Exception as exc: - self.client.fail("Configuration error - %s" % to_native(exc)) - - def exec_module(self): - result = dict() - - if self.state == 'present': - result = self.cmd_up() - elif self.state == 'absent': - result = self.cmd_down() - - if self.definition: - compose_file = os.path.join(self.project_src, "docker-compose.yml") - self.log("removing %s" % compose_file) - os.remove(compose_file) - self.log("removing %s" % self.project_src) - os.rmdir(self.project_src) - - if not self.check_mode and not self.debug and result.get('actions'): - result.pop('actions') - - return result - - def _get_auth_options(self): - options = dict() - for key, value in self.client.auth_params.items(): - if value is not None: - option = AUTH_PARAM_MAPPING.get(key) - if option: - options[option] = value - return options - - def cmd_up(self): - - start_deps = self.dependencies - service_names = self.services - detached = True - result = dict(changed=False, actions=[], services=dict()) - - up_options = { - u'--no-recreate': False, - u'--build': False, - u'--no-build': False, - u'--no-deps': False, - u'--force-recreate': False, - } - - if self.recreate == 'never': - up_options[u'--no-recreate'] = True - elif self.recreate == 'always': - up_options[u'--force-recreate'] = True - - if self.remove_orphans: - up_options[u'--remove-orphans'] = True - - converge = convergence_strategy_from_opts(up_options) - self.log("convergence strategy: %s" % converge) - - if self.pull: - pull_output = self.cmd_pull() - result['changed'] |= pull_output['changed'] - result['actions'] += pull_output['actions'] - - if self.build: - build_output = self.cmd_build() - result['changed'] |= build_output['changed'] - result['actions'] += build_output['actions'] - - if self.remove_orphans: - containers = self.client.containers( - filters={ - 'label': [ - '{0}={1}'.format(LABEL_PROJECT, self.project.name), - '{0}={1}'.format(LABEL_ONE_OFF, "False") - ], - } - ) - - orphans = [] - for container in containers: - service_name = container.get('Labels', {}).get(LABEL_SERVICE) - if service_name not in self.project.service_names: - orphans.append(service_name) - - if orphans: - result['changed'] = True - - for service in self.project.services: - if not service_names or service.name in service_names: - plan = service.convergence_plan(strategy=converge) - if plan.action == 'start' and self.stopped: - # In case the only action is starting, and the user requested - # that the service should be stopped, ignore this service. - continue - if not self._service_profile_enabled(service): - continue - if plan.action != 'noop': - result['changed'] = True - result_action = dict(service=service.name) - result_action[plan.action] = [] - for container in plan.containers: - result_action[plan.action].append(dict( - id=container.id, - name=container.name, - short_id=container.short_id, - )) - result['actions'].append(result_action) - - if not self.check_mode and result['changed']: - out_redir_name, err_redir_name = make_redirection_tempfiles() - try: - with stdout_redirector(out_redir_name): - with stderr_redirector(err_redir_name): - do_build = build_action_from_opts(up_options) - self.log('Setting do_build to %s' % do_build) - up_kwargs = { - 'service_names': service_names, - 'start_deps': start_deps, - 'strategy': converge, - 'do_build': do_build, - 'detached': detached, - 'remove_orphans': self.remove_orphans, - 'timeout': self.timeout, - } - - if LooseVersion(compose_version) >= LooseVersion('1.17.0'): - up_kwargs['start'] = not self.stopped - elif self.stopped: - self.client.module.warn( - "The 'stopped' option requires docker-compose version >= 1.17.0. " + - "This task was run with docker-compose version %s." % compose_version - ) - - self.project.up(**up_kwargs) - except Exception as exc: - fail_reason = get_failure_info(exc, out_redir_name, err_redir_name, - msg_format="Error starting project %s") - self.client.fail(**fail_reason) - else: - cleanup_redirection_tempfiles(out_redir_name, err_redir_name) - - if self.stopped: - stop_output = self.cmd_stop(service_names) - result['changed'] |= stop_output['changed'] - result['actions'] += stop_output['actions'] - - if self.restarted: - restart_output = self.cmd_restart(service_names) - result['changed'] |= restart_output['changed'] - result['actions'] += restart_output['actions'] - - if self.scale: - scale_output = self.cmd_scale() - result['changed'] |= scale_output['changed'] - result['actions'] += scale_output['actions'] - - for service in self.project.services: - service_facts = dict() - result['services'][service.name] = service_facts - for container in service.containers(stopped=True): - inspection = container.inspect() - # pare down the inspection data to the most useful bits - facts = dict( - cmd=[], - labels=dict(), - image=None, - state=dict( - running=None, - status=None - ), - networks=dict() - ) - if inspection['Config'].get('Cmd', None) is not None: - facts['cmd'] = inspection['Config']['Cmd'] - if inspection['Config'].get('Labels', None) is not None: - facts['labels'] = inspection['Config']['Labels'] - if inspection['Config'].get('Image', None) is not None: - facts['image'] = inspection['Config']['Image'] - if inspection['State'].get('Running', None) is not None: - facts['state']['running'] = inspection['State']['Running'] - if inspection['State'].get('Status', None) is not None: - facts['state']['status'] = inspection['State']['Status'] - - if inspection.get('NetworkSettings') and inspection['NetworkSettings'].get('Networks'): - networks = inspection['NetworkSettings']['Networks'] - for key in networks: - facts['networks'][key] = dict( - aliases=[], - globalIPv6=None, - globalIPv6PrefixLen=0, - IPAddress=None, - IPPrefixLen=0, - links=None, - macAddress=None, - ) - if networks[key].get('Aliases', None) is not None: - facts['networks'][key]['aliases'] = networks[key]['Aliases'] - if networks[key].get('GlobalIPv6Address', None) is not None: - facts['networks'][key]['globalIPv6'] = networks[key]['GlobalIPv6Address'] - if networks[key].get('GlobalIPv6PrefixLen', None) is not None: - facts['networks'][key]['globalIPv6PrefixLen'] = networks[key]['GlobalIPv6PrefixLen'] - if networks[key].get('IPAddress', None) is not None: - facts['networks'][key]['IPAddress'] = networks[key]['IPAddress'] - if networks[key].get('IPPrefixLen', None) is not None: - facts['networks'][key]['IPPrefixLen'] = networks[key]['IPPrefixLen'] - if networks[key].get('Links', None) is not None: - facts['networks'][key]['links'] = networks[key]['Links'] - if networks[key].get('MacAddress', None) is not None: - facts['networks'][key]['macAddress'] = networks[key]['MacAddress'] - - service_facts[container.name] = facts - - return result - - def cmd_pull(self): - result = dict( - changed=False, - actions=[], - ) - - if not self.check_mode: - for service in self.project.get_services(self.services, include_deps=False): - if 'image' not in service.options: - continue - - self.log('Pulling image for service %s' % service.name) - # store the existing image ID - old_image_id = '' - try: - image = service.image() - if image and image.get('Id'): - old_image_id = image['Id'] - except NoSuchImageError: - pass - except Exception as exc: - self.client.fail("Error: service image lookup failed - %s" % to_native(exc)) - - out_redir_name, err_redir_name = make_redirection_tempfiles() - # pull the image - try: - with stdout_redirector(out_redir_name): - with stderr_redirector(err_redir_name): - service.pull(ignore_pull_failures=False) - except Exception as exc: - fail_reason = get_failure_info(exc, out_redir_name, err_redir_name, - msg_format="Error: pull failed with %s") - self.client.fail(**fail_reason) - else: - cleanup_redirection_tempfiles(out_redir_name, err_redir_name) - - # store the new image ID - new_image_id = '' - try: - image = service.image() - if image and image.get('Id'): - new_image_id = image['Id'] - except NoSuchImageError as exc: - self.client.fail("Error: service image lookup failed after pull - %s" % to_native(exc)) - - if new_image_id != old_image_id: - # if a new image was pulled - result['changed'] = True - result['actions'].append(dict( - service=service.name, - pulled_image=dict( - name=service.image_name, - id=new_image_id - ) - )) - return result - - def cmd_build(self): - result = dict( - changed=False, - actions=[] - ) - if not self.check_mode: - for service in self.project.get_services(self.services, include_deps=False): - if service.can_be_built(): - self.log('Building image for service %s' % service.name) - # store the existing image ID - old_image_id = '' - try: - image = service.image() - if image and image.get('Id'): - old_image_id = image['Id'] - except NoSuchImageError: - pass - except Exception as exc: - self.client.fail("Error: service image lookup failed - %s" % to_native(exc)) - - out_redir_name, err_redir_name = make_redirection_tempfiles() - # build the image - try: - with stdout_redirector(out_redir_name): - with stderr_redirector(err_redir_name): - new_image_id = service.build(pull=self.pull, no_cache=self.nocache) - except Exception as exc: - fail_reason = get_failure_info(exc, out_redir_name, err_redir_name, - msg_format="Error: build failed with %s") - self.client.fail(**fail_reason) - else: - cleanup_redirection_tempfiles(out_redir_name, err_redir_name) - - if new_image_id not in old_image_id: - # if a new image was built - result['changed'] = True - result['actions'].append(dict( - service=service.name, - built_image=dict( - name=service.image_name, - id=new_image_id - ) - )) - return result - - def _service_profile_enabled(self, service): - """Returns `True` if the service has no profiles defined or has a profile which is among - the profiles passed to the `docker compose up` command. Otherwise returns `False`. - """ - if LooseVersion(compose_version) < LooseVersion('1.28.0'): - return True - return service.enabled_for_profiles(self.profiles or []) - - def cmd_down(self): - result = dict( - changed=False, - actions=[] - ) - for service in self.project.services: - containers = service.containers(stopped=True) - if len(containers): - result['changed'] = True - result['actions'].append(dict( - service=service.name, - deleted=[container.name for container in containers] - )) - if not self.check_mode and result['changed']: - image_type = image_type_from_opt('--rmi', self.remove_images) - out_redir_name, err_redir_name = make_redirection_tempfiles() - try: - with stdout_redirector(out_redir_name): - with stderr_redirector(err_redir_name): - self.project.down(image_type, self.remove_volumes, self.remove_orphans) - except Exception as exc: - fail_reason = get_failure_info(exc, out_redir_name, err_redir_name, - msg_format="Error stopping project - %s") - self.client.fail(**fail_reason) - else: - cleanup_redirection_tempfiles(out_redir_name, err_redir_name) - return result - - def cmd_stop(self, service_names): - result = dict( - changed=False, - actions=[] - ) - for service in self.project.services: - if not service_names or service.name in service_names: - service_res = dict( - service=service.name, - stop=[] - ) - for container in service.containers(stopped=False): - result['changed'] = True - service_res['stop'].append(dict( - id=container.id, - name=container.name, - short_id=container.short_id - )) - result['actions'].append(service_res) - if not self.check_mode and result['changed']: - out_redir_name, err_redir_name = make_redirection_tempfiles() - try: - with stdout_redirector(out_redir_name): - with stderr_redirector(err_redir_name): - self.project.stop(service_names=service_names, timeout=self.timeout) - except Exception as exc: - fail_reason = get_failure_info(exc, out_redir_name, err_redir_name, - msg_format="Error stopping project %s") - self.client.fail(**fail_reason) - else: - cleanup_redirection_tempfiles(out_redir_name, err_redir_name) - return result - - def cmd_restart(self, service_names): - result = dict( - changed=False, - actions=[] - ) - - for service in self.project.services: - if not service_names or service.name in service_names: - service_res = dict( - service=service.name, - restart=[] - ) - for container in service.containers(stopped=True): - result['changed'] = True - service_res['restart'].append(dict( - id=container.id, - name=container.name, - short_id=container.short_id - )) - result['actions'].append(service_res) - - if not self.check_mode and result['changed']: - out_redir_name, err_redir_name = make_redirection_tempfiles() - try: - with stdout_redirector(out_redir_name): - with stderr_redirector(err_redir_name): - self.project.restart(service_names=service_names, timeout=self.timeout) - except Exception as exc: - fail_reason = get_failure_info(exc, out_redir_name, err_redir_name, - msg_format="Error restarting project %s") - self.client.fail(**fail_reason) - else: - cleanup_redirection_tempfiles(out_redir_name, err_redir_name) - return result - - def cmd_scale(self): - result = dict( - changed=False, - actions=[] - ) - for service in self.project.services: - if service.name in self.scale: - service_res = dict( - service=service.name, - scale=0 - ) - containers = service.containers(stopped=True) - scale = self.parse_scale(service.name) - if len(containers) != scale: - result['changed'] = True - service_res['scale'] = scale - len(containers) - if not self.check_mode: - out_redir_name, err_redir_name = make_redirection_tempfiles() - try: - with stdout_redirector(out_redir_name): - with stderr_redirector(err_redir_name): - service.scale(scale) - except Exception as exc: - fail_reason = get_failure_info(exc, out_redir_name, err_redir_name, - msg_format="Error scaling {0} - %s".format(service.name)) - self.client.fail(**fail_reason) - else: - cleanup_redirection_tempfiles(out_redir_name, err_redir_name) - result['actions'].append(service_res) - return result - - def parse_scale(self, service_name): - try: - return int(self.scale[service_name]) - except ValueError: - self.client.fail("Error scaling %s - expected int, got %s", - service_name, to_native(type(self.scale[service_name]))) - - -def main(): - argument_spec = dict( - project_src=dict(type='path'), - project_name=dict(type='str',), - env_file=dict(type='path'), - files=dict(type='list', elements='path'), - profiles=dict(type='list', elements='str'), - state=dict(type='str', default='present', choices=['absent', 'present']), - definition=dict(type='dict'), - hostname_check=dict(type='bool', default=False), - recreate=dict(type='str', default='smart', choices=['always', 'never', 'smart']), - build=dict(type='bool', default=False), - remove_images=dict(type='str', choices=['all', 'local']), - remove_volumes=dict(type='bool', default=False), - remove_orphans=dict(type='bool', default=False), - stopped=dict(type='bool', default=False), - restarted=dict(type='bool', default=False), - scale=dict(type='dict'), - services=dict(type='list', elements='str'), - dependencies=dict(type='bool', default=True), - pull=dict(type='bool', default=False), - nocache=dict(type='bool', default=False), - debug=dict(type='bool', default=False), - timeout=dict(type='int') - ) - - mutually_exclusive = [ - ('definition', 'project_src'), - ('definition', 'files') - ] - - client = AnsibleDockerClient( - argument_spec=argument_spec, - mutually_exclusive=mutually_exclusive, - supports_check_mode=True, - ) - - try: - result = ContainerManager(client).exec_module() - client.module.exit_json(**result) - except DockerException as e: - client.fail('An unexpected docker error occurred: {0}'.format(to_native(e)), exception=traceback.format_exc()) - except RequestException as e: - client.fail( - 'An unexpected requests error occurred when Docker SDK for Python tried to talk to the docker daemon: {0}'.format(to_native(e)), - exception=traceback.format_exc()) - - -if __name__ == '__main__': - main() diff --git a/plugins/modules/docker_compose_v2.py b/plugins/modules/docker_compose_v2.py index 5ed873bb..359a16e9 100644 --- a/plugins/modules/docker_compose_v2.py +++ b/plugins/modules/docker_compose_v2.py @@ -143,7 +143,6 @@ author: - Felix Fontein (@felixfontein) seealso: - - module: community.docker.docker_compose - module: community.docker.docker_compose_v2_pull ''' diff --git a/plugins/modules/docker_container.py b/plugins/modules/docker_container.py index 832a2cf4..49422775 100644 --- a/plugins/modules/docker_container.py +++ b/plugins/modules/docker_container.py @@ -429,18 +429,6 @@ options: description: - The container's hostname. type: str - ignore_image: - description: - - When O(state) is V(present) or V(started), the module compares the configuration of an existing - container to requested configuration. The evaluation includes the image version. If the image - version in the registry does not match the container, the container will be recreated. You can - stop this behavior by setting O(ignore_image) to V(true). - - "B(Warning:) This option is ignored if C(image: ignore) or C(*: ignore) is specified in the - O(comparisons) option." - - "This option is deprecated since community.docker 3.2.0 and will be removed in community.docker 4.0.0. - Use C(image: ignore) in O(comparisons) instead of O(ignore_image=true)." - type: bool - default: false image: description: - Repository path and tag used to create the container. If an image is not found or pull is true, the image @@ -485,12 +473,12 @@ options: - If set to V(recreate) the container will be recreated. - If set to V(ignore) (currently the default) the container will not be recreated because of this. It might still get recreated for other reasons. This has been the default behavior of the module for a long time, but might not be what users expect. - - Since community.docker 3.5.0, the default V(ignore) has been deprecated. If not specified, a deprecation warning - will be emitted if this setting would make a difference. The default will change to V(recreate) in community.docker 4.0.0. + - The default changed from V(ignore) to V(recreate) in community.docker 4.0.0. type: str choices: - recreate - ignore + default: recreate version_added: 3.2.0 init: description: @@ -849,15 +837,6 @@ options: - image_not_present - always version_added: 3.8.0 - purge_networks: - description: - - Remove the container from ALL networks not included in O(networks) parameter. - - Any default networks such as C(bridge), if not found in O(networks), will be removed as well. - - "This option is deprecated since community.docker 3.2.0 and will be removed in community.docker 4.0.0. - Use C(networks: strict) in O(comparisons) instead of O(purge_networks=true) and make sure that - O(networks) is specified. If you want to remove all networks, specify O(networks) as C([])." - type: bool - default: false read_only: description: - Mount the container's root file system as read-only. diff --git a/tests/integration/targets/docker_compose/aliases b/tests/integration/targets/docker_compose/aliases deleted file mode 100644 index d8f457d5..00000000 --- a/tests/integration/targets/docker_compose/aliases +++ /dev/null @@ -1,6 +0,0 @@ -# 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 - -azp/6 -destructive diff --git a/tests/integration/targets/docker_compose/meta/main.yml b/tests/integration/targets/docker_compose/meta/main.yml deleted file mode 100644 index 6b423221..00000000 --- a/tests/integration/targets/docker_compose/meta/main.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -# 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 - -dependencies: - - setup_docker_compose_v1 - - setup_remote_tmp_dir diff --git a/tests/integration/targets/docker_compose/tasks/main.yml b/tests/integration/targets/docker_compose/tasks/main.yml deleted file mode 100644 index 34d51887..00000000 --- a/tests/integration/targets/docker_compose/tasks/main.yml +++ /dev/null @@ -1,53 +0,0 @@ ---- -# 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 - -#################################################################### -# WARNING: These are designed specifically for Ansible tests # -# and should not be used as examples of how to write Ansible roles # -#################################################################### - -# Create random name prefix (for containers, networks, ...) -- name: Create random container name prefix - set_fact: - cname_prefix: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}" - cnames: [] - dnetworks: [] - -- debug: - msg: "Using container name prefix {{ cname_prefix }}" - -# Run the tests -- module_defaults: - community.docker.docker_compose: - api_version: '{{ omit if docker_api_version is version("1.45", "<") else "1.44" }}' - - block: - - include_tasks: run-test.yml - with_fileglob: - - "tests/*.yml" - loop_control: - loop_var: test_name - - always: - - name: "Make sure all containers are removed" - docker_container: - name: "{{ item }}" - state: absent - force_kill: true - with_items: "{{ cnames }}" - diff: false - - name: "Make sure all networks are removed" - docker_network: - name: "{{ item }}" - state: absent - force: true - with_items: "{{ dnetworks }}" - when: docker_py_version is version('1.10.0', '>=') - diff: false - - when: has_docker_compose and docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.25', '>=') - -- fail: msg="Too old docker / docker-py version to run all docker_container tests!" - when: has_docker_compose and not(docker_py_version is version('3.5.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) diff --git a/tests/integration/targets/docker_compose/tasks/run-test.yml b/tests/integration/targets/docker_compose/tasks/run-test.yml deleted file mode 100644 index 72a58962..00000000 --- a/tests/integration/targets/docker_compose/tasks/run-test.yml +++ /dev/null @@ -1,7 +0,0 @@ ---- -# 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 - -- name: "Loading tasks from {{ test_name }}" - include_tasks: "{{ test_name }}" diff --git a/tests/integration/targets/docker_compose/tasks/tests/options.yml b/tests/integration/targets/docker_compose/tasks/tests/options.yml deleted file mode 100644 index f2440317..00000000 --- a/tests/integration/targets/docker_compose/tasks/tests/options.yml +++ /dev/null @@ -1,243 +0,0 @@ ---- -# 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 - -- name: Registering container name - set_fact: - pname: "{{ cname_prefix }}" - cname_1: "{{ cname_prefix ~ '1' }}" - cname_2: "{{ cname_prefix ~ '2' }}" - -#################################################################### -## Profiles ######################################################## -#################################################################### - -- block: - - name: Define service - set_fact: - test_service: | - version: '3' - services: - {{ cname_1 }}: - image: "{{ docker_test_image_alpine }}" - command: '/bin/sh -c "sleep 10m"' - profiles: - - profile_1 - - profile_all - stop_grace_period: 1s - {{ cname_2 }}: - image: "{{ docker_test_image_alpine }}" - command: '/bin/sh -c "sleep 10m"' - profiles: - - profile_2 - - profile_all - stop_grace_period: 1s - test_cases: - - test_name: no services enabled - - test_name: enable 1 - profiles_value: - - profile_1 - - test_name: stop all services - profiles_value: - - profile_1 - stopped_value: true - - test_name: enable 2 - profiles_value: - - profile_2 - - test_name: stop all services - profiles_value: - - profile_2 - stopped_value: true - - test_name: enable both - profiles_value: - - profile_1 - - profile_2 - - test_name: stop all services - profiles_value: - - profile_1 - - profile_2 - stopped_value: true - - test_name: enable all - profiles_value: - - profile_all - - - name: Profiles ({{ test_case.test_name }}) - docker_compose: - project_name: "{{ pname }}" - definition: "{{ test_service | from_yaml }}" - profiles: "{{ test_case.profiles_value | default(omit) }}" - stopped: "{{ test_case.stopped_value | default(omit) }}" - state: present - register: profiles_outputs - loop: "{{ test_cases }}" - loop_control: - loop_var: test_case - - - name: Cleanup - docker_compose: - project_name: "{{ pname }}" - state: absent - definition: "{{ test_service | from_yaml }}" - - - assert: - that: - - profiles_outputs.results[0] is not changed - - profiles_outputs.results[1].services[cname_1][cname_1_name].state.running - - profiles_outputs.results[1].services[cname_2] == {} - - not profiles_outputs.results[2].services[cname_1][cname_1_name].state.running - - profiles_outputs.results[2].services[cname_2] == {} - - not profiles_outputs.results[3].services[cname_1][cname_1_name].state.running - - profiles_outputs.results[3].services[cname_2][cname_2_name].state.running - - not profiles_outputs.results[4].services[cname_1][cname_1_name].state.running - - not profiles_outputs.results[4].services[cname_2][cname_2_name].state.running - - profiles_outputs.results[5].services[cname_1][cname_1_name].state.running - - profiles_outputs.results[5].services[cname_2][cname_2_name].state.running - - not profiles_outputs.results[6].services[cname_1][cname_1_name].state.running - - not profiles_outputs.results[6].services[cname_2][cname_2_name].state.running - - profiles_outputs.results[7].services[cname_1][cname_1_name].state.running - - profiles_outputs.results[7].services[cname_2][cname_2_name].state.running - vars: - cname_1_name: "{{ pname + '_' + cname_1 + '_1' }}" - cname_2_name: "{{ pname + '_' + cname_2 + '_1' }}" - when: docker_compose_version is version('1.28.0', '>=') - -#################################################################### -## Env_file ######################################################## -#################################################################### - -- block: - - name: Define service and files - set_fact: - compose_file: "{{ remote_tmp_dir }}/docker-compose.yml" - env_file: "{{ remote_tmp_dir }}/.env" - env_sleep_cmd: sleep 10m - new_env_file: "{{ remote_tmp_dir }}/new.env" - new_env_sleep_cmd: sleep 20m - test_service: | - version: '3' - services: - {{ cname_1 }}: - image: "{{ docker_test_image_alpine }}" - command: '/bin/sh -c "${SLEEP_CMD}"' - stop_grace_period: 1s - - - name: Define testcases - set_fact: - test_cases: - - test_name: Without env_file option - - test_name: With env_file option - env_file: "{{ new_env_file }}" - - - name: Generate compose file - ansible.builtin.copy: - content: "{{ test_service }}" - dest: "{{ compose_file }}" - - - name: Generate .env file - ansible.builtin.copy: - content: | - SLEEP_CMD="{{ env_sleep_cmd }}" - dest: "{{ env_file }}" - - - name: Generate new.env file - ansible.builtin.copy: - content: | - SLEEP_CMD="{{ new_env_sleep_cmd }}" - dest: "{{ new_env_file }}" - - - name: Env_file - docker_compose: - project_name: "{{ pname }}" - project_src: "{{ remote_tmp_dir }}" - env_file: "{{ test_case.env_file | default(omit) }}" - register: env_file_outputs - loop: "{{ test_cases }}" - loop_control: - loop_var: test_case - - - name: Cleanup - docker_compose: - project_name: "{{ pname }}" - state: absent - definition: "{{ test_service | from_yaml }}" - - - assert: - that: - - "env_sleep_cmd is in (env_file_outputs.results[0].services[cname_1][cname_1_name].cmd | join(' '))" - - "new_env_sleep_cmd is in (env_file_outputs.results[1].services[cname_1][cname_1_name].cmd | join(' '))" - vars: - cname_1_name: "{{ pname + '_' + cname_1 + '_1' }}" - cname_2_name: "{{ pname + '_' + cname_2 + '_1' }}" - - - name: Remove files - ansible.builtin.file: - path: "{{ file_path }}" - state: absent - loop_control: - loop_var: file_path - loop: - - "{{ compose_file }}" - - "{{ env_file }}" - - "{{ new_env_file }}" - when: docker_compose_version is version('1.25.0', '>=') - -#################################################################### -## Project_src ##################################################### -#################################################################### - -- name: Define service and files - set_fact: - compose_file: "{{ remote_tmp_dir }}/docker-compose.yml" - env_sleep_cmd: sleep 10m - new_env_sleep_cmd: sleep 20m - test_service: | - version: '3' - services: - {{ cname_1 }}: - image: "{{ docker_test_image_alpine }}" - command: '/bin/sh -c 10m' - stop_grace_period: 1s - -- name: Generate compose file - ansible.builtin.copy: - content: "{{ test_service }}" - dest: "{{ compose_file }}" - -- name: Start with project_src - docker_compose: - project_src: "{{ remote_tmp_dir }}" - register: project_src_1 - -- name: Start with project_src (idempotent) - docker_compose: - project_src: "{{ remote_tmp_dir }}" - register: project_src_2 - -- name: Stop with project_src - docker_compose: - project_src: "{{ remote_tmp_dir }}" - state: absent - register: project_src_3 - -- name: Stop with project_src (idempotent) - docker_compose: - project_src: "{{ remote_tmp_dir }}" - state: absent - register: project_src_4 - -- name: Remove files - ansible.builtin.file: - path: "{{ file_path }}" - state: absent - loop_control: - loop_var: file_path - loop: - - "{{ compose_file }}" - -- assert: - that: - - project_src_1 is changed - # - project_src_2 is not changed -- for some reason, this currently fails! - - project_src_3 is changed - - project_src_4 is not changed diff --git a/tests/integration/targets/docker_compose/tasks/tests/start-stop.yml b/tests/integration/targets/docker_compose/tasks/tests/start-stop.yml deleted file mode 100644 index 89945071..00000000 --- a/tests/integration/targets/docker_compose/tasks/tests/start-stop.yml +++ /dev/null @@ -1,233 +0,0 @@ ---- -# 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 - -- name: Registering container name - set_fact: - pname: "{{ cname_prefix }}" - cname: "{{ cname_prefix ~ '-hi' }}" -- name: Registering container name - set_fact: - cnames: "{{ cnames + [pname ~ '-' ~ cname] }}" - dnetworks: "{{ dnetworks + [pname ~ '_default'] }}" - -- name: Define service - set_fact: - test_service: | - version: '3' - services: - {{ cname }}: - image: "{{ docker_test_image_alpine }}" - command: '/bin/sh -c "sleep 10m"' - stop_grace_period: 1s - test_service_mod: | - version: '3' - services: - {{ cname }}: - image: "{{ docker_test_image_alpine }}" - command: '/bin/sh -c "sleep 15m"' - stop_grace_period: 1s - -#################################################################### -## Present ######################################################### -#################################################################### - -- name: Present (check) - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - check_mode: true - register: present_1 - -- name: Present - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - register: present_2 - -- name: Present (idempotent) - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - register: present_3 - -- name: Present (idempotent check) - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - check_mode: true - register: present_4 - -- name: Present (changed check) - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service_mod | from_yaml }}" - check_mode: true - register: present_5 - -- name: Present (changed) - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service_mod | from_yaml }}" - register: present_6 - -- assert: - that: - - present_1 is changed - - present_2 is changed - - present_3 is not changed - - present_4 is not changed - - present_5 is changed - - present_6 is changed - -#################################################################### -## Absent ########################################################## -#################################################################### - -- name: Absent (check) - docker_compose: - project_name: "{{ pname }}" - state: absent - definition: "{{ test_service_mod | from_yaml }}" - check_mode: true - register: absent_1 - -- name: Absent - docker_compose: - project_name: "{{ pname }}" - state: absent - definition: "{{ test_service_mod | from_yaml }}" - register: absent_2 - -- name: Absent (idempotent) - docker_compose: - project_name: "{{ pname }}" - state: absent - definition: "{{ test_service_mod | from_yaml }}" - register: absent_3 - -- name: Absent (idempotent check) - docker_compose: - project_name: "{{ pname }}" - state: absent - definition: "{{ test_service_mod | from_yaml }}" - check_mode: true - register: absent_4 - -- assert: - that: - - absent_1 is changed - - absent_2 is changed - - absent_3 is not changed - - absent_4 is not changed - -#################################################################### -## Stopping and starting ########################################### -#################################################################### - -- name: Present stopped (check) - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - stopped: true - check_mode: true - register: present_1 - -- name: Present stopped - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - stopped: true - register: present_2 - -- name: Present stopped (idempotent) - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - stopped: true - register: present_3 - -- name: Present stopped (idempotent check) - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - stopped: true - check_mode: true - register: present_4 - -- name: Started (check) - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - check_mode: true - register: started_1 - -- name: Started - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - register: started_2 - -- name: Started (idempotent) - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - register: started_3 - -- name: Started (idempotent check) - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - check_mode: true - register: started_4 - -- name: Stopped (check) - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - stopped: true - check_mode: true - register: stopped_1 - -- name: Stopped - docker_compose: - project_name: "{{ pname }}" - state: present - definition: "{{ test_service | from_yaml }}" - stopped: true - register: stopped_2 - -- name: Cleanup - docker_compose: - project_name: "{{ pname }}" - state: absent - definition: "{{ test_service | from_yaml }}" - -- assert: - that: - - present_1 is changed - - present_2 is changed - - present_3 is not changed - - present_4 is not changed - - started_1 is changed - - started_2 is changed - - started_3 is not changed - - started_4 is not changed - - stopped_1 is changed - - stopped_2 is 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 4dfdb02a..e905defc 100644 --- a/tests/integration/targets/docker_container/tasks/tests/image-ids.yml +++ b/tests/integration/targets/docker_container/tasks/tests/image-ids.yml @@ -77,6 +77,7 @@ image: "{{ docker_test_image_alpine }}" name: "{{ cname }}" state: present + image_name_mismatch: ignore register: create_5 check_mode: true @@ -85,6 +86,7 @@ image: "{{ docker_test_image_alpine }}" name: "{{ cname }}" state: present + image_name_mismatch: ignore register: create_6 - name: Cleanup diff --git a/tests/integration/targets/docker_container/tasks/tests/network.yml b/tests/integration/targets/docker_container/tasks/tests/network.yml index d6a6f0bc..42ebef65 100644 --- a/tests/integration/targets/docker_container/tasks/tests/network.yml +++ b/tests/integration/targets/docker_container/tasks/tests/network.yml @@ -385,18 +385,16 @@ networks_cli_compatible: true register: networks_7 -- name: networks_cli_compatible=yes, networks not specified, purge_networks +- name: networks_cli_compatible=yes, networks empty, purge_networks docker_container: image: "{{ docker_test_image_alpine }}" command: '/bin/sh -c "sleep 10m"' name: "{{ cname }}" state: started networks_cli_compatible: true - purge_networks: true - # To replace `purge_networks=true`, we have to specify `networks: []`: - # comparisons: - # networks: strict - # networks: [] + comparisons: + networks: strict + networks: [] force_kill: true register: networks_8 diff --git a/tests/integration/targets/docker_container/tasks/tests/options.yml b/tests/integration/targets/docker_container/tasks/tests/options.yml index a7bc0f37..d49b1a6f 100644 --- a/tests/integration/targets/docker_container/tasks/tests/options.yml +++ b/tests/integration/targets/docker_container/tasks/tests/options.yml @@ -2290,7 +2290,7 @@ - interactive_3 is changed #################################################################### -## image / image_comparison / ignore_image ######################### +## image / image_comparison ######################################## #################################################################### - name: Pull images to make sure ignore_image test succeeds @@ -2570,7 +2570,8 @@ - name: ignore_image docker_container: image: "{{ docker_test_image_hello_world }}" - ignore_image: true + comparisons: + image: ignore name: "{{ cname }}" state: started register: ignore_image @@ -2579,8 +2580,9 @@ - name: ignore_image (labels and env differ in image, image_comparison=current-image) docker_container: image: "{{ docker_test_image_registry_nginx }}" - ignore_image: true image_comparison: current-image + comparisons: + image: ignore name: "{{ cname }}" state: started register: ignore_image_2 @@ -2589,8 +2591,9 @@ - name: ignore_image (labels and env differ in image, image_comparison=desired-image) docker_container: image: "{{ docker_test_image_registry_nginx }}" - ignore_image: true image_comparison: desired-image + comparisons: + image: ignore name: "{{ cname }}" state: started force_kill: true diff --git a/tests/integration/targets/setup_docker_compose_v1/defaults/main.yml b/tests/integration/targets/setup_docker_compose_v1/defaults/main.yml deleted file mode 100644 index 0ebf5269..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/defaults/main.yml +++ /dev/null @@ -1,15 +0,0 @@ ---- -# 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 - -skip_docker_compose: false - -docker_pip_extra_packages: [] -docker_pip_package: docker -docker_pip_package_limit: '<7.0.0' - -docker_compose_packages: - - docker-compose -docker_compose_pip_packages: - - docker-compose diff --git a/tests/integration/targets/setup_docker_compose_v1/meta/main.yml b/tests/integration/targets/setup_docker_compose_v1/meta/main.yml deleted file mode 100644 index b6e985d7..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/meta/main.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -# 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 - -dependencies: - - setup_docker - - setup_remote_constraints diff --git a/tests/integration/targets/setup_docker_compose_v1/tasks/Alpine.yml b/tests/integration/targets/setup_docker_compose_v1/tasks/Alpine.yml deleted file mode 100644 index 85042fdf..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/tasks/Alpine.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -# 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 - -- name: Install docker-compose as system package - apk: - name: "{{ docker_compose_packages }}" - state: present diff --git a/tests/integration/targets/setup_docker_compose_v1/tasks/Archlinux.yml b/tests/integration/targets/setup_docker_compose_v1/tasks/Archlinux.yml deleted file mode 100644 index 2e62ff05..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/tasks/Archlinux.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -# 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 - -- name: Install docker-compose as system package - pacman: - name: "{{ docker_compose_packages }}" - state: present diff --git a/tests/integration/targets/setup_docker_compose_v1/tasks/Debian.yml b/tests/integration/targets/setup_docker_compose_v1/tasks/Debian.yml deleted file mode 100644 index 1729ccab..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/tasks/Debian.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -# 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 - -- name: Install docker-compose as system package - apt: - name: "{{ docker_compose_packages }}" - state: present diff --git a/tests/integration/targets/setup_docker_compose_v1/tasks/Fedora.yml b/tests/integration/targets/setup_docker_compose_v1/tasks/Fedora.yml deleted file mode 100644 index a5f3d467..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/tasks/Fedora.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -# 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 - -- name: Install docker-compose as system package - dnf: - name: "{{ docker_compose_packages }}" - state: present - enablerepo: docker-ce-test diff --git a/tests/integration/targets/setup_docker_compose_v1/tasks/RedHat-7.yml b/tests/integration/targets/setup_docker_compose_v1/tasks/RedHat-7.yml deleted file mode 100644 index 62f0e373..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/tasks/RedHat-7.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -# 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 - -- name: Install docker-compose as system package - yum: - name: "{{ docker_compose_packages }}" - state: present diff --git a/tests/integration/targets/setup_docker_compose_v1/tasks/RedHat-8.yml b/tests/integration/targets/setup_docker_compose_v1/tasks/RedHat-8.yml deleted file mode 100644 index 54986845..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/tasks/RedHat-8.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -# 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 - -- name: Install docker-compose as system package - dnf: - name: "{{ docker_compose_packages }}" - state: present diff --git a/tests/integration/targets/setup_docker_compose_v1/tasks/RedHat-9.yml b/tests/integration/targets/setup_docker_compose_v1/tasks/RedHat-9.yml deleted file mode 100644 index 54986845..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/tasks/RedHat-9.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -# 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 - -- name: Install docker-compose as system package - dnf: - name: "{{ docker_compose_packages }}" - state: present diff --git a/tests/integration/targets/setup_docker_compose_v1/tasks/Suse.yml b/tests/integration/targets/setup_docker_compose_v1/tasks/Suse.yml deleted file mode 100644 index 46e50fd4..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/tasks/Suse.yml +++ /dev/null @@ -1,12 +0,0 @@ ---- -# 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 - -- name: Install docker-compose as system package - community.general.zypper: - name: "{{ docker_compose_packages }}" - force: true - disable_gpg_check: true - update_cache: true - notify: cleanup docker diff --git a/tests/integration/targets/setup_docker_compose_v1/tasks/main.yml b/tests/integration/targets/setup_docker_compose_v1/tasks/main.yml deleted file mode 100644 index 63088510..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/tasks/main.yml +++ /dev/null @@ -1,16 +0,0 @@ ---- -# 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 - -#################################################################### -# WARNING: These are designed specifically for Ansible tests # -# and should not be used as examples of how to write Ansible roles # -#################################################################### - -- set_fact: - has_docker_compose: false - -- when: ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['CentOS6', 'RedHat6'] - include_tasks: - file: setup.yml diff --git a/tests/integration/targets/setup_docker_compose_v1/tasks/setup.yml b/tests/integration/targets/setup_docker_compose_v1/tasks/setup.yml deleted file mode 100644 index 0db7293d..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/tasks/setup.yml +++ /dev/null @@ -1,79 +0,0 @@ ---- -# 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 - -- name: Include distribution specific variables - include_vars: "{{ lookup('first_found', params) }}" - vars: - params: - files: - - "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}-py{{ ansible_python.version.major }}.yml" - - "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}-py{{ ansible_python.version.major }}.yml" - - "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml" - - "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml" - - "{{ ansible_facts.distribution }}-py{{ ansible_python.version.major }}.yml" - - "{{ ansible_facts.os_family }}-py{{ ansible_python.version.major }}.yml" - - "{{ ansible_facts.distribution }}.yml" - - "{{ ansible_facts.os_family }}.yml" - - default.yml - paths: - - "{{ 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 }}-py{{ ansible_python.version.major }}.yml" - - "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}-py{{ ansible_python.version.major }}.yml" - - "{{ ansible_facts.distribution }}-{{ ansible_facts.distribution_major_version }}.yml" - - "{{ ansible_facts.os_family }}-{{ ansible_facts.distribution_major_version }}.yml" - - "{{ ansible_facts.distribution }}-py{{ ansible_python.version.major }}.yml" - - "{{ ansible_facts.os_family }}-py{{ ansible_python.version.major }}.yml" - - "{{ ansible_facts.distribution }}.yml" - - "{{ ansible_facts.os_family }}.yml" - paths: - - "{{ role_path }}/tasks" - - - name: Limit docker pypi package version to < 4.3.0 - set_fact: - docker_pip_package_limit: '<4.3.0' - when: docker_api_version is version('1.39', '<') - - - name: Install/upgrade Docker SDK for Python - pip: - name: "{{ [docker_pip_package ~ docker_pip_package_limit] + docker_pip_extra_packages }}" - extra_args: "-c {{ remote_constraints }}" - state: present - - - name: Install docker-compose - pip: - state: present - name: "{{ docker_compose_pip_packages }}" - extra_args: "-c {{ remote_constraints }}" - - - name: Check docker-py version - command: "{{ ansible_python.executable }} -c 'import docker; print(docker.__version__)'" - register: docker_py_version_stdout - ignore_errors: true - - - name: Register docker-compose version - command: "{{ ansible_python.executable }} -c 'import compose; print(compose.__version__)'" - register: docker_compose_version - ignore_errors: true - - - name: Declare docker-py and docker-compose version - set_fact: - docker_py_version: "{{ docker_py_version_stdout.stdout | default('0.0') }}" - docker_compose_version: "{{ docker_compose_version.stdout | default('0.0.0') }}" - - - debug: - msg: "Docker SDK for Python version: {{ docker_py_version }}; Docker Compose version: {{ docker_compose_version }}" - - - name: Declare docker-compose as existing - set_fact: - has_docker_compose: true - - when: not skip_docker_compose diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/Alpine.yml b/tests/integration/targets/setup_docker_compose_v1/vars/Alpine.yml deleted file mode 100644 index 65f6f432..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/Alpine.yml +++ /dev/null @@ -1,13 +0,0 @@ ---- -# 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 - -docker_compose_packages: - - docker-compose -docker_compose_pip_packages: - - docker-compose - # Force PyYAML to 5.3.1 - - PyYAML==5.3.1 - # Force requests to < 2.32.0 (https://github.com/docker/docker-py/issues/3256) - - requests<2.32.0 diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/Archlinux.yml b/tests/integration/targets/setup_docker_compose_v1/vars/Archlinux.yml deleted file mode 100644 index bd619ad5..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/Archlinux.yml +++ /dev/null @@ -1,11 +0,0 @@ ---- -# 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 - -docker_compose_pip_packages: - - docker-compose - # Force PyYAML to 5.3.1 - - PyYAML==5.3.1 - # Force requests to < 2.32.0 (https://github.com/docker/docker-py/issues/3256) - - requests<2.32.0 diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/CentOS-8.yml b/tests/integration/targets/setup_docker_compose_v1/vars/CentOS-8.yml deleted file mode 100644 index c5d18002..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/CentOS-8.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# 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 - -skip_docker_compose: true diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/Debian-11.yml b/tests/integration/targets/setup_docker_compose_v1/vars/Debian-11.yml deleted file mode 100644 index 727d541f..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/Debian-11.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -# 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 - -docker_pip_extra_packages: - # https://github.com/docker/docker-py/issues/3113 - - requests<2.29.0 diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/Debian-12.yml b/tests/integration/targets/setup_docker_compose_v1/vars/Debian-12.yml deleted file mode 100644 index 727d541f..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/Debian-12.yml +++ /dev/null @@ -1,8 +0,0 @@ ---- -# 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 - -docker_pip_extra_packages: - # https://github.com/docker/docker-py/issues/3113 - - requests<2.29.0 diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/RedHat-7.yml b/tests/integration/targets/setup_docker_compose_v1/vars/RedHat-7.yml deleted file mode 100644 index 99b27c1c..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/RedHat-7.yml +++ /dev/null @@ -1,10 +0,0 @@ ---- -# 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 - -skip_docker_compose: true - -docker_pip_extra_packages: - # Not sure why RHEL7 needs this specific version - - requests==2.6.0 diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/RedHat-8.yml b/tests/integration/targets/setup_docker_compose_v1/vars/RedHat-8.yml deleted file mode 100644 index 7279eac1..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/RedHat-8.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# 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 - -docker_compose_packages: [] diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/RedHat-9.yml b/tests/integration/targets/setup_docker_compose_v1/vars/RedHat-9.yml deleted file mode 100644 index 7279eac1..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/RedHat-9.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# 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 - -docker_compose_packages: [] diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/Suse-py2.yml b/tests/integration/targets/setup_docker_compose_v1/vars/Suse-py2.yml deleted file mode 100644 index c5d18002..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/Suse-py2.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# 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 - -skip_docker_compose: true diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/Suse-py3.yml b/tests/integration/targets/setup_docker_compose_v1/vars/Suse-py3.yml deleted file mode 100644 index 7279eac1..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/Suse-py3.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# 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 - -docker_compose_packages: [] diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu-14.yml b/tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu-14.yml deleted file mode 100644 index f701e1f7..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu-14.yml +++ /dev/null @@ -1,9 +0,0 @@ ---- -# 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 - -docker_pip_extra_packages: - # Installing requests >=2.12.0 on Ubuntu 14.04 breaks certificate validation. We restrict to an older version - # to ensure out get_url tests work out fine. This is only an issue if pyOpenSSL is also installed. - - requests==2.6.0 diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu-16.yml b/tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu-16.yml deleted file mode 100644 index c5d18002..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu-16.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# 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 - -skip_docker_compose: true diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu-18.yml b/tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu-18.yml deleted file mode 100644 index c5d18002..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu-18.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# 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 - -skip_docker_compose: true diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu.yml b/tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu.yml deleted file mode 100644 index 46c58b25..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/Ubuntu.yml +++ /dev/null @@ -1,6 +0,0 @@ ---- -# 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 - -docker_compose_pip_packages: [] diff --git a/tests/integration/targets/setup_docker_compose_v1/vars/default.yml b/tests/integration/targets/setup_docker_compose_v1/vars/default.yml deleted file mode 100644 index f55df21f..00000000 --- a/tests/integration/targets/setup_docker_compose_v1/vars/default.yml +++ /dev/null @@ -1,4 +0,0 @@ ---- -# 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 diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt deleted file mode 100644 index 8dce572f..00000000 --- a/tests/sanity/ignore-2.11.txt +++ /dev/null @@ -1,14 +0,0 @@ -.azure-pipelines/scripts/publish-codecov.py replace-urlopen -.azure-pipelines/scripts/publish-codecov.py compile-2.6!skip # Uses Python 3.6+ syntax -.azure-pipelines/scripts/publish-codecov.py compile-2.7!skip # Uses Python 3.6+ syntax -.azure-pipelines/scripts/publish-codecov.py compile-3.5!skip # Uses Python 3.6+ syntax -.azure-pipelines/scripts/publish-codecov.py future-import-boilerplate -.azure-pipelines/scripts/publish-codecov.py metaclass-boilerplate -plugins/modules/current_container_facts.py validate-modules:return-syntax-error -plugins/module_utils/module_container/module.py compile-2.6!skip # Uses Python 2.7+ syntax -plugins/module_utils/module_container/module.py import-2.6!skip # Uses Python 2.7+ syntax -plugins/modules/docker_compose_v2.py validate-modules:return-syntax-error -plugins/modules/docker_compose_v2_pull.py validate-modules:return-syntax-error -plugins/modules/docker_container.py import-2.6!skip # Import uses Python 2.7+ syntax -plugins/modules/docker_container_copy_into.py validate-modules:undocumented-parameter # _max_file_size_for_diff is used by the action plugin -plugins/modules/docker_image_build.py validate-modules:invalid-documentation diff --git a/tests/sanity/ignore-2.11.txt.license b/tests/sanity/ignore-2.11.txt.license deleted file mode 100644 index edff8c76..00000000 --- a/tests/sanity/ignore-2.11.txt.license +++ /dev/null @@ -1,3 +0,0 @@ -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 -SPDX-FileCopyrightText: Ansible Project diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt deleted file mode 100644 index a3d961e4..00000000 --- a/tests/sanity/ignore-2.12.txt +++ /dev/null @@ -1,6 +0,0 @@ -.azure-pipelines/scripts/publish-codecov.py replace-urlopen -plugins/modules/current_container_facts.py validate-modules:return-syntax-error -plugins/modules/docker_compose_v2.py validate-modules:return-syntax-error -plugins/modules/docker_compose_v2_pull.py validate-modules:return-syntax-error -plugins/modules/docker_container_copy_into.py validate-modules:undocumented-parameter # _max_file_size_for_diff is used by the action plugin -plugins/modules/docker_image_build.py validate-modules:invalid-documentation diff --git a/tests/sanity/ignore-2.12.txt.license b/tests/sanity/ignore-2.12.txt.license deleted file mode 100644 index edff8c76..00000000 --- a/tests/sanity/ignore-2.12.txt.license +++ /dev/null @@ -1,3 +0,0 @@ -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 -SPDX-FileCopyrightText: Ansible Project diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt deleted file mode 100644 index ef8aab6c..00000000 --- a/tests/sanity/ignore-2.13.txt +++ /dev/null @@ -1,4 +0,0 @@ -.azure-pipelines/scripts/publish-codecov.py replace-urlopen -plugins/modules/docker_compose_v2.py validate-modules:return-syntax-error -plugins/modules/docker_container_copy_into.py validate-modules:undocumented-parameter # _max_file_size_for_diff is used by the action plugin -plugins/modules/docker_image_build.py validate-modules:invalid-documentation diff --git a/tests/sanity/ignore-2.13.txt.license b/tests/sanity/ignore-2.13.txt.license deleted file mode 100644 index edff8c76..00000000 --- a/tests/sanity/ignore-2.13.txt.license +++ /dev/null @@ -1,3 +0,0 @@ -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 -SPDX-FileCopyrightText: Ansible Project diff --git a/tests/sanity/ignore-2.14.txt b/tests/sanity/ignore-2.14.txt deleted file mode 100644 index f717d24a..00000000 --- a/tests/sanity/ignore-2.14.txt +++ /dev/null @@ -1,3 +0,0 @@ -.azure-pipelines/scripts/publish-codecov.py replace-urlopen -plugins/modules/docker_container_copy_into.py validate-modules:undocumented-parameter # _max_file_size_for_diff is used by the action plugin -plugins/modules/docker_image_build.py validate-modules:invalid-documentation diff --git a/tests/sanity/ignore-2.14.txt.license b/tests/sanity/ignore-2.14.txt.license deleted file mode 100644 index edff8c76..00000000 --- a/tests/sanity/ignore-2.14.txt.license +++ /dev/null @@ -1,3 +0,0 @@ -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 -SPDX-FileCopyrightText: Ansible Project