-
Notifications
You must be signed in to change notification settings - Fork 2
/
udp.yml
76 lines (65 loc) · 2.17 KB
/
udp.yml
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
---
- name: start UDP server
hosts: server
vars:
server_port: "{{ server.port }}"
gather_facts: false
become: true
tasks:
- name: start ncat as UDP server
shell: ncat -u -k -c 'echo hello' -l "{{ server_port }}" &
register: result
changed_when: false
- name: print out the result
debug: var=result
- name: UDP connection between two droplets
hosts: client
vars:
server_port: "{{ server.port }}"
timeout: 3
debug: false
gather_facts: false
become: true
tasks:
- name: check the UDP port reachability (IPv4)
shell: nc -4 -v -u -w "{{ timeout }}" "{{ server.ipv4 }}" "{{ server_port }}" 2>/dev/null
register: result
changed_when: false
failed_when: "result.rc != 0 or 'hello' not in result.stdout"
ignore_errors: "{{ debug }}"
- name: print out the result
debug: var=result
- name: check the UDP port reachability (private IPv4)
shell: nc -4 -v -u -w "{{ timeout }}" "{{ server.ipv4_private }}" "{{ server_port }}" 2>/dev/null
register: result
changed_when: false
failed_when: "result.rc != 0 or 'hello' not in result.stdout"
ignore_errors: "{{ debug }}"
- name: print out the result
debug: var=result
- name: check the UDP port reachability (IPv6)
shell: nc -6 -v -u -w "{{ timeout }}" "{{ server.ipv6 }}" "{{ server_port }}" 2>/dev/null
register: result
changed_when: false
failed_when: "result.rc != 0 or 'hello' not in result.stdout"
ignore_errors: "{{ debug }}"
- name: print out the result
debug: var=result
- name: check the UDP port reachability (Floating IP)
shell: nc -4 -v -u -w "{{ timeout }}" "{{ server.flip }}" "{{ server_port }}" 2>/dev/null
register: result
changed_when: false
failed_when: "result.rc != 0 or 'hello' not in result.stdout"
ignore_errors: true
- name: print out the result
debug: var=result
- fail: msg="finish the test without stopping the UDP server"
when: debug
- name: stop UDP server
hosts: server
gather_facts: false
become: true
tasks:
- name: stop ncat
command: killall ncat
changed_when: false