]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-ansible.git/commitdiff
Initial add of haproxy example for fronting a number of radosgw's
authorJimmy Tang <jcftang@gmail.com>
Fri, 14 Mar 2014 09:50:31 +0000 (09:50 +0000)
committerJimmy Tang <jcftang@gmail.com>
Sat, 15 Mar 2014 08:58:24 +0000 (08:58 +0000)
roles/haproxy/files/precise/haproxy [new file with mode: 0644]
roles/haproxy/handlers/main.yml [new file with mode: 0644]
roles/haproxy/handlers/precise.yml [new file with mode: 0644]
roles/haproxy/tasks/main.yml [new file with mode: 0644]
roles/haproxy/tasks/precise.yml [new file with mode: 0644]
roles/haproxy/templates/precise/haproxy.cfg [new file with mode: 0644]

diff --git a/roles/haproxy/files/precise/haproxy b/roles/haproxy/files/precise/haproxy
new file mode 100644 (file)
index 0000000..9a2ee79
--- /dev/null
@@ -0,0 +1,4 @@
+# Set ENABLED to 1 if you want the init script to start haproxy.
+ENABLED=1
+# Add extra flags here.
+#EXTRAOPTS="-de -m 16"
diff --git a/roles/haproxy/handlers/main.yml b/roles/haproxy/handlers/main.yml
new file mode 100644 (file)
index 0000000..ab341cc
--- /dev/null
@@ -0,0 +1,6 @@
+---
+## Check distribution release
+#
+
+- include: precise.yml
+  when: ansible_distribution == 'precise'
diff --git a/roles/haproxy/handlers/precise.yml b/roles/haproxy/handlers/precise.yml
new file mode 100644 (file)
index 0000000..2de15f4
--- /dev/null
@@ -0,0 +1,3 @@
+---
+- name: restart haproxy
+  service: name=haproxy state=restarted
diff --git a/roles/haproxy/tasks/main.yml b/roles/haproxy/tasks/main.yml
new file mode 100644 (file)
index 0000000..ab341cc
--- /dev/null
@@ -0,0 +1,6 @@
+---
+## Check distribution release
+#
+
+- include: precise.yml
+  when: ansible_distribution == 'precise'
diff --git a/roles/haproxy/tasks/precise.yml b/roles/haproxy/tasks/precise.yml
new file mode 100644 (file)
index 0000000..a4312e0
--- /dev/null
@@ -0,0 +1,15 @@
+---
+- apt_repository: repo=ppa:vbernat/haproxy-1.5 state=present
+
+- apt: name={{item}} state=present
+  with_items:
+   - haproxy
+   - socat
+
+- copy: src=precise/haproxy dest=/etc/default/haproxy
+  notify: restart haproxy
+
+- template: src=precise/haproxy.cfg dest=/etc/haproxy/haproxy.cfg backup=yes
+  notify: restart haproxy
+
+- service: name=haproxy state=started enabled=yes
diff --git a/roles/haproxy/templates/precise/haproxy.cfg b/roles/haproxy/templates/precise/haproxy.cfg
new file mode 100644 (file)
index 0000000..b737ddf
--- /dev/null
@@ -0,0 +1,58 @@
+#
+# {{ ansible_managed }}
+#
+global
+       log /dev/log    local0
+       log /dev/log    local1 notice
+       chroot /var/lib/haproxy
+       user haproxy
+       group haproxy
+    daemon
+    stats socket /var/lib/haproxy/stats level admin
+
+defaults
+       log     global
+    mode       http
+    option     httplog
+    option     dontlognull
+    contimeout 5000
+    clitimeout 50000
+    srvtimeout 50000
+       errorfile 400 /etc/haproxy/errors/400.http
+       errorfile 403 /etc/haproxy/errors/403.http
+       errorfile 408 /etc/haproxy/errors/408.http
+       errorfile 500 /etc/haproxy/errors/500.http
+       errorfile 502 /etc/haproxy/errors/502.http
+       errorfile 503 /etc/haproxy/errors/503.http
+       errorfile 504 /etc/haproxy/errors/504.http
+
+frontend http_frontend
+       bind *:80
+       mode http
+       option httpclose
+       option forwardfor
+       default_backend web_server
+
+frontend https_frontend
+       bind *:443 ssl crt /etc/ceph/radosgw-key-cert.pem
+       mode http
+       option httpclose
+       option forwardfor
+       reqadd X-Forwarded-Proto:\ https
+       default_backend web_server
+
+backend web_server
+       mode http
+       balance roundrobin
+       cookie RADOSGWLB insert indirect nocache
+{% for host in groups['rgws'] %}
+       server {{ hostvars[host].ansible_hostname }} {{ hostvars[host]['ansible_eth0'].ipv4.address }}:80 check cookie {{ hostvars[host].ansible_hostname }}
+{% endfor %}
+
+listen stats :8080
+    mode http
+    stats enable
+    stats hide-version
+    stats realm Haproxy\ Statistics
+    stats uri /
+#stats auth Username:Password