Compare commits
11 Commits
19df6fdca0
...
1.1.0
| Author | SHA1 | Date | |
|---|---|---|---|
| 014c663e30 | |||
| 541e3672b7 | |||
| ad2428456a | |||
| 7df6938b04 | |||
| 6fef250c0d | |||
| 06dbd0fbd0 | |||
| a399dde784 | |||
| cb54dad12a | |||
| 281ce92cd8 | |||
| 2e46d610cb | |||
| af0ddb9f36 |
7
.vscode/settings.json
vendored
7
.vscode/settings.json
vendored
@@ -1,13 +1,20 @@
|
|||||||
{
|
{
|
||||||
"cSpell.words": [
|
"cSpell.words": [
|
||||||
|
"allowdupe",
|
||||||
"dontlognull",
|
"dontlognull",
|
||||||
"dport",
|
"dport",
|
||||||
"forwardfor",
|
"forwardfor",
|
||||||
|
"getsebool",
|
||||||
"httplog",
|
"httplog",
|
||||||
|
"managehome",
|
||||||
"maxconn",
|
"maxconn",
|
||||||
|
"nagiosadmin",
|
||||||
"nologin",
|
"nologin",
|
||||||
|
"onlyif",
|
||||||
"pidfile",
|
"pidfile",
|
||||||
|
"procs",
|
||||||
"redispatch",
|
"redispatch",
|
||||||
|
"roundrobin",
|
||||||
"sess",
|
"sess",
|
||||||
"setsebool",
|
"setsebool",
|
||||||
"tcplog",
|
"tcplog",
|
||||||
|
|||||||
40
README.md
40
README.md
@@ -1,6 +1,8 @@
|
|||||||
# Readme
|
# Readme
|
||||||
|
|
||||||
[](https://jenkins.confdroid.com/job/confdroid_haproxy/)
|
[](https://jenkins.confdroid.com/job/confdroid_haproxy/)
|
||||||
|
[](https://sonarqube.confdroid.com/dashboard?id=confdroid_haproxy)
|
||||||
|
[](https://deepwiki.com/grizzlycoda/puppet_collection)
|
||||||
|
|
||||||
- [Readme](#readme)
|
- [Readme](#readme)
|
||||||
- [Synopsis](#synopsis)
|
- [Synopsis](#synopsis)
|
||||||
@@ -10,6 +12,7 @@
|
|||||||
- [Deployment](#deployment)
|
- [Deployment](#deployment)
|
||||||
- [Parameters](#parameters)
|
- [Parameters](#parameters)
|
||||||
- [Proxy Configuration](#proxy-configuration)
|
- [Proxy Configuration](#proxy-configuration)
|
||||||
|
- [TLS](#tls)
|
||||||
- [SELINUX](#selinux)
|
- [SELINUX](#selinux)
|
||||||
- [Known Problems](#known-problems)
|
- [Known Problems](#known-problems)
|
||||||
- [Support](#support)
|
- [Support](#support)
|
||||||
@@ -42,18 +45,20 @@ CONFIGURATION
|
|||||||
- front-end options
|
- front-end options
|
||||||
- back-end options
|
- back-end options
|
||||||
- ACL options
|
- ACL options
|
||||||
- manage fail2ban integration (optional, requires fail2ban_cd module)
|
- adds haproxy logs to rsyslog for remote logging where used
|
||||||
|
- manage fail2ban integration (optional, requires `confdroid_fail2ban` module)
|
||||||
|
- manage nagios integration (optional, requires `confdroid-nagios` module)
|
||||||
|
|
||||||
SERVICE
|
SERVICE
|
||||||
|
|
||||||
- manage haproxy service
|
- manage haproxy service
|
||||||
- restart service after changes in the configuration
|
- restart service after changes in the configuration
|
||||||
|
- stats are enabled on port 8404 with uri /haproxy?stats and strict private mode, set `hy_stats_auth` to something meaningful.
|
||||||
|
|
||||||
## Dependencies
|
## Dependencies
|
||||||
|
|
||||||
All dependencies must be included in the catalogue.
|
All dependencies must be included in the catalogue.
|
||||||
|
|
||||||
- [cd_resources](https://gitlab.confdroid.com/puppet/cd_resources) for managing yum base repos
|
|
||||||
- [concat](https://github.com/puppetlabs/puppetlabs-concat) for managing file fragments
|
- [concat](https://github.com/puppetlabs/puppetlabs-concat) for managing file fragments
|
||||||
|
|
||||||
## Deployment
|
## Deployment
|
||||||
@@ -83,6 +88,8 @@ The parameters are documented via puppet strings and [listed here](/docs/index.h
|
|||||||
The proxy instances are configured in /etc/haproxy/haproxy.cfg, which is concatenated from various templates through a define in this puppet module.
|
The proxy instances are configured in /etc/haproxy/haproxy.cfg, which is concatenated from various templates through a define in this puppet module.
|
||||||
In order to create proxy instances, you will need an external class, which addresses the define, like so:
|
In order to create proxy instances, you will need an external class, which addresses the define, like so:
|
||||||
|
|
||||||
|
ACL rule:
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
confdroid_haproxy::server::proxy { 'testing':
|
confdroid_haproxy::server::proxy { 'testing':
|
||||||
haproxy_fqdn => 'node.example.net',
|
haproxy_fqdn => 'node.example.net',
|
||||||
@@ -94,14 +101,41 @@ In order to create proxy instances, you will need an external class, which addre
|
|||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
real Proxy for https:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
haproxy_cd::server::proxy { 'https-in':
|
||||||
|
haproxy_fqdn => 'node.example.net',
|
||||||
|
frontend_name => 'https-in',
|
||||||
|
frontend_mode => 'http',
|
||||||
|
fe_bind_mode => '*:443 ssl crt /etc/haproxy/certs/',
|
||||||
|
fe_option => 'forwardfor',
|
||||||
|
fe_http_request => 'add-header X-Forwarded-Proto https',
|
||||||
|
acl_rule_front => 'host_grafana hdr(host) -i grafana.example.net',
|
||||||
|
fe_use_backend => 'grafana_backend if host_grafana',
|
||||||
|
backend_configs => [
|
||||||
|
{
|
||||||
|
'backend_name' => 'grafana_backend',
|
||||||
|
'be_mode' => 'http',
|
||||||
|
'be_balance' => 'roundrobin',
|
||||||
|
'be_server_name_array' => ['node1 10.0.1.1:8080 check'],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
default_backend => 'error_backend',
|
||||||
|
```
|
||||||
|
|
||||||
This allows the puppet module to create the sections in the configuration file as required. The haproxy service will be restarted after the changes in the configuration file are made.
|
This allows the puppet module to create the sections in the configuration file as required. The haproxy service will be restarted after the changes in the configuration file are made.
|
||||||
`haproxy_fqdn` **must**- contain the fqdn of the haproxy **server**- where this should be configured, otherwise the templates are not being populated.
|
`haproxy_fqdn` **must**- contain the fqdn of the haproxy **server**- where this should be configured, otherwise the templates are not being populated.
|
||||||
Multiple ACLs need to be added as array, and will create one line each.
|
Multiple ACLs need to be added as array, and will create one line each.
|
||||||
|
|
||||||
|
## TLS
|
||||||
|
|
||||||
|
Haproxy can manage all sorts of proxies including http and https. It also can terminate https requests and send the requests within a private network unencrypted, which is quite common. **This module is NOT managing certificates**, as there are many ways to manage this, including Kubernetes cert-manager, Let's encrypt or other ways.
|
||||||
|
|
||||||
## SELINUX
|
## SELINUX
|
||||||
|
|
||||||
All files and directories are configured with correct selinux context. If selinux is disabled, these contexts are ignored.
|
All files and directories are configured with correct selinux context. If selinux is disabled, these contexts are ignored.
|
||||||
If selinux is set to `enforce` (not controlled within this module) and `hy_show_stats`is set to `true`, the parameter `hy_selinux_allow_stats` must also be set to `true`, else the haproxy service will not start as selinux will not allow it.
|
If selinux is set to `enforce` (not controlled within this module), the parameter `hy_selinux_allow_stats` must also be set to `true`, else the haproxy service will not start as selinux will not allow it. This is the default setting.
|
||||||
|
|
||||||
## Known Problems
|
## Known Problems
|
||||||
|
|
||||||
|
|||||||
@@ -18,5 +18,11 @@ class confdroid_haproxy::firewall::iptables (
|
|||||||
dport => $hy_https_port,
|
dport => $hy_https_port,
|
||||||
jump => 'accept',
|
jump => 'accept',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
firewall { "${hy_fw_order_no}${hy_stats_port} tcp port ${hy_stats_port}":
|
||||||
|
proto => 'tcp',
|
||||||
|
dport => $hy_stats_port,
|
||||||
|
jump => 'accept',
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,9 +12,14 @@ class confdroid_haproxy::main::config (
|
|||||||
include confdroid_haproxy::monitoring::fail2ban
|
include confdroid_haproxy::monitoring::fail2ban
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if $hy_manage_nagios == true {
|
||||||
|
include confdroid_haproxy::monitoring::target
|
||||||
|
}
|
||||||
|
|
||||||
if $hy_selinux_allow_stats == true {
|
if $hy_selinux_allow_stats == true {
|
||||||
exec { 'setsebool haproxy_connect_any on':
|
exec { 'setsebool haproxy_connect_any on':
|
||||||
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
|
path => ['/bin', '/usr/bin', '/sbin', '/usr/sbin'],
|
||||||
|
onlyif => '/usr/sbin/getsebool haproxy_connect_any | /usr/bin/grep -q " --> off$"',
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
23
manifests/monitoring/target.pp
Normal file
23
manifests/monitoring/target.pp
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
## confdroid_haproxy::monitoring::target.pp
|
||||||
|
# Module name: confdroid_haproxy
|
||||||
|
# Author: 12ww1160 (12ww1160@puppetsoft.com)
|
||||||
|
# @summary class manages exports for nagios monitoring
|
||||||
|
##############################################################################
|
||||||
|
class confdroid_haproxy::monitoring::target (
|
||||||
|
|
||||||
|
) inherits confdroid_haproxy::params {
|
||||||
|
if $hy_manage_nagios == true {
|
||||||
|
@@nagios_service { "check_haproxy_${fqdn}":
|
||||||
|
check_command => "check_nrpe!check_haproxy!${hy_procs_allowed}!haproxy",
|
||||||
|
use => 'generic-service',
|
||||||
|
host_name => $fqdn,
|
||||||
|
notification_period => '24x7',
|
||||||
|
service_description => "${fqdn}_check_haproxy",
|
||||||
|
target => $hy_target_service,
|
||||||
|
owner => 'nagios',
|
||||||
|
group => 'nagios',
|
||||||
|
mode => '0640',
|
||||||
|
contacts => $hy_target_contacts,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,7 +23,6 @@
|
|||||||
# @param [String] hy_chroot where the chroot should be
|
# @param [String] hy_chroot where the chroot should be
|
||||||
# @param [String] hy_pid the pid file to use.
|
# @param [String] hy_pid the pid file to use.
|
||||||
# @param [String] hy_maxconn how many connections should we max allow.
|
# @param [String] hy_maxconn how many connections should we max allow.
|
||||||
# @param [Boolean] hy_show_stats whether we want to display the statistics page
|
|
||||||
# @param [String] hy_stats_socket name and path of the stats socket
|
# @param [String] hy_stats_socket name and path of the stats socket
|
||||||
# @param [String] hy_default_mode which mode to use in the defaults block
|
# @param [String] hy_default_mode which mode to use in the defaults block
|
||||||
# @param [String] hy_log_default should be used when the instance's logging
|
# @param [String] hy_log_default should be used when the instance's logging
|
||||||
@@ -55,6 +54,10 @@
|
|||||||
# @param [String] hy_be_userlist backend userlist comment
|
# @param [String] hy_be_userlist backend userlist comment
|
||||||
# @param [Boolean] hy_manage_be_users whether to manage backend users
|
# @param [Boolean] hy_manage_be_users whether to manage backend users
|
||||||
# @param [Boolean] hy_selinux_allow_stats whether to allow stats in selinux
|
# @param [Boolean] hy_selinux_allow_stats whether to allow stats in selinux
|
||||||
|
# @param [String] hy_stats_port the port to use for stats. used in firewall settings
|
||||||
|
# @param [Boolean] hy_manage_nagios whether to manage nagios service checks
|
||||||
|
# @param [String] hy_target_service the path to the nagios service check file
|
||||||
|
# @param [Array] hy_target_contacts the contacts to use for nagios service checks
|
||||||
###############################################################################
|
###############################################################################
|
||||||
class confdroid_haproxy::params (
|
class confdroid_haproxy::params (
|
||||||
|
|
||||||
@@ -71,15 +74,15 @@ class confdroid_haproxy::params (
|
|||||||
Boolean $hy_manage_fail2ban = false,
|
Boolean $hy_manage_fail2ban = false,
|
||||||
|
|
||||||
# selinux
|
# selinux
|
||||||
Boolean $hy_selinux_allow_stats = false,
|
Boolean $hy_selinux_allow_stats = true,
|
||||||
|
|
||||||
# main config
|
# main config
|
||||||
String $hy_http_port = '80',
|
String $hy_http_port = '80',
|
||||||
String $hy_https_port = '443',
|
String $hy_https_port = '443',
|
||||||
|
String $hy_stats_port = '8404',
|
||||||
String $hy_chroot = '/var/lib/haproxy',
|
String $hy_chroot = '/var/lib/haproxy',
|
||||||
String $hy_pid = '/var/run/haproxy.pid',
|
String $hy_pid = '/var/run/haproxy.pid',
|
||||||
String $hy_maxconn = '4000',
|
String $hy_maxconn = '4000',
|
||||||
Boolean $hy_show_stats = false,
|
|
||||||
String $hy_stats_socket = '/var/lib/haproxy/stats',
|
String $hy_stats_socket = '/var/lib/haproxy/stats',
|
||||||
String $hy_default_mode = 'tcp',
|
String $hy_default_mode = 'tcp',
|
||||||
Boolean $hy_use_http_server_close = false,
|
Boolean $hy_use_http_server_close = false,
|
||||||
@@ -115,6 +118,12 @@ class confdroid_haproxy::params (
|
|||||||
Boolean $hy_manage_be_users = false,
|
Boolean $hy_manage_be_users = false,
|
||||||
String $hy_be_userlist = '####',
|
String $hy_be_userlist = '####',
|
||||||
|
|
||||||
|
# nagios
|
||||||
|
Boolean $hy_manage_nagios = false,
|
||||||
|
String $hy_target_service = '/etc/nagios/conf.d/haproxy_service.cfg',
|
||||||
|
Array $hy_target_contacts = ['nagiosadmin'],
|
||||||
|
String $hy_procs_allowed = '1:1'
|
||||||
|
|
||||||
) {
|
) {
|
||||||
$fqdn = $facts['networking']['fqdn']
|
$fqdn = $facts['networking']['fqdn']
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ defaults
|
|||||||
timeout check <%= @hy_timeout_check %>
|
timeout check <%= @hy_timeout_check %>
|
||||||
maxconn <%= @hy_maxconn %>
|
maxconn <%= @hy_maxconn %>
|
||||||
|
|
||||||
<% if @hy_show_stats == true -%>
|
|
||||||
listen stats
|
listen stats
|
||||||
bind *:8404
|
bind *:8404
|
||||||
mode http
|
mode http
|
||||||
@@ -60,8 +59,6 @@ listen stats
|
|||||||
stats auth <%= @hy_stats_auth %>
|
stats auth <%= @hy_stats_auth %>
|
||||||
stats refresh 30s
|
stats refresh 30s
|
||||||
stats admin if TRUE # Allow admin actions if logged in
|
stats admin if TRUE # Allow admin actions if logged in
|
||||||
<% end -%>
|
|
||||||
listen stats
|
|
||||||
|
|
||||||
<% if @hy_manage_be_users == true -%>
|
<% if @hy_manage_be_users == true -%>
|
||||||
<%= @hy_be_userlist %>
|
<%= @hy_be_userlist %>
|
||||||
|
|||||||
Reference in New Issue
Block a user