mirror of https://github.com/ansible/ansible.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.6 KiB
YAML
61 lines
1.6 KiB
YAML
6 years ago
|
---
|
||
|
- block:
|
||
|
- name: Create random network name
|
||
|
set_fact:
|
||
|
nname: "{{ 'ansible-test-%0x' % ((2**32) | random) }}"
|
||
|
|
||
|
- name: Make sure network is not there
|
||
|
docker_network:
|
||
|
name: "{{ nname }}"
|
||
|
state: absent
|
||
|
force: yes
|
||
|
|
||
|
- name: Inspect a non-present network
|
||
6 years ago
|
docker_network_info:
|
||
6 years ago
|
name: "{{ nname }}"
|
||
|
register: result
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- "not result.exists"
|
||
6 years ago
|
- "'network' in result"
|
||
|
- "result.network is none"
|
||
6 years ago
|
|
||
|
- name: Make sure network exists
|
||
|
docker_network:
|
||
|
name: "{{ nname }}"
|
||
|
state: present
|
||
|
|
||
|
- name: Inspect a present network
|
||
6 years ago
|
docker_network_info:
|
||
6 years ago
|
name: "{{ nname }}"
|
||
|
register: result
|
||
6 years ago
|
- name: Dump docker_network_info result
|
||
6 years ago
|
debug: var=result
|
||
|
|
||
|
- name: "Comparison: use 'docker network inspect'"
|
||
|
command: docker network inspect "{{ nname }}"
|
||
|
register: docker_inspect
|
||
|
- set_fact:
|
||
|
docker_inspect_result: "{{ docker_inspect.stdout | from_json }}"
|
||
|
- name: Dump docker inspect result
|
||
|
debug: var=docker_inspect_result
|
||
|
|
||
|
- name: Cleanup
|
||
|
docker_network:
|
||
|
name: "{{ nname }}"
|
||
|
state: absent
|
||
|
force: yes
|
||
|
|
||
|
- assert:
|
||
|
that:
|
||
|
- result.exists
|
||
6 years ago
|
- "'network' in result"
|
||
|
- "result.network"
|
||
|
- "result.network == docker_inspect_result[0]"
|
||
6 years ago
|
|
||
|
when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.21', '>=')
|
||
|
|
||
6 years ago
|
- fail: msg="Too old docker / docker-py version to run docker_network_info tests!"
|
||
6 years ago
|
when: not(docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.21', '>=')) and (ansible_distribution != 'CentOS' or ansible_distribution_major_version|int > 6)
|