Skip to content

add SmartOS support #104

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -34,7 +34,7 @@ haproxy_global:
haproxy_defaults:
mode: http
log:
- address: /dev/log
- address: "{{ _haproxy_log_address }}"
facility: local1
level: notice
timeout:
Expand All @@ -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: []
Expand Down
9 changes: 9 additions & 0 deletions files/400.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
HTTP/1.0 400 Bad request
Cache-Control: no-cache
Connection: close
Content-Type: text/html

<html><body><h1>400 Bad request</h1>
Your browser sent an invalid request.
</body></html>

9 changes: 9 additions & 0 deletions files/403.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
HTTP/1.0 403 Forbidden
Cache-Control: no-cache
Connection: close
Content-Type: text/html

<html><body><h1>403 Forbidden</h1>
Request forbidden by administrative rules.
</body></html>

9 changes: 9 additions & 0 deletions files/408.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
HTTP/1.0 408 Request Time-out
Cache-Control: no-cache
Connection: close
Content-Type: text/html

<html><body><h1>408 Request Time-out</h1>
Your browser didn't send a complete request in time.
</body></html>

9 changes: 9 additions & 0 deletions files/500.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
HTTP/1.0 500 Server Error
Cache-Control: no-cache
Connection: close
Content-Type: text/html

<html><body><h1>500 Server Error</h1>
An internal server error occured.
</body></html>

9 changes: 9 additions & 0 deletions files/502.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
HTTP/1.0 502 Bad Gateway
Cache-Control: no-cache
Connection: close
Content-Type: text/html

<html><body><h1>502 Bad Gateway</h1>
The server returned an invalid or incomplete response.
</body></html>

9 changes: 9 additions & 0 deletions files/503.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
HTTP/1.0 503 Service Unavailable
Cache-Control: no-cache
Connection: close
Content-Type: text/html

<html><body><h1>503 Service Unavailable</h1>
No server is available to handle this request.
</body></html>

9 changes: 9 additions & 0 deletions files/504.http
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
HTTP/1.0 504 Gateway Time-out
Cache-Control: no-cache
Connection: close
Content-Type: text/html

<html><body><h1>504 Gateway Time-out</h1>
The server didn't respond in time.
</body></html>

36 changes: 36 additions & 0 deletions tasks/configure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
8 changes: 8 additions & 0 deletions tasks/install.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand All @@ -73,6 +80,7 @@
service:
name: haproxy
enabled: yes
when: ansible_os_family != 'Solaris'

- name: 'Ensure chroot directory exists'
file:
Expand Down
9 changes: 9 additions & 0 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions templates/frontend.cfg
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#jinja2: trim_blocks:False
{%- import '_macros.j2' as macros with context -%}

#{{ ansible_managed }}
Expand Down
4 changes: 4 additions & 0 deletions vars/Solaris.yml
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions vars/default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions vars/empty.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
---
# This file intentionally does not define any variables.