Readme

Synopsis

HA Proxy is a very powerful and popular open source load balancer to balance incoming requests between multiple instances of web-, application- or database servers etc.

confdroid_haproxy automates installation and configuration of HA proxy including self-healing, monitoring and firewall etc.

WARNING

Attention: Never use this puppet module on systems which have been previously configured manually. It is impossible to predict how and what would have been configured, hence previous configurations outside the scope of this module may be overwritten! Automated configurations require a test environment to verify that the module suits the purpose intended by the user, as well as tune the parameters, before deploying into live production

Features

INSTALLATION

  • install rpm binaries

CONFIGURATION

  • manage haproxy user

  • manage directories (file system permissions, selinux context)

  • manage files (file system permissions, content, selinux context)

  • manage proxy instances through a define

  • front-end options

  • back-end options

  • ACL options

  • manage fail2ban integration (optional, requires confdroid_fail2ban module)

SERVICE

  • manage haproxy service

  • restart service after changes in the configuration

Dependencies

All dependencies must be included in the catalogue.

  • concat for managing file fragments

Deployment

  • native Puppet deployment

via site.pp or nodes.pp

node 'example.example.net' {
  include confdroid_haproxy
}
  • through Foreman:

In order to apply parameters through Foreman, confdroid_haproxy::params- must be added to the host or host group in question.

See more details about class deployment on Confdroid.com.

Parameters

The parameters are documented via puppet strings and listed here. Simply open in web browser.

Proxy Configuration

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:

ACL rule:

confdroid_haproxy::server::proxy { 'testing':
    haproxy_fqdn    =>  'node.example.net',
    frontend_name   =>  'test01-frontend',
    frontend_mode   =>  'http',
    acl_rule        =>  ['too_fast fe_sess_rate ge 10',
                          'network_allowed src 0.0.0.0/0'],
    backend_name    =>  'test01-backend',
  }

real Proxy for https:

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. 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.

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

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), 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

Support

  • OS: Rocky 9

  • Puppet 8

Tests

  • Puppet Lint

  • excluded tests:

    • --no-variable_scope-check: not applicable as we are inheriting parameters from params class. the lint check does not distinguish between facts and inherited parameters.

  • Puppet Parser

  • ERB Template Parser

  • Sonar Quality Gate

Contact Us

Disclaimer

ConfDroid as entity is entirely independent from Puppet. We provide custom configuration modules, written for specific purposes and specific environments. The modules are tested and supported only as documented, and require testing in designated environments (i.e. lab or development environments) for parameter tuning etc. before deploying into production environments.