-
-
Notifications
You must be signed in to change notification settings - Fork 248
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add option to listen resource and refactor option storage
- Loading branch information
Showing
10 changed files
with
207 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -33,6 +33,7 @@ jobs: | |
suite: | ||
- config-2 | ||
- config-3 | ||
- config-4 | ||
- config-acl | ||
- config-array | ||
- config-backend-search | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
apt_update | ||
|
||
haproxy_install 'package' | ||
|
||
haproxy_config_global '' | ||
|
||
haproxy_config_defaults '' do | ||
hash_type 'consistent' | ||
end | ||
|
||
haproxy_listen 'admin' do | ||
bind '0.0.0.0:1337' | ||
mode 'http' | ||
stats uri: '/', | ||
realm: 'Haproxy-Statistics', | ||
auth: 'user:pwd' | ||
http_request [ | ||
'add-header X-Forwarded-Proto https if { ssl_fc }', | ||
'add-header X-Proto http', | ||
] | ||
http_response 'set-header Expires %[date(3600),http_date]' | ||
default_backend 'servers' | ||
option %w(dontlog-normal) | ||
extra_options('bind-process' => 'odd') | ||
hash_type 'consistent' | ||
end | ||
|
||
haproxy_listen 'single-reqrep-reqirep' do | ||
bind '0.0.0.0:8001' | ||
default_backend 'servers' | ||
reqrep '^Host:\ ftp.mydomain.com Host:\ ftp' | ||
reqirep '^Host:\ www.mydomain.com Host:\ www' | ||
end | ||
|
||
haproxy_listen 'multi-reqrep' do | ||
bind '0.0.0.0:8002' | ||
default_backend 'servers' | ||
reqrep [ | ||
'^Host:\ ftp.mydomain.com Host:\ ftp', | ||
'^Host:\ www.mydomain.com Host:\ www', | ||
] | ||
end | ||
|
||
haproxy_listen 'multi-reqirep' do | ||
bind '0.0.0.0:8003' | ||
default_backend 'servers' | ||
reqirep [ | ||
'^Host:\ ftp.mydomain.com Host:\ ftp', | ||
'^Host:\ www.mydomain.com Host:\ www', | ||
] | ||
end | ||
|
||
haproxy_backend 'servers' do | ||
server ['disabled-server 127.0.0.1:1 disabled'] | ||
hash_type 'consistent' | ||
end | ||
|
||
haproxy_backend 'single-reqrep-reqirep' do | ||
server ['disabled-server 127.0.0.1:1 disabled'] | ||
reqrep '^Host:\ ftp.mydomain.com Host:\ ftp' | ||
reqirep '^Host:\ www.mydomain.com Host:\ www' | ||
end | ||
|
||
haproxy_backend 'multi-reqrep' do | ||
server ['disabled-server 127.0.0.1:1 disabled'] | ||
reqrep [ | ||
'^Host:\ ftp.mydomain.com Host:\ ftp', | ||
'^Host:\ www.mydomain.com Host:\ www', | ||
] | ||
end | ||
|
||
haproxy_backend 'multi-reqirep' do | ||
server ['disabled-server 127.0.0.1:1 disabled'] | ||
reqirep [ | ||
'^Host:\ ftp.mydomain.com Host:\ ftp', | ||
'^Host:\ www.mydomain.com Host:\ www', | ||
] | ||
end | ||
|
||
haproxy_service 'haproxy' do | ||
action %i(create enable start) | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,104 @@ | ||
describe package('haproxy') do | ||
it { should be_installed } | ||
end | ||
|
||
describe directory '/etc/haproxy' do | ||
it { should exist } | ||
end | ||
|
||
describe file('/etc/haproxy/haproxy.cfg') do | ||
it { should exist } | ||
it { should be_owned_by 'haproxy' } | ||
it { should be_grouped_into 'haproxy' } | ||
cfg_content = [ | ||
'global', | ||
' user haproxy', | ||
' group haproxy', | ||
' log /dev/log syslog info', | ||
' log-tag haproxy', | ||
' daemon', | ||
' quiet', | ||
' stats socket /var/run/haproxy.sock user haproxy group haproxy', | ||
' stats timeout 2m', | ||
' maxconn 4096', | ||
' pidfile /var/run/haproxy.pid', | ||
'', | ||
'', | ||
'defaults', | ||
' timeout client 10s', | ||
' timeout server 10s', | ||
' timeout connect 10s', | ||
' log global', | ||
' mode http', | ||
' balance roundrobin', | ||
' hash-type consistent', | ||
' option httplog', | ||
' option dontlognull', | ||
' option redispatch', | ||
' option tcplog', | ||
'', | ||
'', | ||
'backend servers', | ||
' server disabled-server 127.0.0.1:1 disabled', | ||
' hash-type consistent', | ||
'', | ||
'', | ||
'backend single-reqrep-reqirep', | ||
' server disabled-server 127.0.0.1:1 disabled', | ||
' reqrep \^Host:\\\ ftp.mydomain.com Host:\\\ ftp', | ||
' reqirep \^Host:\\\ www.mydomain.com Host:\\\ www', | ||
'', | ||
'', | ||
'backend multi-reqrep', | ||
' server disabled-server 127.0.0.1:1 disabled', | ||
' reqrep \^Host:\\\ ftp.mydomain.com Host:\\\ ftp', | ||
' reqrep \^Host:\\\ www.mydomain.com Host:\\\ www', | ||
'', | ||
'', | ||
'backend multi-reqirep', | ||
' server disabled-server 127.0.0.1:1 disabled', | ||
' reqirep \^Host:\\\ ftp.mydomain.com Host:\\\ ftp', | ||
' reqirep \^Host:\\\ www.mydomain.com Host:\\\ www', | ||
'', | ||
'', | ||
'listen admin', | ||
' mode http', | ||
' bind 0.0.0.0:1337', | ||
' stats uri /', | ||
' stats realm Haproxy-Statistics', | ||
' stats auth user:pwd', | ||
' http-request add-header X-Forwarded-Proto https if { ssl_fc }', | ||
' http-request add-header X-Proto http', | ||
' http-response set-header Expires %\[date\(3600\),http_date\]', | ||
' default_backend servers', | ||
' option dontlog-normal', | ||
' bind-process odd', | ||
' hash-type consistent', | ||
'', | ||
'', | ||
'listen single-reqrep-reqirep', | ||
' bind 0.0.0.0:8001', | ||
' reqrep \^Host:\\\ ftp.mydomain.com Host:\\\ ftp', | ||
' reqirep \^Host:\\\ www.mydomain.com Host:\\\ www', | ||
' default_backend servers', | ||
'', | ||
'', | ||
'listen multi-reqrep', | ||
' bind 0.0.0.0:8002', | ||
' reqrep \^Host:\\\ ftp.mydomain.com Host:\\\ ftp', | ||
' reqrep \^Host:\\\ www.mydomain.com Host:\\\ www', | ||
' default_backend servers', | ||
'', | ||
'', | ||
'listen multi-reqirep', | ||
' bind 0.0.0.0:8003', | ||
' reqirep \^Host:\\\ ftp.mydomain.com Host:\\\ ftp', | ||
' reqirep \^Host:\\\ www.mydomain.com Host:\\\ www', | ||
' default_backend servers', | ||
] | ||
its('content') { should match /#{cfg_content.join('\n')}/ } | ||
end | ||
|
||
describe service('haproxy') do | ||
it { should be_running } | ||
end |