-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathhttp.yml
82 lines (71 loc) · 2 KB
/
http.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
77
78
79
80
81
82
---
- name: start HTTP server
hosts: server
vars:
server_port: "{{ server.port }}"
gather_facts: true
tasks:
- name: upload the index.html
template:
src: templates/index.html.j2
dest: /root/index.html
mode: 0644
owner: root
group: root
become: true
- name: start busybox based HTTP server
shell: nohup busybox httpd -f -p "{{ server_port }}" 0<&- &> /tmp/script.log &
register: result
changed_when: false
become: true
- name: print out the result
debug: var=result
delegate_to: local
- name: HTTP connection between two droplets
hosts: client
vars:
server_port: "{{ server.port }}"
timeout: 3
debug: false
gather_facts: false
tasks:
- name: check the HTTP reachability (IPv4)
uri:
url: "http://{{ server.ipv4 }}:{{ server_port }}"
timeout: "{{ timeout }}"
register: result
ignore_errors: "{{ debug }}"
- name: print out the result
debug: var=result
- name: check the HTTP reachability (private IPv4)
uri:
url: "http://{{ server.ipv4_private }}:{{ server_port }}"
timeout: "{{ timeout }}"
register: result
ignore_errors: "{{ debug }}"
- name: print out the result
debug: var=result
- name: check the HTTP reachability (IPv6)
uri:
url: "http://[{{ server.ipv6 }}]:{{ server_port }}"
timeout: "{{ timeout }}"
register: result
ignore_errors: "{{ debug }}"
- name: print out the result
debug: var=result
- name: check the HTTP reachability (Floating IP)
uri:
url: "http://{{ server.flip }}:{{ server_port }}"
timeout: "{{ timeout }}"
register: result
ignore_errors: "{{ debug }}"
- name: print out the result
debug: var=result
- name: stop HTTP server
hosts: server
gather_facts: false
tasks:
- name: stop busybox based httpd server
command: killall busybox
changed_when: false
become: true