Debian Codegraph @

ansible_collections/community/docker/tests/integration/targets/docker_network/tasks/main.yml

raw
1 ---
2 # Copyright (c) Ansible Project
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)
4 # SPDX-License-Identifier: GPL-3.0-or-later
5
6 ####################################################################
7 # WARNING: These are designed specifically for Ansible tests #
8 # and should not be used as examples of how to write Ansible roles #
9 ####################################################################
10
11 - name: List inspection results for all docker networks
12 community.docker.docker_host_info:
13 networks: true
14 verbose_output: true
15 register: all_networks
16
17 - name: Show inspection results for all docker networks
18 ansible.builtin.debug:
19 var: all_networks.networks
20
21 - name: Create random name prefix
22 ansible.builtin.set_fact:
23 name_prefix: "{{ 'ansible-docker-test-%0x' % ((2**32) | random) }}"
24 cnames: []
25 dnetworks: []
26
27 - ansible.builtin.debug:
28 msg: "Using name prefix {{ name_prefix }}"
29
30 - block:
31 - ansible.builtin.include_tasks: run-test.yml
32 with_fileglob:
33 - "tests/*.yml"
34 loop_control:
35 loop_var: test_name
36
37 always:
38 - name: "Make sure all containers are removed"
39 community.docker.docker_container:
40 name: "{{ item }}"
41 state: absent
42 force_kill: true
43 loop: "{{ cnames }}"
44 - name: "Make sure all networks are removed"
45 community.docker.docker_network:
46 name: "{{ item }}"
47 state: absent
48 force: true
49 loop: "{{ dnetworks }}"
50
51 when: docker_api_version is version('1.25', '>=') # FIXME: find out API version!
52
53 - ansible.builtin.fail: msg="Too old docker / docker-py version to run docker_network tests!"
54 when: not(docker_api_version is version('1.25', '>=')) and (ansible_facts.distribution != 'CentOS' or ansible_facts.distribution_major_version|int > 6)