Skip to content

Commit e4b97c2

Browse files
committed
chore(examples/config/haproxy): Create haproxy example
1 parent 88e9511 commit e4b97c2

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed
+60
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
meta:
2+
schema_version: 2
3+
hosts:
4+
proxy:
5+
- ssh_target: [email protected]
6+
backends:
7+
- ssh_target: [email protected]
8+
vars:
9+
backend: test2.sikademo.com
10+
msg: Gobble 2
11+
- ssh_target: [email protected]
12+
vars:
13+
backend: test3.sikademo.com
14+
msg: Gobble 3
15+
- ssh_target: [email protected]
16+
vars:
17+
backend: test4.sikademo.com
18+
msg: Gobble 4
19+
plays:
20+
- name: Proxy
21+
hosts: [proxy]
22+
tasks:
23+
- name: Install HAProxy
24+
apt_install:
25+
name: haproxy
26+
- name: Config HAProxy
27+
templete:
28+
path: /etc/haproxy/haproxy.cfg
29+
template: |
30+
defaults
31+
mode http
32+
timeout client 10s
33+
timeout connect 5s
34+
timeout server 10s
35+
timeout http-request 10s
36+
37+
frontend http
38+
bind 0.0.0.0:80
39+
default_backend http
40+
41+
backend http
42+
{{ range $i, $server := .Config.Hosts.backends }}
43+
server backend{{$i}} {{$server.Vars.backend}}:80
44+
{{ end }}
45+
- name: Restart HAProxy
46+
command:
47+
cmd: service haproxy restart
48+
- name: Backends
49+
hosts: [backends]
50+
tasks:
51+
- name: Install Nginx
52+
apt_install:
53+
name: nginx
54+
- name: Create index.html
55+
templete:
56+
path: /var/www/html/index.html
57+
template: <h1>Gobble {{.Vars.msg}}</h1>{{ printf "\n" }}
58+
- name: Start Nginx
59+
command:
60+
cmd: service nginx start

0 commit comments

Comments
 (0)