mirror of
https://github.com/ansible-collections/community.general.git
synced 2024-09-14 20:13:21 +02:00
c563caf451
* Fix version checks in tests * Set minimum version to 2.0.2 * Networks can only be updated >= docker-py 2.7 * Constraints require docker-py 2.4.0 * Healthchecks require docker-py 2.6.0 * Properly run tests different docker_py_versions * Add changelog fragment * Specify lowest version on placement.constraints * Fix running new tests on older docker-py * Handle different hosts formats returned by docker * FIx test naming * Quote str options * secrets options require docker-py 2.4.0
75 lines
2.1 KiB
YAML
75 lines
2.1 KiB
YAML
---
|
|
|
|
# Create random name prefix (for containers, networks, ...)
|
|
- name: Create random name prefix
|
|
set_fact:
|
|
name_prefix: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
|
|
service_names: []
|
|
network_names: []
|
|
config_names: []
|
|
secret_names: []
|
|
volume_names: []
|
|
|
|
- debug:
|
|
msg: "Using container name prefix {{ name_prefix }}"
|
|
|
|
# Run the tests
|
|
- block:
|
|
- name: Create a Swarm cluster
|
|
docker_swarm:
|
|
state: present
|
|
advertise_addr: "{{ansible_default_ipv4.address}}"
|
|
|
|
- include_tasks: run-test.yml
|
|
with_fileglob:
|
|
- "tests/*.yml"
|
|
|
|
always:
|
|
- name: Make sure all services are removed
|
|
docker_swarm_service:
|
|
name: "{{ item }}"
|
|
state: absent
|
|
loop: "{{ service_names }}"
|
|
ignore_errors: yes
|
|
|
|
- name: Make sure all networks are removed
|
|
docker_network:
|
|
name: "{{ item }}"
|
|
state: absent
|
|
force: yes
|
|
loop: "{{ network_names }}"
|
|
ignore_errors: yes
|
|
|
|
- name: Make sure all configs are removed
|
|
docker_config:
|
|
name: "{{ item }}"
|
|
state: absent
|
|
force: yes
|
|
loop: "{{ config_names }}"
|
|
ignore_errors: yes
|
|
|
|
- name: Make sure all volumes are removed
|
|
docker_volume:
|
|
name: "{{ item }}"
|
|
state: absent
|
|
loop: "{{ volume_names }}"
|
|
ignore_errors: yes
|
|
|
|
- name: Make sure all secrets are removed
|
|
docker_secret:
|
|
name: "{{ item }}"
|
|
state: absent
|
|
force: yes
|
|
loop: "{{ secret_names }}"
|
|
ignore_errors: yes
|
|
|
|
- name: Make sure swarm is removed
|
|
docker_swarm:
|
|
state: absent
|
|
force: yes
|
|
ignore_errors: yes
|
|
# Maximum of 1.24 (docker API version for docker_swarm_service) and 1.25 (docker API version for docker_swarm) is 1.25
|
|
when: docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')
|
|
|
|
- fail: msg="Too old docker / docker-py version to run docker_swarm_service tests!"
|
|
when: not(docker_py_version is version('2.0.2', '>=') and docker_api_version is version('1.25', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
|