From a5f88871057df23773022a3b5181e87fb1ea0f0b Mon Sep 17 00:00:00 2001 From: Juergen WAIBEL Date: Mon, 2 Nov 2015 09:01:18 +0100 Subject: [PATCH] Merged pull requests --- defaults/main.yml | 2 ++ tasks/configure.yml | 4 ++++ tasks/install.yml | 13 +++++++++---- templates/backend.cfg | 5 +++++ templates/defaults.cfg | 20 -------------------- templates/frontend.cfg | 12 +++++++++--- templates/listen.cfg | 6 ++++++ templates/web_stats.cfg | 23 +++++++++++++++++++++++ vars/main.yml | 13 ++++++++++++- 9 files changed, 70 insertions(+), 28 deletions(-) create mode 100644 templates/web_stats.cfg diff --git a/defaults/main.yml b/defaults/main.yml index 47963d3..c7fb89e 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -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 diff --git a/tasks/configure.yml b/tasks/configure.yml index c0f3cd9..8204f43 100644 --- a/tasks/configure.yml +++ b/tasks/configure.yml @@ -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' diff --git a/tasks/install.yml b/tasks/install.yml index ff733fb..20d7093 100644 --- a/tasks/install.yml +++ b/tasks/install.yml @@ -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" diff --git a/templates/backend.cfg b/templates/backend.cfg index fca2958..a430595 100644 --- a/templates/backend.cfg +++ b/templates/backend.cfg @@ -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 -%} diff --git a/templates/defaults.cfg b/templates/defaults.cfg index caa848a..54dc325 100644 --- a/templates/defaults.cfg +++ b/templates/defaults.cfg @@ -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 }} diff --git a/templates/frontend.cfg b/templates/frontend.cfg index 1fdc8c1..e2e473d 100644 --- a/templates/frontend.cfg +++ b/templates/frontend.cfg @@ -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 }} @@ -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 -%} @@ -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 -%} diff --git a/templates/listen.cfg b/templates/listen.cfg index 67e3d3f..36fe1e4 100644 --- a/templates/listen.cfg +++ b/templates/listen.cfg @@ -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 -%} + diff --git a/templates/web_stats.cfg b/templates/web_stats.cfg new file mode 100644 index 0000000..83556ee --- /dev/null +++ b/templates/web_stats.cfg @@ -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 %} \ No newline at end of file diff --git a/vars/main.yml b/vars/main.yml index 21c09fa..6424252 100644 --- a/vars/main.yml +++ b/vars/main.yml @@ -77,7 +77,10 @@ empty: true # use_backend: # - name: # condition: -# +# timeout: +# - param: +# value: + #haproxy_backends: # - name: # disabled: @@ -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 @@ -101,6 +106,9 @@ empty: true # - param1 # options: # - forwardfor +# timeout: +# - param: +# value: # #haproxy_listen: # - name: @@ -128,3 +136,6 @@ empty: true # - param1 # options: # - forwardfor +# timeout: +# - param: +# value: \ No newline at end of file