Skip to content

Commit

Permalink
Merged pull requests
Browse files Browse the repository at this point in the history
  • Loading branch information
Juergen WAIBEL committed Nov 2, 2015
1 parent c35fd33 commit a5f8887
Show file tree
Hide file tree
Showing 9 changed files with 70 additions and 28 deletions.
2 changes: 2 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,7 @@ haproxy_defaults:
file: /etc/haproxy/errors/500.http
- code: 502
file: /etc/haproxy/errors/502.http
- code: 503
file: /etc/haproxy/errors/503.http
- code: 504
file: /etc/haproxy/errors/504.http
4 changes: 4 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
template: src=defaults.cfg dest={{ etc_prefix }}/haproxy/compiled/02-defaults.cfg
when: haproxy_defaults is defined

- name: 'Build the web stats config'
template: src=web_stats.cfg dest={{ etc_prefix }}/haproxy/compiled/07-web_stats.cfg
when: haproxy_web_stats is defined

## ASSEMBLE FINAL CONFIG

- name: 'Assemble the backends configuration file'
Expand Down
13 changes: 9 additions & 4 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,17 @@
- socat
when: ansible_os_family == 'RedHat'

- name: 'Add haproxy apt repo'
- name: 'Add haproxy apt repo (squeeze)'
sudo: yes
apt_repository: repo="deb http://http.debian.net/debian wheezy-backports main" state=present update_cache=yes
when: ansible_distribution_release == "wheezy"
apt_repository: repo="deb http://http.debian.net/debian squeeze-backports-sloppy main" state=present update_cache=yes
when: ansible_distribution_release == "squeeze"

- name: 'Add haproxy apt repo'
- name: 'Add haproxy apt repo (wheezy/jessie)'
sudo: yes
apt_repository: repo="deb http://http.debian.net/debian {{ ansible_distribution_release}}-backports main" state=present update_cache=yes
when: ansible_distribution_release == "wheezy" or ansible_distribution_release == "jessie"

- name: 'Add haproxy apt repo (Ubuntu)'
sudo: yes
apt_repository: repo="ppa:vbernat/haproxy-1.5" state=present update_cache=yes
when: ansible_distribution == "Ubuntu"
Expand Down
5 changes: 5 additions & 0 deletions templates/backend.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,8 @@ backend {{ item.name }}
option {{ option }}
{% endfor %}
{% endif -%}
{% if item.timeout is defined -%}
{% for entry in item.timeout %}
timeout {{ entry.param }} {{ entry.value }}
{% endfor %}
{% endif -%}
20 changes: 0 additions & 20 deletions templates/defaults.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -24,26 +24,6 @@ defaults
{% if haproxy_defaults.maxconn is defined -%}
maxconn {{ haproxy_defaults.maxconn }}
{% endif -%}
{% if haproxy_defaults.stats is defined %}
{% if haproxy_defaults.stats.enabled is defined and haproxy_defaults.stats.enabled == True %}
stats enable
{% endif -%}
{% if haproxy_defaults.stats.hide_version is defined and haproxy_defaults.stats.hide_version == true %}
stats hide-version
{% endif -%}
{% if haproxy_defaults.stats.uri is defined %}
stats uri {{ haproxy_defaults.stats.uri }}
{% endif -%}
{% if haproxy_defaults.stats.realm is defined %}
stats realm {{ haproxy_defaults.stats.realm }}
{% endif -%}
{% if haproxy_defaults.stats.auth is defined %}
stats auth {{ haproxy_defaults.stats.auth }}
{% endif -%}
{% if haproxy_defaults.stats.refresh is defined %}
stats refresh {{ haproxy_defaults.stats.refresh }}
{% endif -%}
{% endif %}
{% if haproxy_defaults.options is defined %}
{% for option in haproxy_defaults.options %}
option {{ option }}
Expand Down
12 changes: 9 additions & 3 deletions templates/frontend.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ frontend {{ item.name }} {%if item.ip is defined %}{{ item.ip }}{% endif %}{%if
maxconn {{ item.maxconn }}
{% endif -%}

{% if item.timeout is defined -%}
{% for entry in item.timeout %}
timeout {{ entry.param }} {{ entry.value }}
{% endfor %}
{% endif -%}

{%- if item.monitor is defined -%}
{% if item.monitor.uri is defined -%}
monitor-uri {{ item.monitor.uri }}
Expand All @@ -30,7 +36,7 @@ frontend {{ item.name }} {%if item.ip is defined %}{{ item.ip }}{% endif %}{%if
{%- if item.acl is defined -%}
{%- for acl in item.acl -%}
acl {{ acl.name }} {{ acl.condition }}
{% endfor %}
{% endfor -%}
{% endif -%}

{%- if item.reqadd is defined -%}
Expand Down Expand Up @@ -83,8 +89,8 @@ frontend {{ item.name }} {%if item.ip is defined %}{{ item.ip }}{% endif %}{%if
{% endif -%}

{%- if item.use_backend is defined -%}
{% for backend in item.use_backend %}
{%- for backend in item.use_backend %}
use_backend {{ backend.name }} {{ backend.condition }}
{% endfor %}
{% endfor -%}
{% endif -%}

6 changes: 6 additions & 0 deletions templates/listen.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,9 @@ listen {{ item.name }}
{% endfor %}
{% endif -%}

{% if item.timeout is defined -%}
{% for entry in item.timeout %}
timeout {{ entry.param }} {{ entry.value }}
{% endfor %}
{% endif -%}

23 changes: 23 additions & 0 deletions templates/web_stats.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
+{% if haproxy_web_stats is defined %}
+listen stats *:{{ haproxy_web_stats.port | default(1936) }}
+ mode http
+ stats realm Haproxy\ Statistics
+{% if haproxy_web_stats.enabled is defined and haproxy_web_stats.enabled == true %}
+ stats enable
+{% endif -%}
+{% if haproxy_web_stats.hide_version is defined and haproxy_web_stats.hide_version == true %}
+ stats hide-version
+{% endif -%}
+{% if haproxy_web_stats.uri is defined %}
+ stats uri {{ haproxy_web_stats.uri }}
+{% endif -%}
+{% if haproxy_web_stats.realm is defined %}
+ stats realm {{ haproxy_web_stats.realm }}
+{% endif -%}
+{% if haproxy_web_stats.auth is defined %}
+ stats auth {{ haproxy_web_stats.auth }}
+{% endif -%}
+{% if haproxy_web_stats.refresh is defined %}
+ stats refresh {{ haproxy_web_stats.refresh }}
+{% endif -%}
+{% endif %}
13 changes: 12 additions & 1 deletion vars/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,10 @@ empty: true
# use_backend:
# - name:
# condition:
#
# timeout:
# - param:
# value:

#haproxy_backends:
# - name:
# disabled:
Expand All @@ -86,6 +89,8 @@ empty: true
# log:
# retries:
# contimeout:
# NOTE: contimeout is deprecated
# http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#4-contimeout
# http-send-name-header:
# http-check-expect:
# - condition
Expand All @@ -101,6 +106,9 @@ empty: true
# - param1
# options:
# - forwardfor
# timeout:
# - param:
# value:
#
#haproxy_listen:
# - name:
Expand Down Expand Up @@ -128,3 +136,6 @@ empty: true
# - param1
# options:
# - forwardfor
# timeout:
# - param:
# value:

0 comments on commit a5f8887

Please sign in to comment.