summaryrefslogtreecommitdiff
path: root/test/integration/targets/docker_network_info/tasks/main.yml
blob: f8bce0ebcccae070b466b7854155da4c7c6c491a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
---
- 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
    docker_network_info:
      name: "{{ nname }}"
    register: result

  - assert:
      that:
      - "not result.exists"
      - "'network' in result"
      - "result.network is none"

  - name: Make sure network exists
    docker_network:
      name: "{{ nname }}"
      state: present

  - name: Inspect a present network
    docker_network_info:
      name: "{{ nname }}"
    register: result
  - name: Dump docker_network_info result
    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
      - "'network' in result"
      - "result.network"
      - "result.network == docker_inspect_result[0]"

  when: docker_py_version is version('1.8.0', '>=') and docker_api_version is version('1.21', '>=')

- fail: msg="Too old docker / docker-py version to run docker_network_info tests!"
  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)