Avoid shadowing loop variables. (#738)

This commit is contained in:
Felix Fontein 2024-01-02 14:21:19 +01:00 committed by GitHub
parent 2caa77c032
commit 39717d380e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
28 changed files with 216 additions and 185 deletions

View File

@ -20,26 +20,28 @@
# Run the tests # Run the tests
- block: - block:
- include_tasks: run-test.yml - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- "tests/*.yml" - "tests/*.yml"
loop_control:
loop_var: test_name
always: always:
- name: "Make sure all containers are removed" - name: "Make sure all containers are removed"
docker_container: docker_container:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
force_kill: true force_kill: true
with_items: "{{ cnames }}" with_items: "{{ cnames }}"
diff: false diff: false
- name: "Make sure all networks are removed" - name: "Make sure all networks are removed"
docker_network: docker_network:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
force: true force: true
with_items: "{{ dnetworks }}" with_items: "{{ dnetworks }}"
when: docker_py_version is version('1.10.0', '>=') when: docker_py_version is version('1.10.0', '>=')
diff: false diff: false
when: has_docker_compose and docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.25', '>=') when: has_docker_compose and docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.25', '>=')

View File

@ -3,5 +3,5 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ item }}" - name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ item }}" include_tasks: "{{ test_name }}"

View File

@ -34,29 +34,31 @@
# Run the tests # Run the tests
- block: - block:
- include_tasks: run-test.yml - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- "tests/*.yml" - "tests/*.yml"
loop_control:
loop_var: test_name
always: always:
- name: "Make sure all containers are removed" - name: "Make sure all containers are removed"
docker_container: docker_container:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
force_kill: true force_kill: true
with_items: "{{ cnames }}" with_items: "{{ cnames }}"
diff: false diff: false
- name: "Make sure all images are removed" - name: "Make sure all images are removed"
docker_image_remove: docker_image_remove:
name: "{{ item }}" name: "{{ item }}"
with_items: "{{ inames }}" with_items: "{{ inames }}"
- name: "Make sure all networks are removed" - name: "Make sure all networks are removed"
docker_network: docker_network:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
force: true force: true
with_items: "{{ dnetworks }}" with_items: "{{ dnetworks }}"
diff: false diff: false
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=')

View File

@ -3,5 +3,5 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ item }}" - name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ item }}" include_tasks: "{{ test_name }}"

View File

@ -26,18 +26,20 @@
# Run the tests # Run the tests
- block: - block:
- include_tasks: run-test.yml - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- "tests/*.yml" - "tests/*.yml"
loop_control:
loop_var: test_name
always: always:
- name: "Make sure all containers are removed" - name: "Make sure all containers are removed"
docker_container: docker_container:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
force_kill: true force_kill: true
with_items: "{{ cnames }}" with_items: "{{ cnames }}"
diff: false diff: false
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=')

View File

@ -3,5 +3,5 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ item }}" - name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ item }}" include_tasks: "{{ test_name }}"

View File

@ -3,5 +3,5 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ item }}" - name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ item }}" include_tasks: "{{ test_name }}"

View File

@ -31,22 +31,24 @@
- StagedDockerfile - StagedDockerfile
- block: - block:
- include_tasks: run-test.yml - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- "tests/*.yml" - "tests/*.yml"
loop_control:
loop_var: test_name
always: always:
- name: "Make sure all images are removed" - name: "Make sure all images are removed"
docker_image: docker_image:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
with_items: "{{ inames }}" with_items: "{{ inames }}"
- name: "Make sure all containers are removed" - name: "Make sure all containers are removed"
docker_container: docker_container:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
force_kill: true force_kill: true
with_items: "{{ cnames }}" with_items: "{{ cnames }}"
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=')

View File

@ -3,5 +3,5 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ item }}" - name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ item }}" include_tasks: "{{ test_name }}"

View File

@ -34,22 +34,24 @@
msg: "Has buildx plugin: {{ docker_has_buildx }}" msg: "Has buildx plugin: {{ docker_has_buildx }}"
- block: - block:
- include_tasks: run-test.yml - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- "tests/*.yml" - "tests/*.yml"
loop_control:
loop_var: test_name
always: always:
- name: "Make sure all images are removed" - name: "Make sure all images are removed"
docker_image: docker_image:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
with_items: "{{ inames }}" with_items: "{{ inames }}"
- name: "Make sure all containers are removed" - name: "Make sure all containers are removed"
docker_container: docker_container:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
force_kill: true force_kill: true
with_items: "{{ cnames }}" with_items: "{{ cnames }}"
when: docker_api_version is version('1.25', '>=') and docker_cli_version is version('19.03', '>=') and docker_has_buildx when: docker_api_version is version('1.25', '>=') and docker_cli_version is version('19.03', '>=') and docker_has_buildx

View File

@ -3,5 +3,5 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ item }}" - name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ item }}" include_tasks: "{{ test_name }}"

View File

@ -15,21 +15,23 @@
msg: "Using name prefix {{ name_prefix }}" msg: "Using name prefix {{ name_prefix }}"
- block: - block:
- include_tasks: run-test.yml - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- "tests/*.yml" - "tests/*.yml"
loop_control:
loop_var: test_name
always: always:
- name: "Make sure all images are removed" - name: "Make sure all images are removed"
docker_image_remove: docker_image_remove:
name: "{{ item }}" name: "{{ item }}"
with_items: "{{ inames }}" with_items: "{{ inames }}"
- name: "Make sure all containers are removed" - name: "Make sure all containers are removed"
docker_container: docker_container:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
force_kill: true force_kill: true
with_items: "{{ cnames }}" with_items: "{{ cnames }}"
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=')

View File

@ -3,5 +3,5 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ item }}" - name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ item }}" include_tasks: "{{ test_name }}"

View File

@ -15,21 +15,23 @@
msg: "Using name prefix {{ name_prefix }}" msg: "Using name prefix {{ name_prefix }}"
- block: - block:
- include_tasks: run-test.yml - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- "tests/*.yml" - "tests/*.yml"
loop_control:
loop_var: test_name
always: always:
- name: "Make sure all images are removed" - name: "Make sure all images are removed"
docker_image_remove: docker_image_remove:
name: "{{ item }}" name: "{{ item }}"
with_items: "{{ inames }}" with_items: "{{ inames }}"
- name: "Make sure all containers are removed" - name: "Make sure all containers are removed"
docker_container: docker_container:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
force_kill: true force_kill: true
with_items: "{{ cnames }}" with_items: "{{ cnames }}"
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=')

View File

@ -3,5 +3,5 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ item }}" - name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ item }}" include_tasks: "{{ test_name }}"

View File

@ -15,21 +15,23 @@
msg: "Using name prefix {{ name_prefix }}" msg: "Using name prefix {{ name_prefix }}"
- block: - block:
- include_tasks: run-test.yml - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- "tests/*.yml" - "tests/*.yml"
loop_control:
loop_var: test_name
always: always:
- name: "Make sure all images are removed" - name: "Make sure all images are removed"
docker_image_remove: docker_image_remove:
name: "{{ item }}" name: "{{ item }}"
with_items: "{{ inames }}" with_items: "{{ inames }}"
- name: "Make sure all containers are removed" - name: "Make sure all containers are removed"
docker_container: docker_container:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
force_kill: true force_kill: true
with_items: "{{ cnames }}" with_items: "{{ cnames }}"
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=')

View File

@ -3,5 +3,5 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ item }}" - name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ item }}" include_tasks: "{{ test_name }}"

View File

@ -4,9 +4,11 @@
# SPDX-License-Identifier: GPL-3.0-or-later # SPDX-License-Identifier: GPL-3.0-or-later
- block: - block:
- include_tasks: run-test.yml - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- "tests/*.yml" - "tests/*.yml"
loop_control:
loop_var: test_name
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=')
- fail: msg="Too old docker / docker-py version to run docker_image tests!" - fail: msg="Too old docker / docker-py version to run docker_image tests!"

View File

@ -28,23 +28,25 @@
msg: "Using name prefix {{ name_prefix }}" msg: "Using name prefix {{ name_prefix }}"
- block: - block:
- include_tasks: run-test.yml - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- "tests/*.yml" - "tests/*.yml"
loop_control:
loop_var: test_name
always: always:
- name: "Make sure all containers are removed" - name: "Make sure all containers are removed"
docker_container: docker_container:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
force_kill: true force_kill: true
loop: "{{ cnames }}" loop: "{{ cnames }}"
- name: "Make sure all networks are removed" - name: "Make sure all networks are removed"
docker_network: docker_network:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
force: true force: true
loop: "{{ dnetworks }}" loop: "{{ dnetworks }}"
when: docker_api_version is version('1.25', '>=') # FIXME: find out API version! when: docker_api_version is version('1.25', '>=') # FIXME: find out API version!

View File

@ -3,5 +3,5 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ item }}" - name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ item }}" include_tasks: "{{ test_name }}"

View File

@ -17,16 +17,18 @@
register: dev_fuse_stat register: dev_fuse_stat
- block: - block:
- include_tasks: run-test.yml - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- "tests/*.yml" - "tests/*.yml"
loop_control:
loop_var: test_name
always: always:
- name: "Make sure plugin is removed" - name: "Make sure plugin is removed"
docker_plugin: docker_plugin:
plugin_name: "{{ item }}" plugin_name: "{{ item }}"
state: absent state: absent
with_items: "{{ plugin_names }}" with_items: "{{ plugin_names }}"
when: docker_api_version is version('1.25', '>=') and dev_fuse_stat.stat.exists when: docker_api_version is version('1.25', '>=') and dev_fuse_stat.stat.exists

View File

@ -3,5 +3,5 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ item }}" - name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ item }}" include_tasks: "{{ test_name }}"

View File

@ -14,9 +14,11 @@
- docker_api_version is version('1.25', '>=') - docker_api_version is version('1.25', '>=')
block: block:
- include_tasks: "{{ item }}" - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- 'tests/*.yml' - "tests/*.yml"
loop_control:
loop_var: test_name
always: always:
- import_tasks: cleanup.yml - import_tasks: cleanup.yml

View File

@ -2,3 +2,6 @@
# Copyright (c) Ansible Project # 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) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ test_name }}"

View File

@ -24,14 +24,16 @@
# Run the tests # Run the tests
- block: - block:
- name: Create a Swarm cluster - name: Create a Swarm cluster
docker_swarm: docker_swarm:
state: present state: present
advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}" advertise_addr: "{{ansible_default_ipv4.address | default('127.0.0.1')}}"
- include_tasks: run-test.yml - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- "tests/*.yml" - "tests/*.yml"
loop_control:
loop_var: test_name
always: always:
- name: Make sure all services are removed - name: Make sure all services are removed

View File

@ -3,5 +3,5 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ item }}" - name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ item }}" include_tasks: "{{ test_name }}"

View File

@ -17,16 +17,18 @@
msg: "Using name prefix {{ name_prefix }}" msg: "Using name prefix {{ name_prefix }}"
- block: - block:
- include_tasks: run-test.yml - include_tasks: run-test.yml
with_fileglob: with_fileglob:
- "tests/*.yml" - "tests/*.yml"
loop_control:
loop_var: test_name
always: always:
- name: "Make sure all volumes are removed" - name: "Make sure all volumes are removed"
docker_volume: docker_volume:
name: "{{ item }}" name: "{{ item }}"
state: absent state: absent
with_items: "{{ vnames }}" with_items: "{{ vnames }}"
when: docker_api_version is version('1.25', '>=') when: docker_api_version is version('1.25', '>=')

View File

@ -3,5 +3,5 @@
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt) # 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-License-Identifier: GPL-3.0-or-later
- name: "Loading tasks from {{ item }}" - name: "Loading tasks from {{ test_name }}"
include_tasks: "{{ item }}" include_tasks: "{{ test_name }}"