update ansible collections sops, docker and debops
All checks were successful
/ build (pull_request) Successful in 28s
/ Ansible Lint (push) Successful in 2m36s
/ Ansible Lint (pull_request) Successful in 2m41s

This commit is contained in:
chris 2026-09-21 22:26:20 +02:00
commit e31ee5e39c
Signed by: c6ristian
SSH key fingerprint: SHA256:B3m+yzpaxGXSEcDBpPHfvza/DNC0wuX+CKMeGq8wgak
910 changed files with 27667 additions and 19786 deletions

View file

@ -7,6 +7,10 @@
community.docker.current_container_facts:
register: result
- name: Print facts returned by module
ansible.builtin.debug:
var: result.ansible_facts
# The following two tasks are useful if we ever have to debug why this fails.
- name: Print all Ansible facts
@ -20,13 +24,10 @@
- /proc/self/cpuset
- /proc/1/cgroup
- /proc/1/environ
ignore_errors: true # not all of these files always exist
loop_control:
loop_var: path
- name: Print facts returned by module
ansible.builtin.debug:
var: result.ansible_facts
- name: Validate results
ansible.builtin.assert:
that:

View file

@ -27,8 +27,8 @@
- /proc/self/cgroup
- /proc/self/cpuset
- /proc/self/mountinfo
ignore_errors: true # not all of these files always exist
register: slurp
ignore_errors: true
- name: Print files
ansible.builtin.debug:

View file

@ -12,4 +12,4 @@
when: docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.30', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_config tests!"
when: not(docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.30', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_py_version is version('2.6.0', '>=') and docker_api_version is version('1.30', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -17,7 +17,7 @@
community.docker.docker_swarm:
name: default
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
- name: Parameter name should be required
community.docker.docker_config: # noqa: args[module]

View file

@ -70,4 +70,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run all docker_container tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -957,7 +957,7 @@
- when: device_read_bps_1 is failed
ansible.builtin.assert:
that:
- "'error setting cgroup config for procHooks process' in device_read_bps_1.msg and 'blkio.throttle.read_bps_device: no such device' in device_read_bps_1.msg"
- "'error setting cgroup config for procHooks process' in device_read_bps_1.msg and ': no such device' in device_read_bps_1.msg"
####################################################################
## device_read_iops ################################################
@ -1040,7 +1040,7 @@
- when: device_read_iops_1 is failed
ansible.builtin.assert:
that:
- "'error setting cgroup config for procHooks process' in device_read_iops_1.msg and 'blkio.throttle.read_iops_device: no such device' in device_read_iops_1.msg"
- "'error setting cgroup config for procHooks process' in device_read_iops_1.msg and ': no such device' in device_read_iops_1.msg"
####################################################################
## device_write_bps and device_write_iops ##########################
@ -1110,7 +1110,7 @@
- when: device_write_limit_1 is failed
ansible.builtin.assert:
that:
- "'error setting cgroup config for procHooks process' in device_write_limit_1.msg and 'blkio.throttle.write_bps_device: no such device' in device_write_limit_1.msg"
- "'error setting cgroup config for procHooks process' in device_write_limit_1.msg and ': no such device' in device_write_limit_1.msg"
####################################################################
## device_requests #################################################

View file

@ -44,4 +44,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old Docker API version to run all docker_container_copy_into tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -243,4 +243,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_container_exec tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -81,4 +81,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_container_info tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -37,4 +37,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run all docker_container tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -12,7 +12,7 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_host_info tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)
- when: podman_cli_version is version('1.0.0', '>=')
block:

View file

@ -53,4 +53,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_image tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -68,4 +68,4 @@
when: docker_api_version is version('1.25', '>=') and docker_cli_version is version('19.03', '>=') and docker_has_buildx
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_image tests!"
when: not(docker_api_version is version('1.25', '>=') and docker_cli_version is version('19.03', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6) and docker_has_buildx
when: not(docker_api_version is version('1.25', '>=') and docker_cli_version is version('19.03', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6) and docker_has_buildx

View file

@ -36,4 +36,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_image tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -0,0 +1,34 @@
---
# 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
- when: docker_api_version is version('1.48', '>=')
block:
- name: Pull image for platform test
community.docker.docker_image_pull:
name: "{{ docker_test_image_hello_world }}"
platform: linux/amd64
- name: Export image with platform (check mode)
community.docker.docker_image_export:
name: "{{ docker_test_image_hello_world }}"
path: "{{ remote_tmp_dir }}/platform-test.tar"
platform: linux/amd64
register: result_check
check_mode: true
- ansible.builtin.assert:
that:
- result_check is changed
- name: Export image with platform
community.docker.docker_image_export:
name: "{{ docker_test_image_hello_world }}"
path: "{{ remote_tmp_dir }}/platform-test.tar"
platform: linux/amd64
register: result
- ansible.builtin.assert:
that:
- result is changed

View file

@ -57,4 +57,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_image_info tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -36,4 +36,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_image tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -36,4 +36,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_image tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -36,4 +36,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_image tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -303,4 +303,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_image_info tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -6,3 +6,4 @@
dependencies:
- setup_docker
- setup_docker_python_deps
- setup_utils

View file

@ -76,7 +76,7 @@
- info_1.images | length == 2
- info_1.images[0].Id == pulled_images.results[0].image.Id
- info_1.images[1].Id == pulled_images.results[0].image.Id
- tag_1_check == tag_1
- tag_1_check | internal__normalize_image("image") == tag_1 | internal__normalize_image("image")
- name: Tag image 1 (idempotent, check mode)
community.docker.docker_image_tag:
@ -102,7 +102,7 @@
- tag_2 is not changed
- tag_2.diff.before == tag_2.diff.after
- tag_2.diff.before.images | length == 2
- tag_2_check == tag_2
- tag_2_check | internal__normalize_image("image") == tag_2 | internal__normalize_image("image")
- name: Tag image 1 (idempotent, different input format, check mode)
community.docker.docker_image_tag:
@ -130,7 +130,7 @@
- tag_3 is not changed
- tag_3.diff.before == tag_3.diff.after
- tag_3.diff.before.images | length == 2
- tag_3_check == tag_3
- tag_3_check | internal__normalize_image("image") == tag_3 | internal__normalize_image("image")
- name: Tag image 1 (one more, check mode)
community.docker.docker_image_tag:
@ -173,7 +173,7 @@
- info_4.images[0].Id == pulled_images.results[0].image.Id
- info_4.images[1].Id == pulled_images.results[0].image.Id
- info_4.images[2].Id == pulled_images.results[0].image.Id
- tag_4_check == tag_4
- tag_4_check | internal__normalize_image("image") == tag_4 | internal__normalize_image("image")
- name: Tag image 2 (only change missing one, check mode)
community.docker.docker_image_tag:
@ -219,7 +219,7 @@
- info_5.images[1].Id == pulled_images.results[0].image.Id
- info_5.images[2].Id == pulled_images.results[1].image.Id
- info_5.images[3].Id == pulled_images.results[0].image.Id
- tag_5_check == tag_5
- tag_5_check | internal__normalize_image("image") == tag_5 | internal__normalize_image("image")
- name: Tag image 2 (idempotent, check mode)
community.docker.docker_image_tag:
@ -249,7 +249,7 @@
- tag_6 is not changed
- tag_6.diff.before == tag_6.diff.after
- tag_6.diff.before.images | length == 3
- tag_6_check == tag_6
- tag_6_check | internal__normalize_image("image") == tag_6 | internal__normalize_image("image")
- name: Tag image 2 (only change wrong ones, check mode)
community.docker.docker_image_tag:
@ -296,7 +296,7 @@
- info_7.images[1].Id == pulled_images.results[1].image.Id
- info_7.images[2].Id == pulled_images.results[1].image.Id
- info_7.images[3].Id == pulled_images.results[0].image.Id
- tag_7_check == tag_7
- tag_7_check | internal__normalize_image("image") == tag_7 | internal__normalize_image("image")
- name: Tag image 2 (idempotent, check mode)
community.docker.docker_image_tag:
@ -326,7 +326,7 @@
- tag_8 is not changed
- tag_8.diff.before == tag_8.diff.after
- tag_8.diff.before.images | length == 3
- tag_8_check == tag_8
- tag_8_check | internal__normalize_image("image") == tag_8 | internal__normalize_image("image")
- name: Tag image 3 (source image has digest)
community.docker.docker_image_tag:
@ -399,4 +399,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_image_info tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -12,4 +12,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_image tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -51,4 +51,4 @@
when: docker_api_version is version('1.25', '>=') # FIXME: find out API version!
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_network tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -205,7 +205,7 @@
name: "{{ nname_ipam_3 }}"
driver: "macvlan"
driver_options:
parent: "{{ ansible_default_ipv4.alias }}"
parent: "{{ ansible_facts.default_ipv4.alias }}"
ipam_config:
- subnet: 10.26.120.0/24
- subnet: 10.26.121.0/24
@ -220,7 +220,7 @@
name: "{{ nname_ipam_3 }}"
driver: "macvlan"
driver_options:
parent: "{{ ansible_default_ipv4.alias }}"
parent: "{{ ansible_facts.default_ipv4.alias }}"
ipam_config:
- subnet: 10.26.121.0/24
- subnet: 10.26.120.0/24
@ -235,7 +235,7 @@
name: "{{ nname_ipam_3 }}"
driver: "macvlan"
driver_options:
parent: "{{ ansible_default_ipv4.alias }}"
parent: "{{ ansible_facts.default_ipv4.alias }}"
ipam_config:
- subnet: 10.26.120.0/24
- subnet: 10.26.122.0/24
@ -252,7 +252,7 @@
name: "{{ nname_ipam_3 }}"
driver: "macvlan"
driver_options:
parent: "{{ ansible_default_ipv4.alias }}"
parent: "{{ ansible_facts.default_ipv4.alias }}"
ipam_config:
- subnet: 10.26.122.0/24
register: network
@ -266,7 +266,7 @@
name: "{{ nname_ipam_3 }}"
state: absent
when: ansible_facts.virtualization_type != 'docker' and ansible_default_ipv4.alias is defined
when: ansible_facts.virtualization_type != 'docker' and ansible_facts.default_ipv4.alias is defined
#################### IPAM driver options ####################

View file

@ -119,7 +119,7 @@
- name: swarm
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
# Driver change alongside scope is intentional - bridge doesn't appear to support anything but local, and overlay can't downgrade to local. Additionally, overlay reports as swarm for swarm OR global, so no change is reported in that case.
# Test output indicates that the scope is altered, at least, so manual inspection will be required to verify this going forward, unless we come up with a test driver that supports multiple scopes.

View file

@ -15,7 +15,7 @@
- name: swarm
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
####################################################################
## overlay #########################################################

View file

@ -77,4 +77,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_network_info tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -38,4 +38,4 @@
when: docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_node tests!"
when: not(docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -23,7 +23,7 @@
- name: Create a Swarm cluster
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
register: output
- name: assert changed when create a new swarm cluster

View file

@ -12,4 +12,4 @@
when: docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_node_info tests!"
when: not(docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_py_version is version('2.4.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -23,7 +23,7 @@
- name: Create a Swarm cluster
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
register: output
- name: assert changed when create a new swarm cluster

View file

@ -33,4 +33,4 @@
when: docker_api_version is version('1.25', '>=') and dev_fuse_stat.stat.exists
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_plugin tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -172,4 +172,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_prune tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -12,4 +12,4 @@
when: docker_py_version is version('2.1.0', '>=') and docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_secrets tests!"
when: not(docker_py_version is version('2.1.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_py_version is version('2.1.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -12,7 +12,7 @@
- name: Create a Swarm cluster
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
- name: Parameter name should be required
community.docker.docker_secret: # noqa: args[module]

View file

@ -12,4 +12,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_stack tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -12,7 +12,7 @@
- name: Create a Swarm cluster
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
- name: install docker_stack python requirements
ansible.builtin.pip:

View file

@ -12,4 +12,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_stack tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -23,7 +23,7 @@
- name: Create a swarm cluster
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
- name: Get docker_stack_info when docker is running and not stack available
community.docker.docker_stack_info:

View file

@ -12,4 +12,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_stack tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -23,7 +23,7 @@
- name: Create a swarm cluster
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
- name: Get docker_stack_info when docker is running and not stack available
community.docker.docker_stack_info:

View file

@ -27,4 +27,4 @@
msg: "Too old docker / docker-py version to run docker_swarm tests!"
when:
- not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.25', '>='))
- (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
- (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -40,7 +40,7 @@
- name: Create a Swarm cluster (check mode)
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
check_mode: true
diff: true
register: output_1
@ -48,21 +48,21 @@
- name: Create a Swarm cluster
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
diff: true
register: output_2
- name: Create a Swarm cluster (idempotent)
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
diff: true
register: output_3
- name: Create a Swarm cluster (idempotent, check mode)
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
check_mode: true
diff: true
register: output_4
@ -70,7 +70,7 @@
- name: Create a Swarm cluster (force re-create)
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
force: true
diff: true
register: output_5
@ -78,7 +78,7 @@
- name: Create a Swarm cluster (force re-create, check mode)
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
force: true
check_mode: true
diff: true

View file

@ -58,7 +58,7 @@
register: ansible_keys
- name: signing_ca_cert and signing_ca_key (check mode)
community.docker.docker_swarm:
advertise_addr: '{{ ansible_default_ipv4.address | default("127.0.0.1") }}'
advertise_addr: '{{ ansible_facts.default_ipv4.address | default("127.0.0.1") }}'
state: present
signing_ca_cert: '{{ ansible_certificates.results[0].content | b64decode }}'
signing_ca_key: '{{ ansible_keys.results[0].content | b64decode }}'
@ -69,7 +69,7 @@
ignore_errors: true
- name: signing_ca_cert and signing_ca_key
community.docker.docker_swarm:
advertise_addr: '{{ ansible_default_ipv4.address | default("127.0.0.1") }}'
advertise_addr: '{{ ansible_facts.default_ipv4.address | default("127.0.0.1") }}'
state: present
signing_ca_cert: '{{ ansible_certificates.results[0].content | b64decode }}'
signing_ca_key: '{{ ansible_keys.results[0].content | b64decode }}'

View file

@ -9,7 +9,7 @@
- name: Create a Swarm cluster
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
name: default
diff: true
@ -72,7 +72,7 @@
community.docker.docker_swarm:
state: present
force: true
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
autolock_managers: true
diff: true
register: output_7

View file

@ -12,4 +12,4 @@
when: docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_swarm_info tests!"
when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_py_version is version('1.10.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -27,7 +27,7 @@
- name: Create a Swarm cluster
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
register: output
- name: assert changed when create a new swarm cluster
@ -160,7 +160,7 @@
- name: Update swarm cluster to be locked
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
autolock_managers: true
register: autolock_managers_update_output
ignore_errors: true

View file

@ -27,7 +27,7 @@
- name: Create a Swarm cluster
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
- ansible.builtin.include_tasks: run-test.yml
with_fileglob:
@ -82,4 +82,4 @@
when: docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_swarm_service tests!"
when: not(docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -12,4 +12,4 @@
when: docker_py_version is version('2.0.0', '>=') and docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_swarm_service_info tests!"
when: not(docker_py_version is version('2.0.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_py_version is version('2.0.0', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -32,7 +32,7 @@
- name: Create a Swarm cluster
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"
register: output
- name: Create services
@ -82,4 +82,4 @@
when: docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_swarm_service_info tests!"
when: not(docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -33,4 +33,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_volume tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -74,4 +74,4 @@
when: docker_api_version is version('1.25', '>=')
- ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_volume_info tests!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)

View file

@ -20,4 +20,4 @@
- name: Create a Swarm cluster
community.docker.docker_swarm:
state: present
advertise_addr: "{{ ansible_default_ipv4.address | default('127.0.0.1') }}"
advertise_addr: "{{ ansible_facts.default_ipv4.address | default('127.0.0.1') }}"

View file

@ -9,38 +9,32 @@
- name: Install pre-reqs
ansible.builtin.apt:
name: '{{ docker_prereq_packages }}'
name: '{{ docker_prereq_packages + ["python3-debian"] }}'
state: present
update_cache: true
notify: cleanup docker
- when:
- (ansible_facts.distribution == "Ubuntu" and (ansible_facts.distribution_major_version | int) >= 22) or
(ansible_facts.distribution == "Debian" and (ansible_facts.distribution_major_version | int) >= 12)
name: Add Docker repo on Ubuntu 22+ or Debian 12+
block:
- name: Add gpg key
ansible.builtin.get_url:
url: "https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg"
dest: /etc/apt/keyrings/docker.asc
- name: Add Docker repo on Ubuntu or Debian
ansible.builtin.deb822_repository:
name: docker
types: deb
architectures:
- >-
{{ 'arm64' if ansible_facts.architecture == 'aarch64' else 'amd64' }}
signed_by: "https://download.docker.com/linux/{{ ansible_facts.distribution | lower }}/gpg"
uris:
- https://download.docker.com/linux/{{ ansible_facts.distribution | lower }}
suites:
- "{{ ansible_facts.distribution_release }}"
components:
- stable
state: present
register: apt_repo
- name: Add Docker repo
ansible.builtin.apt_repository:
repo: deb [arch={{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }} signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable
state: present
- when:
- (ansible_facts.distribution == "Ubuntu" and (ansible_facts.distribution_major_version | int) < 22) or
(ansible_facts.distribution == "Debian" and (ansible_facts.distribution_major_version | int) < 12)
name: Add Docker repo on Ubuntu 20 or before, or Debian 11 or before
block:
- name: Add gpg key
ansible.builtin.shell: curl -fsSL https://download.docker.com/linux/{{ ansible_distribution | lower }}/gpg >key && apt-key add key # noqa: command-instead-of-module
- name: Add Docker repo
ansible.builtin.apt_repository:
repo: deb [arch={{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}] https://download.docker.com/linux/{{ ansible_distribution | lower }} {{ ansible_distribution_release }} stable
state: present
- name: Update apt cache
ansible.builtin.apt:
update_cache: true
when: apt_repo is changed
- block:
- name: Prevent service restart

View file

@ -35,5 +35,5 @@
ansible.builtin.service:
name: docker
state: started
ignore_errors: "{{ ansible_virtualization_type in ['docker', 'container', 'containerd'] }}"
ignore_errors: "{{ ansible_facts.virtualization_type in ['docker', 'container', 'containerd'] }}"
when: needs_docker_daemon

View file

@ -42,5 +42,5 @@
ansible.builtin.service:
name: docker
state: started
ignore_errors: "{{ ansible_virtualization_type in ['docker', 'container', 'containerd'] }}"
ignore_errors: "{{ ansible_facts.virtualization_type in ['docker', 'container', 'containerd'] }}"
when: needs_docker_daemon

View file

@ -35,5 +35,5 @@
ansible.builtin.service:
name: docker
state: started
ignore_errors: "{{ ansible_virtualization_type in ['docker', 'container', 'containerd'] }}"
ignore_errors: "{{ ansible_facts.virtualization_type in ['docker', 'container', 'containerd'] }}"
when: needs_docker_daemon

View file

@ -35,5 +35,5 @@
ansible.builtin.service:
name: docker
state: started
ignore_errors: "{{ ansible_virtualization_type in ['docker', 'container', 'containerd'] }}"
ignore_errors: "{{ ansible_facts.virtualization_type in ['docker', 'container', 'containerd'] }}"
when: needs_docker_daemon

View file

@ -23,7 +23,7 @@
block:
- name: Determine whether Docker Daemon needs to be installed
ansible.builtin.set_fact:
needs_docker_daemon: '{{ not ansible_module_running_in_container }}'
needs_docker_daemon: '{{ not ansible_facts.module_running_in_container }}'
- name: Print information
ansible.builtin.debug:
@ -62,7 +62,7 @@
ansible.builtin.service:
name: docker
state: started
when: not ansible_module_running_in_container
when: not ansible_facts.module_running_in_container
- name: Set marker that Docker was already set up
ansible.builtin.file:
@ -70,6 +70,26 @@
state: touch
when: docker_skip_cleanup
- name: Retrieve more information (0/4)
ansible.builtin.command:
cmd: sh -c export
- name: Retrieve more information (1/4)
ansible.builtin.command:
cmd: docker version
- name: Retrieve more information (2/4)
ansible.builtin.command:
cmd: docker info
- name: Retrieve more information (3/4)
ansible.builtin.command:
cmd: docker context ls
- name: Retrieve more information (4/4)
ansible.builtin.command:
cmd: which docker
# Detect docker API version
- name: Check Docker API version
ansible.builtin.command: "docker version -f {% raw %}'{{(index .Server.Components 0).Details.ApiVersion}}'{% endraw %}"

View file

@ -63,4 +63,8 @@
{{ docker_cli_plugins_stdout.stdout | from_json | selectattr('Name', 'eq', 'compose') | map(attribute='Version') | first | default('0.0') | regex_replace('^v', '') }}
- ansible.builtin.debug:
msg: "Has Docker compoes plugin: {{ docker_has_compose }}; Docker compose plugin version: {{ docker_compose_version }}"
msg: "Has Docker compose plugin: {{ docker_has_compose }}; Docker compose plugin version: {{ docker_compose_version }}"
- name: Retrieve more information
ansible.builtin.command:
cmd: docker version

View file

@ -11,6 +11,6 @@
- ansible.builtin.set_fact:
has_docker_compose: false
- when: ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['CentOS6', 'RedHat6'] and ansible_python_version is version('3.7', '>=')
- when: ansible_facts.distribution ~ ansible_facts.distribution_major_version not in ['CentOS6', 'RedHat6'] and ansible_facts.python_version is version('3.7', '>=')
ansible.builtin.include_tasks:
file: setup.yml

View file

@ -16,10 +16,10 @@
- name: Inspect current container
community.docker.docker_container_info:
name: "{{ ansible_module_container_id }}"
name: "{{ ansible_facts.module_container_id }}"
register: current_container_info
when: ansible_module_running_in_container
when: ansible_facts.module_running_in_container
- name: Determine network name
ansible.builtin.set_fact:
current_container_network_ip: "{{ (current_container_info.container.NetworkSettings.Networks | dictsort)[0].0 | default('') if ansible_module_running_in_container else '' }}"
current_container_network_ip: "{{ (current_container_info.container.NetworkSettings.Networks | dictsort)[0].0 | default('') if ansible_facts.module_running_in_container else '' }}"

View file

@ -41,7 +41,7 @@
msg: Using test registry name {{ docker_registry_container_name_registry }} and nginx frontend names {{ docker_registry_container_name_nginx }} and {{ docker_registry_container_name_nginx2 }}
- ansible.builtin.fail: msg="Too old docker version to set up docker registry!"
when: not(docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)
- when: docker_api_version is version('1.25', '>=')
block:

View file

@ -53,7 +53,7 @@
}}
- name: Check docker-py version
ansible.builtin.command: "{{ ansible_python.executable }} -c 'import docker; print(docker.__version__)'"
ansible.builtin.command: "{{ ansible_facts.python.executable }} -c 'import docker; print(docker.__version__)'"
register: docker_py_version_stdout
ignore_errors: true

View file

@ -10,6 +10,6 @@
- name: Install EPEL
ansible.builtin.dnf:
name: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/setup_epel/epel-release-latest-{{ ansible_distribution_major_version }}.noarch.rpm
name: https://s3.amazonaws.com/ansible-ci-files/test/integration/targets/setup_epel/epel-release-latest-{{ ansible_facts.distribution_major_version }}.noarch.rpm
disable_gpg_check: true
when: ansible_facts.distribution in ['RedHat', 'CentOS']

View file

@ -9,20 +9,20 @@
####################################################################
- name: Include OS-specific variables
ansible.builtin.include_vars: '{{ ansible_os_family }}.yml'
when: not ansible_os_family == "Darwin"
ansible.builtin.include_vars: '{{ ansible_facts.os_family }}.yml'
when: not ansible_facts.os_family == "Darwin"
- name: Install cryptography (Python 3)
become: true
ansible.builtin.package:
name: '{{ cryptography_package_name_python3 }}'
when: ansible_os_family != 'Darwin' and ansible_python_version is version('3.0', '>=')
when: ansible_facts.os_family != 'Darwin' and ansible_facts.python_version is version('3.0', '>=')
- name: Install cryptography (Python 2)
become: true
ansible.builtin.package:
name: '{{ cryptography_package_name }}'
when: ansible_os_family != 'Darwin' and ansible_python_version is version('3.0', '<')
when: ansible_facts.os_family != 'Darwin' and ansible_facts.python_version is version('3.0', '<')
- name: Install cryptography (Darwin, and potentially upgrade for other OSes)
become: true
@ -31,5 +31,5 @@
extra_args: "-c {{ remote_constraints }}"
- name: Register cryptography version
ansible.builtin.command: "{{ ansible_python.executable }} -c 'import cryptography; print(cryptography.__version__)'"
ansible.builtin.command: "{{ ansible_facts.python.executable }} -c 'import cryptography; print(cryptography.__version__)'"
register: cryptography_version

View file

@ -8,7 +8,7 @@
name: python-paramiko
become: true
when:
- ansible_distribution == 'CentOS' and ansible_distribution_major_version|int <= 7
- ansible_facts.distribution == 'CentOS' and ansible_facts.distribution_major_version|int <= 7
- name: Install paramiko
ansible.builtin.pip:

View file

@ -12,20 +12,20 @@
pkg_mgr: community.general.pkgng
ansible_pkg_mgr: community.general.pkgng
cacheable: true
when: ansible_os_family == "FreeBSD"
when: ansible_facts.os_family == "FreeBSD"
- ansible.builtin.set_fact:
pkg_mgr: community.general.zypper
ansible_pkg_mgr: community.general.zypper
cacheable: true
when: ansible_os_family == "Suse"
when: ansible_facts.os_family == "Suse"
- ansible.builtin.shell:
# noqa: command-instead-of-module
cmd: |
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/*.repo
sed -i 's%#baseurl=http://mirror.centos.org/%baseurl=https://vault.centos.org/%g' /etc/yum.repos.d/*.repo
when: ansible_distribution in 'CentOS' and ansible_distribution_major_version == '7'
when: ansible_facts.distribution in 'CentOS' and ansible_facts.distribution_major_version == '7'
- ansible.builtin.shell:
# noqa: command-instead-of-module
@ -33,4 +33,4 @@
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-Linux-*.repo
sed -i 's%#baseurl=http://mirror.centos.org/$contentdir/$releasever/%baseurl=https://vault.centos.org/8.4.2105/%g' /etc/yum.repos.d/CentOS-Linux-*.repo
ignore_errors: true # This fails for CentOS Stream 8
when: ansible_distribution in 'CentOS' and ansible_distribution_major_version == '8'
when: ansible_facts.distribution in 'CentOS' and ansible_facts.distribution_major_version == '8'

View file

@ -23,7 +23,7 @@
ansible.builtin.command: id -u
register: podman_user_id
- when: not podman_setup_marker.stat.exists and not ansible_module_running_in_container
- when: not podman_setup_marker.stat.exists and not ansible_facts.module_running_in_container
block:
- name: Print information
ansible.builtin.debug:
@ -57,7 +57,7 @@
ansible.builtin.systemd_service:
name: "{{ podman_socket_service }}"
state: started
scope: "{{ 'global' if podman_user_id.stdout == '0' and ansible_facts.os_family == 'RedHat' and (ansible_facts.distribution_major_version | int < 10) else 'user' }}"
scope: "{{ 'global' if podman_user_id.stdout == '0' and ansible_facts.os_family == 'RedHat' and (ansible_facts.distribution_version is version('9.8', '<')) else 'user' }}"
environment:
XDG_RUNTIME_DIR: "{{ '/run' if podman_user_id.stdout == '0' else ('/run/user/' ~ podman_user_id.stdout) }}"
@ -67,13 +67,13 @@
state: touch
when: podman_skip_cleanup
- when: not has_podman or ansible_module_running_in_container
- when: not has_podman or ansible_facts.module_running_in_container
block:
- ansible.builtin.set_fact:
podman_cli_version: "0.0"
podman_socket: "not available"
- when: has_podman and not ansible_module_running_in_container
- when: has_podman and not ansible_facts.module_running_in_container
block:
- name: Check Podman CLI version
ansible.builtin.command: "podman version -f {% raw %}'{{.Client.Version}}'{% endraw %}"

View file

@ -7,4 +7,3 @@
ansible.builtin.file:
path: "{{ remote_tmp_dir }}"
state: absent
no_log: true

View file

@ -8,7 +8,7 @@
# and should not be used as examples of how to write Ansible roles #
####################################################################
- name: make sure we have the ansible_os_family and ansible_distribution_version facts
- name: make sure we have the ansible_facts.os_family and ansible_facts.distribution_version facts
ansible.builtin.setup:
gather_subset: distribution
when: ansible_facts == {}
@ -16,5 +16,5 @@
- ansible.builtin.include_tasks: "{{ lookup('first_found', files) }}"
vars:
files:
- "{{ ansible_os_family | lower }}.yml"
- "{{ ansible_facts.os_family | lower }}.yml"
- "default.yml"

View file

@ -0,0 +1,46 @@
# Copyright (c) 2026, Felix Fontein <felix@fontein.de>
# 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 annotations
from collections.abc import Mapping, Sequence
def _normalize_image_impl(data):
identity = data.get("Identity")
if not isinstance(identity, Mapping):
return data
pull = identity.get("Pull")
if not isinstance(pull, Sequence):
return data
new_identity = dict(identity)
new_identity["Pull"] = sorted(identity["Pull"], key=lambda entry: entry.get("Repository") or "")
new_data = dict(data)
new_data["Identity"] = new_identity
return new_data
def _process(data, place_parts, place_index, processor):
if place_index == len(place_parts):
return processor(data)
new_data = dict(data)
new_data[place_parts[place_index]] = _process(data[place_parts[place_index]], place_parts, place_index + 1, processor)
return new_data
def normalize_image(data, *places):
if not places:
return _normalize_image_impl(data)
for place in places:
data = _process(data, place.split("."), 0, _normalize_image_impl)
return data
class FilterModule:
"""Utilities for community.docker tests."""
def filters(self):
return {
'internal__normalize_image': normalize_image,
}

View file

@ -0,0 +1,4 @@
---
# Copyright (c) Ansible Project
# GNU General Public License v3.0+ (see LICENSES/GPL-3.0-or-later.txt or https://www.gnu.org/licenses/gpl-3.0.txt)
# SPDX-License-Identifier: GPL-3.0-or-later

View file

@ -1,7 +1,9 @@
plugins/connection/docker.py no-assert
plugins/connection/docker_api.py no-assert
plugins/connection/nsenter.py no-assert
plugins/module_utils/_api/credentials/store.py pylint:ansible-bad-function
plugins/module_utils/_api/transport/sshconn.py no-assert
plugins/module_utils/_api/transport/sshconn.py pylint:ansible-bad-function
plugins/module_utils/_api/utils/build.py no-assert
plugins/module_utils/_module_container/module.py no-assert
plugins/module_utils/_platform.py no-assert

View file

@ -0,0 +1,19 @@
plugins/connection/docker.py no-assert
plugins/connection/docker_api.py no-assert
plugins/connection/nsenter.py no-assert
plugins/module_utils/_api/credentials/store.py pylint:ansible-bad-function
plugins/module_utils/_api/transport/sshconn.py no-assert
plugins/module_utils/_api/transport/sshconn.py pylint:ansible-bad-function
plugins/module_utils/_api/utils/build.py no-assert
plugins/module_utils/_module_container/module.py no-assert
plugins/module_utils/_platform.py no-assert
plugins/module_utils/_socket_handler.py no-assert
plugins/modules/docker_container_copy_into.py no-assert
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_container_exec.py no-assert
plugins/modules/docker_image.py no-assert
plugins/modules/docker_image_tag.py no-assert
plugins/modules/docker_login.py no-assert
plugins/modules/docker_plugin.py no-assert
plugins/modules/docker_swarm_service.py no-assert
plugins/modules/docker_volume.py no-assert

View file

@ -0,0 +1,3 @@
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

View file

@ -20,7 +20,7 @@ from ansible_collections.community.docker.plugins.inventory.docker_containers im
)
if t.TYPE_CHECKING:
from collections.abc import Callable
from collections.abc import Callable # pragma: no cover
@pytest.fixture(scope="module", name="templar")

View file

@ -43,7 +43,7 @@ from ansible_collections.community.docker.tests.unit.plugins.module_utils._api.c
from .. import fake_api
if t.TYPE_CHECKING:
from ansible_collections.community.docker.plugins.module_utils._api.auth import (
from ansible_collections.community.docker.plugins.module_utils._api.auth import ( # pragma: no cover
AuthConfig,
)

View file

@ -18,7 +18,7 @@ from ansible_collections.community.docker.tests.unit.plugins.module_utils._api.c
from . import fake_stat
if t.TYPE_CHECKING:
from collections.abc import Callable
from collections.abc import Callable # pragma: no cover
CURRENT_VERSION = f"v{DEFAULT_DOCKER_API_VERSION}"

View file

@ -13,9 +13,9 @@ from ansible_collections.community.docker.plugins.module_utils._copy import (
)
if t.TYPE_CHECKING:
from collections.abc import Sequence
from collections.abc import Sequence # pragma: no cover
T = t.TypeVar("T")
T = t.TypeVar("T") # pragma: no cover
def _simple_generator(sequence: Sequence[T]) -> t.Generator[T]:

View file

@ -61,12 +61,10 @@ def test_archived_image_manifest_extracts_nothing_when_file_not_present(
def test_archived_image_manifest_raises_when_file_not_a_tar() -> None:
try:
with pytest.raises(ImageArchiveInvalidException, match=__file__) as exc_info:
archived_image_manifest(__file__)
raise AssertionError()
except ImageArchiveInvalidException as e:
assert isinstance(e.__cause__, tarfile.ReadError)
assert str(__file__) in str(e)
assert isinstance(exc_info.value.__cause__, tarfile.ReadError)
assert str(__file__) in str(exc_info.value)
def test_archived_image_manifest_raises_when_tar_missing_manifest(
@ -74,12 +72,10 @@ def test_archived_image_manifest_raises_when_tar_missing_manifest(
) -> None:
write_irrelevant_tar(tar_file_name)
try:
with pytest.raises(ImageArchiveInvalidException) as exc_info:
archived_image_manifest(tar_file_name)
raise AssertionError()
except ImageArchiveInvalidException as e:
assert isinstance(e.__cause__, KeyError)
assert "manifest.json" in str(e.__cause__)
assert isinstance(exc_info.value.__cause__, KeyError)
assert "manifest.json" in str(exc_info.value.__cause__)
def test_archived_image_manifest_raises_when_manifest_missing_id(
@ -89,9 +85,7 @@ def test_archived_image_manifest_raises_when_manifest_missing_id(
write_imitation_archive_with_manifest(tar_file_name, manifest)
try:
with pytest.raises(ImageArchiveInvalidException) as exc_info:
archived_image_manifest(tar_file_name)
raise AssertionError()
except ImageArchiveInvalidException as e:
assert isinstance(e.__cause__, KeyError)
assert "Config" in str(e.__cause__)
assert isinstance(exc_info.value.__cause__, KeyError)
assert "Config" in str(exc_info.value.__cause__)

View file

@ -17,12 +17,12 @@ from ansible_collections.community.docker.plugins.module_utils._util import (
if t.TYPE_CHECKING:
class DAMSpec(t.TypedDict):
class DAMSpec(t.TypedDict): # pragma: no cover
av: dict[str, t.Any]
bv: dict[str, t.Any]
result: bool
class Spec(t.TypedDict):
class Spec(t.TypedDict): # pragma: no cover
a: t.Any
b: t.Any
method: t.Literal["strict", "ignore", "allow_more_present"]

View file

@ -21,11 +21,13 @@ from ..test_support.docker_image_archive_stubbing import (
)
if t.TYPE_CHECKING:
from collections.abc import Callable
from collections.abc import Callable # pragma: no cover
def assert_no_logging(msg: str) -> t.NoReturn:
raise AssertionError(f"Should not have logged anything but logged {msg}")
raise AssertionError(
f"Should not have logged anything but logged {msg}"
) # pragma: no cover
def capture_logging(messages: list[str]) -> Callable[[str], None]:

View file

@ -12,7 +12,8 @@ from ansible_collections.community.docker.plugins.modules import (
docker_swarm_service,
)
APIError = pytest.importorskip("docker.errors.APIError")
docker_errors = pytest.importorskip("docker.errors")
APIError = docker_errors.APIError
def test_retry_on_out_of_sequence_error(mocker: t.Any) -> None:
@ -375,3 +376,79 @@ def test_get_docker_networks() -> None:
docker_swarm_service.get_docker_networks(
[{"name": "test", "nonexisting_option": "foo"}], {"test": "1"}
)
def test_combine_command_args() -> None:
"""command + args combine into a single argv list for CLI-compatible mode."""
combine = docker_swarm_service._combine_command_args
assert combine(None, None) is None
assert combine(["sleep"], ["3600"]) == ["sleep", "3600"]
# Flag-style command alone (issue #1044 / #212)
assert combine(["-config.file=/etc/loki/loki-config.yaml"], None) == [
"-config.file=/etc/loki/loki-config.yaml"
]
assert combine(None, ["--path.rootfs=/host"]) == ["--path.rootfs=/host"]
assert combine(["prometheus"], ["--config.file=a.yml"]) == [
"prometheus",
"--config.file=a.yml",
]
def _make_service(
command: list[str] | None = None,
args: list[str] | None = None,
command_as_args: bool = False,
) -> docker_swarm_service.DockerService:
svc = docker_swarm_service.DockerService(
docker_swarm_service.LooseVersion("1.40"),
docker_swarm_service.LooseVersion("5.0.0"),
)
svc.image = "alpine:latest"
svc.command = command
svc.args = args
svc.command_as_args = command_as_args
return svc
def test_build_container_spec_legacy_command_mapping(mocker: t.Any) -> None:
"""Default command_as_args=false keeps historical Command/Args split."""
captured: dict[str, t.Any] = {}
class FakeContainerSpec:
def __init__(self, image: str, **kwargs: t.Any) -> None:
captured["image"] = image
captured.update(kwargs)
mocker.patch.object(docker_swarm_service.types, "ContainerSpec", FakeContainerSpec)
svc = _make_service(command=["sleep"], args=["3600"], command_as_args=False)
svc.build_container_spec()
assert captured.get("command") == ["sleep"]
assert captured.get("args") == ["3600"]
def test_build_container_spec_command_as_args(mocker: t.Any) -> None:
"""command_as_args=true maps command+args to ContainerSpec.Args only."""
captured: dict[str, t.Any] = {}
class FakeContainerSpec:
def __init__(self, image: str, **kwargs: t.Any) -> None:
captured["image"] = image
captured.update(kwargs)
mocker.patch.object(docker_swarm_service.types, "ContainerSpec", FakeContainerSpec)
svc = _make_service(
command=["-config.file=/etc/loki/loki-config.yaml"],
args=None,
command_as_args=True,
)
svc.build_container_spec()
assert "command" not in captured
assert captured.get("args") == ["-config.file=/etc/loki/loki-config.yaml"]
captured.clear()
svc = _make_service(command=["sleep"], args=["3600"], command_as_args=True)
svc.build_container_spec()
assert "command" not in captured
assert captured.get("args") == ["sleep", "3600"]

View file

@ -1,31 +0,0 @@
#!/usr/bin/env bash
# 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
set -o pipefail -eux
declare -a args
IFS='/:' read -ra args <<< "$1"
image="${args[1]}"
python="${args[2]}"
if [ "${#args[@]}" -gt 3 ]; then
target="azp/${args[3]}/"
else
target="azp/"
fi
if [[ "${python}" =~ -pypi-latest$ ]]; then
python="${python/-pypi-latest}"
echo 'force_docker_sdk_for_python_pypi: true' >> tests/integration/integration_config.yml
fi
if [[ "${python}" =~ -dev-latest$ ]]; then
python="${python/-dev-latest}"
echo 'force_docker_sdk_for_python_dev: true' >> tests/integration/integration_config.yml
fi
# shellcheck disable=SC2086
ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
--docker "quay.io/ansible-community/test-image:${image}" --python "${python}"

View file

@ -1,30 +0,0 @@
#!/usr/bin/env bash
# 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
set -o pipefail -eux
declare -a args
IFS='/:' read -ra args <<< "$1"
image="${args[1]}"
if [ "${#args[@]}" -gt 2 ]; then
target="azp/${args[2]}/"
else
target="azp/"
fi
if [[ "${image}" =~ -pypi-latest$ ]]; then
image="${image/-pypi-latest}"
echo 'force_docker_sdk_for_python_pypi: true' >> tests/integration/integration_config.yml
fi
if [[ "${image}" =~ -dev-latest$ ]]; then
image="${image/-dev-latest}"
echo 'force_docker_sdk_for_python_dev: true' >> tests/integration/integration_config.yml
fi
# shellcheck disable=SC2086
ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
--docker "${image}"

View file

@ -0,0 +1,59 @@
#!/usr/bin/env bash
# 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
set -o pipefail -eux
# Fix for https://github.com/ansible-community/antsibull-nox/issues/222#issuecomment-4778928615
# caused by https://github.com/ansible/azure-pipelines-test-container/blob/7714d81f64f268bbb10779e1265d312128607b76/Containerfile#L4
export PATH="${PATH//:~\//:${HOME}/}"
nox_session="$1"
docker images ansible/ansible
docker images quay.io/ansible/*
docker ps
for container in $(docker ps --format '{{.Image}} {{.ID}}' | grep -v -e '^drydock/' -e '^quay.io/ansible/azure-pipelines-test-container:' | sed 's/^.* //'); do
docker rm -f "${container}" || true # ignore errors
done
docker ps
command -v python
python -V
function retry
{
# shellcheck disable=SC2034
for repetition in 1 2 3; do
set +e
"$@"
result=$?
set -e
if [ ${result} == 0 ]; then
return ${result}
fi
echo "@* -> ${result}"
done
echo "Command '@*' failed 3 times!"
exit 255
}
command -v pip
pip --version
pip list --disable-pip-version-check
retry pip install https://github.com/ansible-community/antsibull-nox/archive/main.tar.gz --disable-pip-version-check
export PYTHONIOENCODING='utf-8'
export FORCE_COLOR=1
export ANTSIBULL_NOX_IGNORE_INSTALLED_COLLECTIONS="true"
if [ "${nox_session}" == "extra-sanity-tests" ]; then
# We need the ansible-galaxy CLI tool to install collection dependencies
retry pip install ansible-core --disable-pip-version-check
nox --verbose --install-only
else
nox --verbose --install-only -e "${nox_session}"
fi

View file

@ -0,0 +1,68 @@
#!/usr/bin/env bash
# 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
set -o pipefail -eux
# Fix for https://github.com/ansible-community/antsibull-nox/issues/222#issuecomment-4778928615
# caused by https://github.com/ansible/azure-pipelines-test-container/blob/7714d81f64f268bbb10779e1265d312128607b76/Containerfile#L4
export PATH="${PATH//:~\//:${HOME}/}"
nox_session="$1"
export PYTHONIOENCODING='utf-8'
if [ -n "${COVERAGE:-}" ]; then
# on-demand coverage reporting triggered by setting the COVERAGE environment variable to a non-empty value
export COVERAGE="--coverage"
elif [[ "${COMMIT_MESSAGE}" =~ ci_coverage ]]; then
# on-demand coverage reporting triggered by having 'ci_coverage' in the latest commit message
export COVERAGE="--coverage"
else
# on-demand coverage reporting disabled (default behavior, always-on coverage reporting remains enabled)
export COVERAGE="--coverage-check"
fi
if [ -n "${COMPLETE:-}" ]; then
# disable change detection triggered by setting the COMPLETE environment variable to a non-empty value
export ANTSIBULL_CHANGE_DETECTION=""
elif [[ "${COMMIT_MESSAGE}" =~ ci_complete ]]; then
# disable change detection triggered by having 'ci_complete' in the latest commit message
export ANTSIBULL_CHANGE_DETECTION=""
elif [ "${IS_PULL_REQUEST:-}" == "true" ]; then
# enable change detection for PRs (default behavior)
export ANTSIBULL_CHANGE_DETECTION="true"
export ANTSIBULL_BASE_BRANCH="${SYSTEM_PULLREQUEST_TARGETBRANCH}"
# Create a branch for the current HEAD, which happens to be a merge commit
git checkout -b "pull-request-branch"
# Name the target branch
git branch "${SYSTEM_PULLREQUEST_TARGETBRANCH}" --track "origin/${SYSTEM_PULLREQUEST_TARGETBRANCH}"
# Show branches
git branch -vv
else
# disable change detection for pushes and scheduled runs
export ANTSIBULL_CHANGE_DETECTION=""
fi
if [[ "${COVERAGE:-}" == "--coverage" ]]; then
export ANTSIBULL_NOX_TIMEOUT=60
else
export ANTSIBULL_NOX_TIMEOUT=50
fi
if [ "${IS_PULL_REQUEST:-}" == "true" ]; then
export ANTSIBULL_NOX_INTEGRATION_ALLOW_UNSTABLE_CHANGED="true"
fi
export FORCE_COLOR=1
export ANTSIBULL_NOX_IGNORE_INSTALLED_COLLECTIONS="true"
export ANTSIBULL_NOX_COVERAGE_DESTINATION="${COVERAGE_DESTINATION_DIRECTORY}"
export ANTSIBULL_NOX_COVERAGE_ANALYSIS_FILE="${COVERAGE_DESTINATION_DIRECTORY}/coverage-analyze-targets.json"
export ANTSIBULL_NOX_COVERAGE_NO_XML="true"
if [ "${nox_session}" == "extra-sanity-tests" ]; then
nox --reuse-existing-virtualenvs --no-install
else
nox --reuse-existing-virtualenvs --no-install -e "${nox_session}" -- ${COVERAGE}
fi

View file

@ -1,48 +0,0 @@
#!/usr/bin/env bash
# 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
set -o pipefail -eux
declare -a args
IFS='/:' read -ra args <<< "$1"
platform="${args[0]}"
version="${args[1]}"
pyver=default
# check for explicit python version like 8.3@3.8
declare -a splitversion
IFS='@' read -ra splitversion <<< "$version"
if [ "${#splitversion[@]}" -gt 1 ]; then
version="${splitversion[0]}"
pyver="${splitversion[1]}"
fi
if [ "${#args[@]}" -gt 2 ]; then
target="azp/${args[2]}/"
else
target="azp/"
fi
if [[ "${version}" =~ -pypi-latest$ ]]; then
version="${version/-pypi-latest}"
echo 'force_docker_sdk_for_python_pypi: true' >> tests/integration/integration_config.yml
fi
if [[ "${version}" =~ -dev-latest$ ]]; then
version="${version/-dev-latest}"
echo 'force_docker_sdk_for_python_dev: true' >> tests/integration/integration_config.yml
fi
stage="${S:-prod}"
provider="${P:-default}"
if [ "${platform}" == "rhel" ] && [[ "${version}" =~ ^8\. ]]; then
echo "pynacl >= 1.4.0, < 1.5.0; python_version == '3.6'" >> tests/utils/constraints.txt
fi
# shellcheck disable=SC2086
ansible-test integration --color -v --retry-on-error "${target}" ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} ${UNSTABLE:+"$UNSTABLE"} \
--python "${pyver}" --remote "${platform}/${version}" --remote-terminate always --remote-stage "${stage}" --remote-provider "${provider}"

View file

@ -1,17 +0,0 @@
#!/usr/bin/env bash
# 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
set -o pipefail -eux
if [ "${BASE_BRANCH:-}" ]; then
base_branch="origin/${BASE_BRANCH}"
else
base_branch=""
fi
# shellcheck disable=SC2086
ansible-test sanity --color -v --junit ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \
--docker --base-branch "${base_branch}" \
--allow-disabled

View file

@ -1,234 +0,0 @@
#!/usr/bin/env bash
# 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
set -o pipefail -eux
declare -a args
IFS='/:' read -ra args <<< "$1"
ansible_version="${args[0]}"
script="${args[1]}"
after_script="${args[2]}"
function join {
local IFS="$1";
shift;
echo "$*";
}
# Ensure we can write other collections to this dir
sudo chown -R "$(whoami)" "${PWD}/../../../"
test="$(join / "${args[@]:1}")"
docker images ansible/ansible
docker images quay.io/ansible/*
docker ps
for container in $(docker ps --format '{{.Image}} {{.ID}}' | grep -v -e '^drydock/' -e '^quay.io/ansible/azure-pipelines-test-container:' | sed 's/^.* //'); do
docker rm -f "${container}" || true # ignore errors
done
docker ps
if [ -d /home/shippable/cache/ ]; then
ls -la /home/shippable/cache/
fi
command -v python
python -V
function retry
{
# shellcheck disable=SC2034
for repetition in 1 2 3; do
set +e
"$@"
result=$?
set -e
if [ ${result} == 0 ]; then
return ${result}
fi
echo "@* -> ${result}"
done
echo "Command '@*' failed 3 times!"
exit 255
}
command -v pip
pip --version
pip list --disable-pip-version-check
if [ "${ansible_version}" == "devel" ]; then
retry pip install https://github.com/ansible/ansible/archive/devel.tar.gz --disable-pip-version-check
else
retry pip install "https://github.com/ansible/ansible/archive/stable-${ansible_version}.tar.gz" --disable-pip-version-check
fi
export ANSIBLE_COLLECTIONS_PATHS="${PWD}/../../../"
# START: HACK
COMMUNITY_CRYPTO_BRANCH=main
if [ "${ansible_version}" == "2.16" ]; then
COMMUNITY_CRYPTO_BRANCH=stable-2
fi
if [ "${script}" == "linux" ] && [ "$after_script" == "ubuntu2004" ]; then
COMMUNITY_CRYPTO_BRANCH=stable-2
fi
retry git clone --depth=1 --single-branch --branch stable-1 https://github.com/ansible-collections/community.library_inventory_filtering.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/community/library_inventory_filtering_v1"
# NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429)
# retry ansible-galaxy -vvv collection install community.library_inventory_filtering_v1
if [ "${test}" == "units/1" ]; then
# Nothing further should be added to this list.
# This is to prevent modules or plugins in this collection having a runtime dependency on other collections.
retry git clone --depth=1 --single-branch https://github.com/ansible-collections/community.internal_test_tools.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/community/internal_test_tools"
# NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429)
# retry ansible-galaxy -vvv collection install community.internal_test_tools
fi
if [ "${script}" != "sanity/1" ] && [ "${script}" != "units/1" ]; then
# To prevent Python dependencies on other collections only install other collections for integration tests
retry git clone --depth=1 --single-branch https://github.com/ansible-collections/ansible.posix.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/ansible/posix"
retry git clone --depth=1 --single-branch --branch "${COMMUNITY_CRYPTO_BRANCH}" https://github.com/ansible-collections/community.crypto.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/community/crypto"
retry git clone --depth=1 --single-branch https://github.com/ansible-collections/community.general.git "${ANSIBLE_COLLECTIONS_PATHS}/ansible_collections/community/general"
# NOTE: we're installing with git to work around Galaxy being a huge PITA (https://github.com/ansible/galaxy/issues/2429)
# retry ansible-galaxy -vvv collection install ansible.posix
# retry ansible-galaxy -vvv collection install community.crypto
# retry ansible-galaxy -vvv collection install community.general
fi
# END: HACK
export PYTHONIOENCODING='utf-8'
if [ "${JOB_TRIGGERED_BY_NAME:-}" == "nightly-trigger" ]; then
COVERAGE=yes
COMPLETE=yes
fi
if [ -n "${COVERAGE:-}" ]; then
# on-demand coverage reporting triggered by setting the COVERAGE environment variable to a non-empty value
export COVERAGE="--coverage"
elif [[ "${COMMIT_MESSAGE}" =~ ci_coverage ]]; then
# on-demand coverage reporting triggered by having 'ci_coverage' in the latest commit message
export COVERAGE="--coverage"
else
# on-demand coverage reporting disabled (default behavior, always-on coverage reporting remains enabled)
export COVERAGE="--coverage-check"
fi
if [ -n "${COMPLETE:-}" ]; then
# disable change detection triggered by setting the COMPLETE environment variable to a non-empty value
export CHANGED=""
elif [[ "${COMMIT_MESSAGE}" =~ ci_complete ]]; then
# disable change detection triggered by having 'ci_complete' in the latest commit message
export CHANGED=""
else
# enable change detection (default behavior)
export CHANGED="--changed"
fi
if [ "${IS_PULL_REQUEST:-}" == "true" ]; then
# run unstable tests which are targeted by focused changes on PRs
export UNSTABLE="--allow-unstable-changed"
else
# do not run unstable tests outside PRs
export UNSTABLE=""
fi
# remove empty core/extras module directories from PRs created prior to the repo-merge
find plugins -type d -empty -print -delete
function cleanup
{
# for complete on-demand coverage generate a report for all files with no coverage on the "sanity/5" job so we only have one copy
if [ "${COVERAGE}" == "--coverage" ] && [ "${CHANGED}" == "" ] && [ "${test}" == "sanity/5" ]; then
stub="--stub"
# trigger coverage reporting for stubs even if no other coverage data exists
mkdir -p tests/output/coverage/
else
stub=""
fi
if [ -d tests/output/coverage/ ]; then
if find tests/output/coverage/ -mindepth 1 -name '.*' -prune -o -print -quit | grep -q .; then
process_coverage='yes' # process existing coverage files
elif [ "${stub}" ]; then
process_coverage='yes' # process coverage when stubs are enabled
else
process_coverage=''
fi
if [ "${process_coverage}" ]; then
# use python 3.7 for coverage to avoid running out of memory during coverage xml processing
# only use it for coverage to avoid the additional overhead of setting up a virtual environment for a potential no-op job
virtualenv --python /usr/bin/python3.7 ~/ansible-venv
set +ux
. ~/ansible-venv/bin/activate
set -ux
# shellcheck disable=SC2086
ansible-test coverage xml --color -v --requirements --group-by command --group-by version ${stub:+"$stub"}
cp -a tests/output/reports/coverage=*.xml "$SHIPPABLE_RESULT_DIR/codecoverage/"
if [ "${ansible_version}" != "2.9" ]; then
# analyze and capture code coverage aggregated by integration test target
ansible-test coverage analyze targets generate -v "$SHIPPABLE_RESULT_DIR/testresults/coverage-analyze-targets.json"
fi
# upload coverage report to codecov.io only when using complete on-demand coverage
if [ "${COVERAGE}" == "--coverage" ] && [ "${CHANGED}" == "" ]; then
for file in tests/output/reports/coverage=*.xml; do
flags="${file##*/coverage=}"
flags="${flags%-powershell.xml}"
flags="${flags%.xml}"
# remove numbered component from stub files when converting to tags
flags="${flags//stub-[0-9]*/stub}"
flags="${flags//=/,}"
flags="${flags//[^a-zA-Z0-9_,]/_}"
bash <(curl -s https://ansible-ci-files.s3.us-east-1.amazonaws.com/codecov/codecov.sh) \
-f "${file}" \
-F "${flags}" \
-n "${test}" \
-t 8450ed26-4e94-4d07-8831-d2023d6d20a3 \
-X coveragepy \
-X gcov \
-X fix \
-X search \
-X xcode \
|| echo "Failed to upload code coverage report to codecov.io: ${file}"
done
fi
fi
fi
if [ -d tests/output/junit/ ]; then
cp -aT tests/output/junit/ "$SHIPPABLE_RESULT_DIR/testresults/"
fi
if [ -d tests/output/data/ ]; then
cp -a tests/output/data/ "$SHIPPABLE_RESULT_DIR/testresults/"
fi
if [ -d tests/output/bot/ ]; then
cp -aT tests/output/bot/ "$SHIPPABLE_RESULT_DIR/testresults/"
fi
}
if [ "${SHIPPABLE_BUILD_ID:-}" ]; then trap cleanup EXIT; fi
if [[ "${COVERAGE:-}" == "--coverage" ]]; then
timeout=60
else
timeout=50
fi
ansible-test env --dump --show --timeout "${timeout}" --color -v
if [ "${SHIPPABLE_BUILD_ID:-}" ]; then "tests/utils/shippable/check_matrix.py"; fi
"tests/utils/shippable/${script}.sh" "${test}"

View file

@ -1,29 +0,0 @@
#!/usr/bin/env bash
# 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
set -o pipefail -eux
declare -a args
IFS='/:' read -ra args <<< "$1"
group="${args[1]}"
if [[ "${COVERAGE:-}" == "--coverage" ]]; then
timeout=90
else
timeout=30
fi
group1=()
case "${group}" in
1) options=("${group1[@]:+${group1[@]}}") ;;
esac
ansible-test env --timeout "${timeout}" --color -v
# shellcheck disable=SC2086
ansible-test units --color -v --docker default ${COVERAGE:+"$COVERAGE"} ${CHANGED:+"$CHANGED"} \
"${options[@]:+${options[@]}}" \