diff --git a/defaults/main.yml b/defaults/main.yml
index cad51cd..aec171f 100644
--- a/defaults/main.yml
+++ b/defaults/main.yml
@@ -14,9 +14,9 @@ _haproxy_ssl_ciphers: 'ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305
haproxy_global:
log:
- - address: /dev/log
+ - address: "{{ _haproxy_log_address }}"
facility: local0
- - address: /dev/log
+ - address: "{{ _haproxy_log_address }}"
facility: local1
level: notice
chroot: /var/lib/haproxy
@@ -34,7 +34,7 @@ haproxy_global:
haproxy_defaults:
mode: http
log:
- - address: /dev/log
+ - address: "{{ _haproxy_log_address }}"
facility: local1
level: notice
timeout:
@@ -53,19 +53,19 @@ haproxy_defaults:
- dontlognull
errorfile:
- code: 400
- file: /etc/haproxy/errors/400.http
+ file: "{{ haproxy_config_dir }}/errors/400.http"
- code: 403
- file: /etc/haproxy/errors/403.http
+ file: "{{ haproxy_config_dir }}/errors/403.http"
- code: 408
- file: /etc/haproxy/errors/408.http
+ file: "{{ haproxy_config_dir }}/errors/408.http"
- code: 500
- file: /etc/haproxy/errors/500.http
+ file: "{{ haproxy_config_dir }}/errors/500.http"
- code: 502
- file: /etc/haproxy/errors/502.http
+ file: "{{ haproxy_config_dir }}/errors/502.http"
- code: 503
- file: /etc/haproxy/errors/503.http
+ file: "{{ haproxy_config_dir }}/errors/503.http"
- code: 504
- file: /etc/haproxy/errors/504.http
+ file: "{{ haproxy_config_dir }}/errors/504.http"
haproxy_resolvers: []
haproxy_backends: []
diff --git a/files/400.http b/files/400.http
new file mode 100644
index 0000000..e223e38
--- /dev/null
+++ b/files/400.http
@@ -0,0 +1,9 @@
+HTTP/1.0 400 Bad request
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+
400 Bad request
+Your browser sent an invalid request.
+
+
diff --git a/files/403.http b/files/403.http
new file mode 100644
index 0000000..a67e807
--- /dev/null
+++ b/files/403.http
@@ -0,0 +1,9 @@
+HTTP/1.0 403 Forbidden
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+403 Forbidden
+Request forbidden by administrative rules.
+
+
diff --git a/files/408.http b/files/408.http
new file mode 100644
index 0000000..aafb130
--- /dev/null
+++ b/files/408.http
@@ -0,0 +1,9 @@
+HTTP/1.0 408 Request Time-out
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+408 Request Time-out
+Your browser didn't send a complete request in time.
+
+
diff --git a/files/500.http b/files/500.http
new file mode 100644
index 0000000..bb121e8
--- /dev/null
+++ b/files/500.http
@@ -0,0 +1,9 @@
+HTTP/1.0 500 Server Error
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+500 Server Error
+An internal server error occured.
+
+
diff --git a/files/502.http b/files/502.http
new file mode 100644
index 0000000..94b35d4
--- /dev/null
+++ b/files/502.http
@@ -0,0 +1,9 @@
+HTTP/1.0 502 Bad Gateway
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+502 Bad Gateway
+The server returned an invalid or incomplete response.
+
+
diff --git a/files/503.http b/files/503.http
new file mode 100644
index 0000000..48fde58
--- /dev/null
+++ b/files/503.http
@@ -0,0 +1,9 @@
+HTTP/1.0 503 Service Unavailable
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+503 Service Unavailable
+No server is available to handle this request.
+
+
diff --git a/files/504.http b/files/504.http
new file mode 100644
index 0000000..f925184
--- /dev/null
+++ b/files/504.http
@@ -0,0 +1,9 @@
+HTTP/1.0 504 Gateway Time-out
+Cache-Control: no-cache
+Connection: close
+Content-Type: text/html
+
+504 Gateway Time-out
+The server didn't respond in time.
+
+
diff --git a/tasks/configure.yml b/tasks/configure.yml
index 4d9042d..8bc9262 100644
--- a/tasks/configure.yml
+++ b/tasks/configure.yml
@@ -138,6 +138,42 @@
with_items: "{{ haproxy_userlists }}"
when: haproxy_userlists is defined
+## CREATE ERROR PAGES
+
+- name: Add error directory
+ file:
+ path: "{{ haproxy_config_dir }}/errors"
+ state: directory
+
+- name: '400'
+ copy:
+ src: 400.http
+ dest: "{{ haproxy_config_dir }}/errors/400.http"
+- name: '403'
+ copy:
+ src: 403.http
+ dest: "{{ haproxy_config_dir }}/errors/403.http"
+- name: '408'
+ copy:
+ src: 408.http
+ dest: "{{ haproxy_config_dir }}/errors/408.http"
+- name: '500'
+ copy:
+ src: 500.http
+ dest: "{{ haproxy_config_dir }}/errors/500.http"
+- name: '502'
+ copy:
+ src: 502.http
+ dest: "{{ haproxy_config_dir }}/errors/502.http"
+- name: '503'
+ copy:
+ src: 503.http
+ dest: "{{ haproxy_config_dir }}/errors/503.http"
+- name: '504'
+ copy:
+ src: 504.http
+ dest: "{{ haproxy_config_dir }}/errors/504.http"
+
## ASSEMBLE CONFIG - GLOBAL & DEFAULT
- name: 'Delete the compiled folder'
diff --git a/tasks/install.yml b/tasks/install.yml
index 8d0d5cc..8d0c054 100644
--- a/tasks/install.yml
+++ b/tasks/install.yml
@@ -64,6 +64,13 @@
name: "{{ haproxy_package_name }}"
when: ansible_distribution == 'Ubuntu'
+- name: Install HAProxy (pkgin)
+ pkgin:
+ name: "{{ haproxy_package_name }}"
+ state: present
+ update_cache: yes
+ when: ansible_os_family == 'Solaris'
+
- name: Install supplementary packages
package:
name: "{{ item }}"
@@ -73,6 +80,7 @@
service:
name: haproxy
enabled: yes
+ when: ansible_os_family != 'Solaris'
- name: 'Ensure chroot directory exists'
file:
diff --git a/tasks/main.yml b/tasks/main.yml
index 01c30c9..849cb9f 100644
--- a/tasks/main.yml
+++ b/tasks/main.yml
@@ -1,4 +1,13 @@
---
+- include_vars: "{{ item }}"
+ with_first_found:
+ - "../vars/{{ ansible_os_family }}.yml"
+ - "../vars/empty.yml"
+ tags: [always]
+
+- include_vars: "default.yml"
+ tags: [always]
+
- include: install.yml
- include: configure.yml
diff --git a/templates/frontend.cfg b/templates/frontend.cfg
index d4dd55a..afffb62 100644
--- a/templates/frontend.cfg
+++ b/templates/frontend.cfg
@@ -1,3 +1,4 @@
+#jinja2: trim_blocks:False
{%- import '_macros.j2' as macros with context -%}
#{{ ansible_managed }}
diff --git a/vars/Solaris.yml b/vars/Solaris.yml
new file mode 100644
index 0000000..ad14086
--- /dev/null
+++ b/vars/Solaris.yml
@@ -0,0 +1,4 @@
+---
+haproxy_config_dir: /opt/local/etc/haproxy
+haproxy_config_file: /opt/local/etc/haproxy.cfg
+_haproxy_log_address: 127.0.0.1
diff --git a/vars/default.yml b/vars/default.yml
index 7ffd92d..f901e99 100644
--- a/vars/default.yml
+++ b/vars/default.yml
@@ -5,3 +5,5 @@ _haproxy_config_file: "{{ _haproxy_config_dir }}/haproxy.cfg"
_haproxy_package_name: haproxy
_haproxy_extra_packages:
- socat
+
+_haproxy_log_address: /dev/log
diff --git a/vars/empty.yml b/vars/empty.yml
new file mode 100644
index 0000000..f1aa7b6
--- /dev/null
+++ b/vars/empty.yml
@@ -0,0 +1,2 @@
+---
+# This file intentionally does not define any variables.