Puppet Class: tripleo::haproxy

Defined in:
manifests/haproxy.pp

Overview

Class: tripleo::haproxy

Configure HAProxy for TripleO.

Parameters:

haproxy_service_manage

Will be passed as value for service_manage to HAProxy module. Defaults to true

haproxy_global_maxconn

The value to use as maxconn in the HAProxy global config section. Defaults to 20480

haproxy_default_maxconn

The value to use as maxconn in the HAProxy default config section. Defaults to 4096

haproxy_default_timeout

The value to use as timeout in the HAProxy default config section. Defaults to [ ‘http-request 10s’, ‘queue 2m’, ‘connect 10s’, ‘client 2m’, ‘server 2m’, ‘check 10s’ ]

haproxy_listen_bind_param

A list of params to be added to the HAProxy listener bind directive. By default the ‘transparent’ param is added but it should be cleared if one of the *_virtual_ip addresses is a wildcard, eg. 0.0.0.0 Defaults to [ ‘transparent’ ]

haproxy_member_options

The default options to use for the HAProxy balancer members. Defaults to [ ‘check’, ‘inter 2000’, ‘rise 2’, ‘fall 5’ ]

haproxy_log_address

The IPv4, IPv6 or filesystem socket path of the syslog server. Defaults to ‘/dev/log’

haproxy_log_facility

The syslog facility for HAProxy. Defaults to ‘local0’

haproxy_globals_override

HAProxy global option we can append to the default base set in this class. If you enter an already existing key, it will override the default. Defaults to {}

haproxy_lb_mode_longrunning

HAProxy LB mode to use with the services the clients of which may have the notion of the longrunning requests, like RPC or just API requests that take time. The HAProxy’s default roundrobin balance algorithm can be replaced with it. Defaults to “leastconn”.

haproxy_defaults_override

HAProxy defaults option we can append to the default base set in this class. If you enter an already existing key, it will override the default. Defaults to {}

haproxy_daemon

Should haproxy run in daemon mode or not Defaults to true

haproxy_socket_access_level

Access level for HAProxy socket. Can be “user” or “admin” Defaults to “user”

controller_hosts

IPs of host or group of hosts to load-balance the services Can be a string or an array. Defaults to lookup(‘controller_node_ips’)

controller_hosts_names

Names of host or group of hosts to load-balance the services Can be a string or an array. Defaults to lookup(‘controller_node_names’, undef, undef, undef)

controller_virtual_ip

Control IP or group of IPs to bind the pools Can be a string or an array. Defaults to undef

public_virtual_ip

Public IP or group of IPs to bind the pools Can be a string or an array. Defaults to undef

use_backend_syntax

(optional) When set to true, generate a config with frontend and backend sections, otherwise use listen sections. Defaults to lookup(‘haproxy_backend_syntax’, undef, undef, false)

haproxy_stats_user

Username for haproxy stats authentication. A string. Defaults to ‘admin’

haproxy_stats_password

Password for haproxy stats authentication. When set, authentication is enabled on the haproxy stats endpoint. A string. Defaults to undef

haproxy_stats_bind_address

Bind address for where the haproxy stats web interface should listen on in addition to the controller_virtual_ip A string.or an array Defaults to undef

service_certificate

Filename of an HAProxy-compatible certificate and key file When set, enables SSL on the public API endpoints using the specified file. Defaults to undef

use_internal_certificates

Flag that indicates if we’ll use an internal certificate for this specific service. When set, enables SSL on the internal API endpoints using the file that certmonger is tracking; this is derived from the network the service is listening on. Defaults to false

internal_certificates_specs

A hash that should contain the specs that were used to create the certificates. As the name indicates, only the internal certificates will be fetched from here. And the keys should follow the following pattern “haproxy-<network name>”. The network name should be as it was defined in tripleo-heat-templates. Note that this is only taken into account if the $use_internal_certificates flag is set. Defaults to {}

enable_internal_tls

A flag that indicates if the servers in the internal network are using TLS. This enables the ‘ssl’ option for the server members that are proxied. Defaults to lookup(‘enable_internal_tls’, undef, undef, false)

ssl_cipher_suite

The default string describing the list of cipher algorithms (“cipher suite”) that are negotiated during the SSL/TLS handshake for all “bind” lines. This value comes from the Fedora system crypto policy. Defaults to ‘!SSLv2:kEECDH:kRSA:kEDH:kPSK:+3DES:!aNULL:!eNULL:!MD5:!EXP:!RC4:!SEED:!IDEA:!DES’

ssl_options

String that sets the default ssl options to force on all “bind” lines. Defaults to ‘no-sslv3 no-tlsv10’

ca_bundle

Path to the CA bundle to be used for HAProxy to validate the certificates of the servers it balances Defaults to ‘/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt’

crl_file

Path to the CRL file to be used for checking revoked certificates. Defaults to undef

haproxy_stats_certificate

Filename of an HAProxy-compatible certificate and key file When set, enables SSL on the haproxy stats endpoint using the specified file. Defaults to undef

haproxy_stats

(optional) Enable or not the haproxy stats interface Defaults to true

keystone_admin

(optional) Enable or not Keystone Admin API binding Defaults to lookup(‘keystone_enabled’, undef, undef, false)

keystone_public

(optional) Enable or not Keystone Public API binding Defaults to lookup(‘keystone_enabled’, undef, undef, false)

neutron

(optional) Enable or not Neutron API binding Defaults to lookup(‘neutron_api_enabled’, undef, undef, false)

cinder

(optional) Enable or not Cinder API binding Defaults to lookup(‘cinder_api_enabled’, undef, undef, false)

manila

(optional) Enable or not Manila API binding Defaults to lookup(‘manila_api_enabled’, undef, undef, false)

glance_api

(optional) Enable or not Glance API binding Defaults to lookup(‘glance_api_enabled’, undef, undef, false)

glance_api_internal

(optional) Enable or not Glance API (internal) binding Defaults to lookup(‘glance_api_internal_enabled’, undef, undef, false)

nova_osapi

(optional) Enable or not Nova API binding Defaults to lookup(‘nova_api_enabled’, undef, undef, false)

placement

(optional) Enable or not Placement API binding Defaults to lookup(‘placement_enabled’, undef, undef, false)

nova_metadata

(optional) Enable or not Nova metadata binding Defaults to lookup(‘nova_metadata_enabled’, undef, undef, false)

nova_novncproxy

(optional) Enable or not Nova novncproxy binding Defaults to lookup(‘nova_vnc_proxy_enabled’, undef, undef, false)

aodh

(optional) Enable or not Aodh API binding Defaults to lookup(‘aodh_api_enabled’, undef, undef, false)

barbican

(optional) Enable or not Barbican API binding Defaults to lookup(‘barbican_api_enabled’, undef, undef, false)

designate

(optional) Enable or not Designate API binding Defaults to lookup(‘designate_api_enabled’, undef, undef, false)

metrics_qdr

(optional) Enable or not Metrics QDR binding Defaults to lookup(‘metrics_qdr_enabled’, undef, undef, false)

gnocchi

(optional) Enable or not Gnocchi API binding Defaults to lookup(‘gnocchi_api_enabled’, undef, undef, false)

swift_proxy_server

(optional) Enable or not Swift API binding Defaults to lookup(‘swift_proxy_enabled’, undef, undef, false)

heat_api

(optional) Enable or not Heat API binding Defaults to lookup(‘heat_api_enabled’, undef, undef, false)

heat_cfn

(optional) Enable or not Heat CFN API binding Defaults to lookup(‘heat_api_cfn_enabled’, undef, undef, false)

horizon

(optional) Enable or not Horizon dashboard binding Defaults to lookup(‘horizon_enabled’, undef, undef, false)

ironic

(optional) Enable or not Ironic API binding Defaults to lookup(‘ironic_enabled’, undef, undef, false)

ironic_inspector

(optional) Enable or not Ironic Inspector API binding Defaults to lookup(‘ironic_inspector_enabled’, undef, undef, false)

octavia

(optional) Enable or not Octavia API binding Defaults to lookup(‘octavia_api_enabled’, undef, undef, false)

mysql

(optional) Enable or not MySQL Galera binding Defaults to lookup(‘mysql_enabled’, undef, undef, false)

mysql_clustercheck

(optional) Enable check via clustercheck for mysql Defaults to false

mysql_max_conn

(optional) Set the maxconn parameter for mysql Defaults to undef

mysql_member_options

The options to use for the mysql HAProxy balancer members. If this parameter is undefined, the actual value configured will depend on the value of $mysql_clustercheck. If cluster checking is enabled, the mysql member options will be: “[‘backup’, ‘port 9200’, ‘on-marked-down shutdown-sessions’, ‘check’, ‘inter 1s’]” and if mysql cluster checking is disabled, the member options will be: “union($haproxy_member_options, [‘backup’])” Defaults to undef

mysql_custom_listen_options

Hash to pass to the mysql haproxy listen stanza to be deepmerged with the other options Defaults to {}

mysql_custom_frontend_options

Hash to pass to the mysql haproxy frontend stanza to be deepmerged with the other options Defaults to {}

mysql_custom_backend_options

Hash to pass to the mysql haproxy backend stanza to be deepmerged with the other options Defaults to {}

rabbitmq

(optional) Enable or not RabbitMQ binding Defaults to false

etcd

(optional) Enable or not Etcd binding Defaults to lookup(‘etcd_enabled’, undef, undef, false)

docker_registry

(optional) Enable or not the Docker Registry API binding Defaults to lookup(‘enable_docker_registry’, undef, undef, false)

redis

(optional) Enable or not Redis binding Defaults to lookup(‘redis_enabled’, undef, undef, false)

redis_password

(optional) Password for Redis authentication, eventually needed by the specific monitoring we do from HAProxy for Redis Defaults to undef

ceph_rgw

(optional) Enable or not Ceph RadosGW binding Defaults to lookup(‘ceph_rgw_enabled’, undef, undef, false)

ceph_grafana

(optional) Enable or not Ceph Grafana dashboard binding Defaults to lookup(‘ceph_grafana_enabled’, undef, undef, false)

ceph_dashboard

(optional) Enable or not Ceph Dashboard binding Defaults to lookup(‘ceph_grafana_enabled’, undef, undef, false)

ovn_dbs

(optional) Enable or not OVN northd binding Defaults to lookup(‘ovn_dbs_enabled’, undef, undef, false)

ovn_dbs_manage_lb

(optional) Whether or not haproxy should configure OVN dbs for load balancing if ovn_dbs is enabled. Defaults to false

aodh_network

(optional) Specify the network aodh is running on. Defaults to lookup(‘aodh_api_network’, undef, undef, undef)

barbican_network

(optional) Specify the network barbican is running on. Defaults to lookup(‘barbican_api_network’, undef, undef, undef)

ceph_rgw_network

(optional) Specify the network ceph_rgw is running on. Defaults to lookup(‘ceph_rgw_network’, undef, undef, undef)

ceph_grafana_network

(optional) Specify the network ceph_grafana is running on. Defaults to lookup(‘ceph_grafana_network’, undef, undef, undef)

ceph_dashboard_network

(optional) Specify the network ceph_dashboard is running on. Defaults to lookup(‘ceph_dashboard_network’, undef, undef, undef)

cinder_network

(optional) Specify the network cinder is running on. Defaults to lookup(‘cinder_api_network’, undef, undef, undef)

designate_network

(optional) Specify the network designate is running on. Defaults to lookup(‘designate_api_network’, undef, undef, undef)

metrics_qdr_network

(optional) Specify the network metrics_qdr is running on. Defaults to lookup(‘metrics_qdr_network’, undef, undef, undef)

docker_registry_network

(optional) Specify the network docker-registry is running on. Defaults to lookup(‘docker_registry_network’, undef, undef, undef)

glance_api_network

(optional) Specify the network glance_api is running on. Defaults to lookup(‘glance_api_network’, undef, undef, undef)

gnocchi_network

(optional) Specify the network gnocchi is running on. Defaults to lookup(‘gnocchi_api_network’, undef, undef, undef)

heat_api_network

(optional) Specify the network heat_api is running on. Defaults to lookup(‘heat_api_network’, undef, undef, undef)

heat_cfn_network

(optional) Specify the network heat_cfn is running on. Defaults to lookup(‘heat_api_cfn_network’, undef, undef, undef)

horizon_network

(optional) Specify the network horizon is running on. Defaults to lookup(‘horizon_network’, undef, undef, undef)

ironic_inspector_network

(optional) Specify the network ironic_inspector is running on. Defaults to lookup(‘ironic_inspector_network’, undef, undef, undef)

ironic_network

(optional) Specify the network ironic is running on. Defaults to lookup(‘ironic_api_network’, undef, undef, undef)

keystone_admin_network

(optional) Specify the network keystone_admin is running on. Defaults to lookup(‘keystone_network’, undef, undef, undef)

keystone_public_network

(optional) Specify the network keystone_public is running on. Defaults to lookup(‘keystone_network’, undef, undef, undef)

keystone_sticky_sessions

(optional) Use cookie-based session persistence for the Keystone public API. Defaults to lookup(‘keystone_sticky_sessions’, undef, undef, false)

keystone_session_cookie

(optional) Use a specified name for the Keystone sticky session cookie. Defaults to lookup(‘keystone_session_cookie’, undef, undef, ‘KEYSTONESESSION’)

manila_network

(optional) Specify the network manila is running on. Defaults to lookup(‘manila_api_network’, undef, undef, undef)

neutron_network

(optional) Specify the network neutron is running on. Defaults to lookup(‘neutron_api_network’, undef, undef, undef)

nova_metadata_network

(optional) Specify the network nova_metadata is running on. Defaults to lookup(‘nova_metadata_network’, undef, undef, undef)

nova_novncproxy_network

(optional) Specify the network nova_novncproxy is running on. Defaults to lookup(‘nova_vnc_proxy_network’, undef, undef, lookup(‘nova_libvirt_network’, undef, undef, undef))

nova_osapi_network

(optional) Specify the network nova_osapi is running on. Defaults to lookup(‘nova_api_network’, undef, undef, undef)

placement_network

(optional) Specify the network placement is running on. Defaults to lookup(‘placement_network’, undef, undef, undef)

etcd_network

(optional) Specify the network etcd is running on. Defaults to lookup(‘etcd_network’, undef, undef, undef)

octavia_network

(optional) Specify the network octavia is running on. Defaults to lookup(‘octavia_api_network’, undef, undef, undef)

ovn_dbs_network

(optional) Specify the network ovn_dbs is running on. Defaults to lookup(‘ovn_dbs_network’, undef, undef, undef)

swift_proxy_server_network

(optional) Specify the network swift_proxy_server is running on. Defaults to lookup(‘swift_proxy_network’, undef, undef, undef)

designate_mdns_proxy_baseport

(optional) Specify the base port value for the external->internal proxies used for external DNS integration with designate workers. Defaults to lookup(‘designate_mdns_public_port_start’, undef, undef, 16000)

service_ports

(optional) Hash that contains the values to override from the service ports The available keys to modify the services’ ports are:

'aodh_api_port' (Defaults to 8042)
'aodh_api_ssl_port' (Defaults to 13042)
'barbican_api_port' (Defaults to 9311)
'barbican_api_ssl_port' (Defaults to 13311)
'cinder_api_port' (Defaults to 8776)
'cinder_api_ssl_port' (Defaults to 13776)
'docker_registry_port' (Defaults to 8787)
'docker_registry_ssl_port' (Defaults to 13787)
'glance_api_port' (Defaults to 9292)
'glance_api_internal_port' (Defaults to 9293)
'glance_api_ssl_port' (Defaults to 13292)
'gnocchi_api_port' (Defaults to 8041)
'gnocchi_api_ssl_port' (Defaults to 13041)
'heat_api_port' (Defaults to 8004)
'heat_api_ssl_port' (Defaults to 13004)
'heat_cfn_port' (Defaults to 8000)
'heat_cfn_ssl_port' (Defaults to 13005)
'ironic_api_port' (Defaults to 6385)
'ironic_api_ssl_port' (Defaults to 13385)
'ironic_inspector_port' (Defaults to 5050)
'ironic_inspector_ssl_port' (Defaults to 13050)
'keystone_admin_api_port' (Defaults to 35357)
'keystone_public_api_port' (Defaults to 5000)
'keystone_public_api_ssl_port' (Defaults to 13000)
'manila_api_port' (Defaults to 8786)
'manila_api_ssl_port' (Defaults to 13786)
'metrics_qdr_port' (Defaults to 5666)
'neutron_api_port' (Defaults to 9696)
'neutron_api_ssl_port' (Defaults to 13696)
'nova_api_port' (Defaults to 8774)
'nova_api_ssl_port' (Defaults to 13774)
'nova_metadata_port' (Defaults to 8775)
'nova_novnc_port' (Defaults to 6080)
'nova_novnc_ssl_port' (Defaults to 13080)
'octavia_api_port' (Defaults to 9876)
'octavia_api_ssl_port' (Defaults to 13876)
'placement_port' (Defaults to 8778)
'placement_ssl_port' (Defaults to 13778)
'ovn_nbdb_port' (Defaults to 6641)
'ovn_nbdb_ssl_port' (Defaults to 13641)
'ovn_sbdb_port' (Defaults to 6642)
'ovn_sbdb_ssl_port' (Defaults to 13642)
'swift_proxy_port' (Defaults to 8080)
'swift_proxy_ssl_port' (Defaults to 13808)
'ceph_rgw_port' (Defaults to 8080)
'ceph_rgw_ssl_port' (Defaults to 13808)
'ceph_grafana_port' (Defaults to 3100)
'ceph_grafana_ssl_port' (Defaults to 3100)
'ceph_dashboard_port' (Defaults to 8444)
'ceph_dashboard_ssl_port' (Defaults to 8444)

Defaults to {}

DEPRECATED PARAMETERS

activate_httplog

This parameter has been deprecated and has no effect. Defaults to undef

Parameters:

  • controller_virtual_ip (Any)
  • public_virtual_ip (Any)
  • use_backend_syntax (Any) (defaults to: lookup('haproxy_backend_syntax', undef, undef, false))
  • haproxy_service_manage (Any) (defaults to: true)
  • haproxy_global_maxconn (Any) (defaults to: 20480)
  • haproxy_default_maxconn (Any) (defaults to: 4096)
  • haproxy_default_timeout (Any) (defaults to: [ 'http-request 10s', 'queue 2m', 'connect 10s', 'client 2m', 'server 2m', 'check 30s' ])
  • haproxy_listen_bind_param (Any) (defaults to: [ 'transparent' ])
  • haproxy_member_options (Any) (defaults to: [ 'check', 'inter 2000', 'rise 2', 'fall 5' ])
  • haproxy_log_address (Any) (defaults to: '/dev/log')
  • haproxy_log_facility (Any) (defaults to: 'local0')
  • haproxy_globals_override (Any) (defaults to: {})
  • haproxy_defaults_override (Any) (defaults to: {})
  • haproxy_lb_mode_longrunning (Any) (defaults to: 'leastconn')
  • haproxy_daemon (Any) (defaults to: true)
  • haproxy_socket_access_level (Any) (defaults to: 'user')
  • haproxy_stats_user (Any) (defaults to: 'admin')
  • haproxy_stats_password (Any) (defaults to: undef)
  • haproxy_stats_bind_address (Any) (defaults to: undef)
  • controller_hosts (Any) (defaults to: lookup('controller_node_ips'))
  • controller_hosts_names (Any) (defaults to: lookup('controller_node_names', undef, undef, undef))
  • service_certificate (Any) (defaults to: undef)
  • use_internal_certificates (Any) (defaults to: false)
  • internal_certificates_specs (Any) (defaults to: {})
  • enable_internal_tls (Any) (defaults to: lookup('enable_internal_tls', undef, undef, false))
  • ssl_cipher_suite (Any) (defaults to: '!SSLv2:kEECDH:kRSA:kEDH:kPSK:+3DES:!aNULL:!eNULL:!MD5:!EXP:!RC4:!SEED:!IDEA:!DES')
  • ssl_options (Any) (defaults to: 'no-sslv3 no-tlsv10')
  • ca_bundle (Any) (defaults to: '/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt')
  • crl_file (Any) (defaults to: undef)
  • haproxy_stats_certificate (Any) (defaults to: undef)
  • haproxy_stats (Any) (defaults to: true)
  • keystone_admin (Any) (defaults to: lookup('keystone_enabled', undef, undef, false))
  • keystone_public (Any) (defaults to: lookup('keystone_enabled', undef, undef, false))
  • neutron (Any) (defaults to: lookup('neutron_api_enabled', undef, undef, false))
  • cinder (Any) (defaults to: lookup('cinder_api_enabled', undef, undef, false))
  • manila (Any) (defaults to: lookup('manila_api_enabled', undef, undef, false))
  • glance_api (Any) (defaults to: lookup('glance_api_enabled', undef, undef, false))
  • glance_api_internal (Any) (defaults to: lookup('glance_api_internal_enabled', undef, undef, false))
  • nova_osapi (Any) (defaults to: lookup('nova_api_enabled', undef, undef, false))
  • placement (Any) (defaults to: lookup('placement_enabled', undef, undef, false))
  • nova_metadata (Any) (defaults to: lookup('nova_metadata_enabled', undef, undef, false))
  • nova_novncproxy (Any) (defaults to: lookup('nova_vnc_proxy_enabled', undef, undef, false))
  • aodh (Any) (defaults to: lookup('aodh_api_enabled', undef, undef, false))
  • barbican (Any) (defaults to: lookup('barbican_api_enabled', undef, undef, false))
  • ceph_grafana (Any) (defaults to: lookup('ceph_grafana_enabled', undef, undef, false))
  • ceph_dashboard (Any) (defaults to: lookup('ceph_grafana_enabled', undef, undef, false))
  • gnocchi (Any) (defaults to: lookup('gnocchi_api_enabled', undef, undef, false))
  • swift_proxy_server (Any) (defaults to: lookup('swift_proxy_enabled', undef, undef, false))
  • heat_api (Any) (defaults to: lookup('heat_api_enabled', undef, undef, false))
  • heat_cfn (Any) (defaults to: lookup('heat_api_cfn_enabled', undef, undef, false))
  • horizon (Any) (defaults to: lookup('horizon_enabled', undef, undef, false))
  • ironic (Any) (defaults to: lookup('ironic_api_enabled', undef, undef, false))
  • ironic_inspector (Any) (defaults to: lookup('ironic_inspector_enabled', undef, undef, false))
  • octavia (Any) (defaults to: lookup('octavia_api_enabled', undef, undef, false))
  • designate (Any) (defaults to: lookup('designate_api_enabled', undef, undef, false))
  • metrics_qdr (Any) (defaults to: lookup('metrics_qdr_enabled', undef, undef, false))
  • mysql (Any) (defaults to: lookup('mysql_enabled', undef, undef, false))
  • mysql_clustercheck (Any) (defaults to: false)
  • mysql_max_conn (Any) (defaults to: undef)
  • mysql_member_options (Any) (defaults to: undef)
  • mysql_custom_listen_options (Any) (defaults to: {})
  • mysql_custom_frontend_options (Any) (defaults to: {})
  • mysql_custom_backend_options (Any) (defaults to: {})
  • rabbitmq (Any) (defaults to: false)
  • etcd (Any) (defaults to: lookup('etcd_enabled', undef, undef, false))
  • docker_registry (Any) (defaults to: lookup('enable_docker_registry', undef, undef, false))
  • redis (Any) (defaults to: lookup('redis_enabled', undef, undef, false))
  • redis_password (Any) (defaults to: undef)
  • ceph_rgw (Any) (defaults to: lookup('ceph_rgw_enabled', undef, undef, false))
  • ovn_dbs (Any) (defaults to: lookup('ovn_dbs_enabled', undef, undef, false))
  • ovn_dbs_manage_lb (Any) (defaults to: false)
  • aodh_network (Any) (defaults to: lookup('aodh_api_network', undef, undef, undef))
  • barbican_network (Any) (defaults to: lookup('barbican_api_network', undef, undef, false))
  • ceph_rgw_network (Any) (defaults to: lookup('ceph_rgw_network', undef, undef, undef))
  • cinder_network (Any) (defaults to: lookup('cinder_api_network', undef, undef, undef))
  • designate_network (Any) (defaults to: lookup('designate_api_network', undef, undef, undef))
  • metrics_qdr_network (Any) (defaults to: lookup('metrics_qdr_network', undef, undef, undef))
  • docker_registry_network (Any) (defaults to: lookup('docker_registry_network', undef, undef, undef))
  • glance_api_network (Any) (defaults to: lookup('glance_api_network', undef, undef, undef))
  • gnocchi_network (Any) (defaults to: lookup('gnocchi_api_network', undef, undef, undef))
  • heat_api_network (Any) (defaults to: lookup('heat_api_network', undef, undef, undef))
  • ceph_grafana_network (Any) (defaults to: lookup('ceph_grafana_network', undef, undef, undef))
  • ceph_dashboard_network (Any) (defaults to: lookup('ceph_dashboard_network', undef, undef, undef))
  • heat_cfn_network (Any) (defaults to: lookup('heat_api_cfn_network', undef, undef, undef))
  • horizon_network (Any) (defaults to: lookup('horizon_network', undef, undef, undef))
  • ironic_inspector_network (Any) (defaults to: lookup('ironic_inspector_network', undef, undef, undef))
  • ironic_network (Any) (defaults to: lookup('ironic_api_network', undef, undef, undef))
  • keystone_admin_network (Any) (defaults to: lookup('keystone_admin_api_network', undef, undef, undef))
  • keystone_public_network (Any) (defaults to: lookup('keystone_public_api_network', undef, undef, undef))
  • keystone_sticky_sessions (Any) (defaults to: lookup('keystone_sticky_sessions', undef, undef, false))
  • keystone_session_cookie (Any) (defaults to: lookup('keystone_session_cookie,', undef, undef, 'KEYSTONESESSION'))
  • manila_network (Any) (defaults to: lookup('manila_api_network', undef, undef, undef))
  • neutron_network (Any) (defaults to: lookup('neutron_api_network', undef, undef, undef))
  • nova_metadata_network (Any) (defaults to: lookup('nova_metadata_network', undef, undef, undef))
  • nova_novncproxy_network (Any) (defaults to: lookup('nova_vnc_proxy_network', undef, undef, lookup('nova_libvirt_network', undef, undef, undef)))
  • nova_osapi_network (Any) (defaults to: lookup('nova_api_network', undef, undef, undef))
  • placement_network (Any) (defaults to: lookup('placement_network', undef, undef, undef))
  • octavia_network (Any) (defaults to: lookup('octavia_api_network', undef, undef, undef))
  • ovn_dbs_network (Any) (defaults to: lookup('ovn_dbs_network', undef, undef, undef))
  • etcd_network (Any) (defaults to: lookup('etcd_network', undef, undef, undef))
  • swift_proxy_server_network (Any) (defaults to: lookup('swift_proxy_network', undef, undef, undef))
  • designate_mdns_proxy_baseport (Any) (defaults to: lookup('designate_mdns_public_port_start', undef, undef, 16000))
  • service_ports (Any) (defaults to: {})
  • activate_httplog (Any) (defaults to: undef)


531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
# File 'manifests/haproxy.pp', line 531

class tripleo::haproxy (
  $controller_virtual_ip,
  $public_virtual_ip,
  $use_backend_syntax            = lookup('haproxy_backend_syntax', undef, undef, false),
  $haproxy_service_manage        = true,
  $haproxy_global_maxconn        = 20480,
  $haproxy_default_maxconn       = 4096,
  $haproxy_default_timeout       = [ 'http-request 10s', 'queue 2m', 'connect 10s', 'client 2m', 'server 2m', 'check 30s' ],
  $haproxy_listen_bind_param     = [ 'transparent' ],
  $haproxy_member_options        = [ 'check', 'inter 2000', 'rise 2', 'fall 5' ],
  $haproxy_log_address           = '/dev/log',
  $haproxy_log_facility          = 'local0',
  $haproxy_globals_override      = {},
  $haproxy_defaults_override     = {},
  $haproxy_lb_mode_longrunning   = 'leastconn',
  $haproxy_daemon                = true,
  $haproxy_socket_access_level   = 'user',
  $haproxy_stats_user            = 'admin',
  $haproxy_stats_password        = undef,
  $haproxy_stats_bind_address    = undef,
  $controller_hosts              = lookup('controller_node_ips'),
  $controller_hosts_names        = lookup('controller_node_names', undef, undef, undef),
  $service_certificate           = undef,
  $use_internal_certificates     = false,
  $internal_certificates_specs   = {},
  $enable_internal_tls           = lookup('enable_internal_tls', undef, undef, false),
  $ssl_cipher_suite              = '!SSLv2:kEECDH:kRSA:kEDH:kPSK:+3DES:!aNULL:!eNULL:!MD5:!EXP:!RC4:!SEED:!IDEA:!DES',
  $ssl_options                   = 'no-sslv3 no-tlsv10',
  $ca_bundle                     = '/etc/pki/ca-trust/extracted/openssl/ca-bundle.trust.crt',
  $crl_file                      = undef,
  $haproxy_stats_certificate     = undef,
  $haproxy_stats                 = true,
  $keystone_admin                = lookup('keystone_enabled', undef, undef, false),
  $keystone_public               = lookup('keystone_enabled', undef, undef, false),
  $neutron                       = lookup('neutron_api_enabled', undef, undef, false),
  $cinder                        = lookup('cinder_api_enabled', undef, undef, false),
  $manila                        = lookup('manila_api_enabled', undef, undef, false),
  $glance_api                    = lookup('glance_api_enabled', undef, undef, false),
  $glance_api_internal           = lookup('glance_api_internal_enabled', undef, undef, false),
  $nova_osapi                    = lookup('nova_api_enabled', undef, undef, false),
  $placement                     = lookup('placement_enabled', undef, undef, false),
  $nova_metadata                 = lookup('nova_metadata_enabled', undef, undef, false),
  $nova_novncproxy               = lookup('nova_vnc_proxy_enabled', undef, undef, false),
  $aodh                          = lookup('aodh_api_enabled', undef, undef, false),
  $barbican                      = lookup('barbican_api_enabled', undef, undef, false),
  $ceph_grafana                  = lookup('ceph_grafana_enabled', undef, undef, false),
  $ceph_dashboard                = lookup('ceph_grafana_enabled', undef, undef, false),
  $gnocchi                       = lookup('gnocchi_api_enabled', undef, undef, false),
  $swift_proxy_server            = lookup('swift_proxy_enabled', undef, undef, false),
  $heat_api                      = lookup('heat_api_enabled', undef, undef, false),
  $heat_cfn                      = lookup('heat_api_cfn_enabled', undef, undef, false),
  $horizon                       = lookup('horizon_enabled', undef, undef, false),
  $ironic                        = lookup('ironic_api_enabled', undef, undef, false),
  $ironic_inspector              = lookup('ironic_inspector_enabled', undef, undef, false),
  $octavia                       = lookup('octavia_api_enabled', undef, undef, false),
  $designate                     = lookup('designate_api_enabled', undef, undef, false),
  $metrics_qdr                   = lookup('metrics_qdr_enabled', undef, undef, false),
  $mysql                         = lookup('mysql_enabled', undef, undef, false),
  $mysql_clustercheck            = false,
  $mysql_max_conn                = undef,
  $mysql_member_options          = undef,
  $mysql_custom_listen_options   = {},
  $mysql_custom_frontend_options = {},
  $mysql_custom_backend_options  = {},
  $rabbitmq                      = false,
  $etcd                          = lookup('etcd_enabled', undef, undef, false),
  $docker_registry               = lookup('enable_docker_registry', undef, undef, false),
  $redis                         = lookup('redis_enabled', undef, undef, false),
  $redis_password                = undef,
  $ceph_rgw                      = lookup('ceph_rgw_enabled', undef, undef, false),
  $ovn_dbs                       = lookup('ovn_dbs_enabled', undef, undef, false),
  $ovn_dbs_manage_lb             = false,
  $aodh_network                  = lookup('aodh_api_network', undef, undef, undef),
  $barbican_network              = lookup('barbican_api_network', undef, undef, false),
  $ceph_rgw_network              = lookup('ceph_rgw_network', undef, undef, undef),
  $cinder_network                = lookup('cinder_api_network', undef, undef, undef),
  $designate_network             = lookup('designate_api_network', undef, undef, undef),
  $metrics_qdr_network           = lookup('metrics_qdr_network', undef, undef, undef),
  $docker_registry_network       = lookup('docker_registry_network', undef, undef, undef),
  $glance_api_network            = lookup('glance_api_network', undef, undef, undef),
  $gnocchi_network               = lookup('gnocchi_api_network', undef, undef, undef),
  $heat_api_network              = lookup('heat_api_network', undef, undef, undef),
  $ceph_grafana_network          = lookup('ceph_grafana_network', undef, undef, undef),
  $ceph_dashboard_network        = lookup('ceph_dashboard_network', undef, undef, undef),
  $heat_cfn_network              = lookup('heat_api_cfn_network', undef, undef, undef),
  $horizon_network               = lookup('horizon_network', undef, undef, undef),
  $ironic_inspector_network      = lookup('ironic_inspector_network', undef, undef, undef),
  $ironic_network                = lookup('ironic_api_network', undef, undef, undef),
  $keystone_admin_network        = lookup('keystone_admin_api_network', undef, undef, undef),
  $keystone_public_network       = lookup('keystone_public_api_network', undef, undef, undef),
  $keystone_sticky_sessions      = lookup('keystone_sticky_sessions', undef, undef, false),
  $keystone_session_cookie       = lookup('keystone_session_cookie,', undef, undef, 'KEYSTONESESSION'),
  $manila_network                = lookup('manila_api_network', undef, undef, undef),
  $neutron_network               = lookup('neutron_api_network', undef, undef, undef),
  $nova_metadata_network         = lookup('nova_metadata_network', undef, undef, undef),
  $nova_novncproxy_network       = lookup('nova_vnc_proxy_network', undef, undef, lookup('nova_libvirt_network', undef, undef, undef)),
  $nova_osapi_network            = lookup('nova_api_network', undef, undef, undef),
  $placement_network             = lookup('placement_network', undef, undef, undef),
  $octavia_network               = lookup('octavia_api_network', undef, undef, undef),
  $ovn_dbs_network               = lookup('ovn_dbs_network', undef, undef, undef),
  $etcd_network                  = lookup('etcd_network', undef, undef, undef),
  $swift_proxy_server_network    = lookup('swift_proxy_network', undef, undef, undef),
  $designate_mdns_proxy_baseport = lookup('designate_mdns_public_port_start', undef, undef, 16000),
  $service_ports                 = {},
  # DEPRECATED PARAMETERS
  $activate_httplog              = undef
) {

  if $activate_httplog != undef {
    warning('The activate_httplog parameter has been deprecated and has no effect')
  }

  $default_service_ports = {
    aodh_api_port => 8042,
    aodh_api_ssl_port => 13042,
    barbican_api_port => 9311,
    barbican_api_ssl_port => 13311,
    cinder_api_port => 8776,
    cinder_api_ssl_port => 13776,
    designate_api_port => 9001,
    designate_api_ssl_port => 13001,
    docker_registry_port => 8787,
    docker_registry_ssl_port => 13787,
    etcd_port => 2379,
    glance_api_port => 9292,
    glance_api_internal_port => 9293,
    glance_api_ssl_port => 13292,
    gnocchi_api_port => 8041,
    gnocchi_api_ssl_port => 13041,
    heat_api_port => 8004,
    heat_api_ssl_port => 13004,
    heat_cfn_port => 8000,
    heat_cfn_ssl_port => 13005,
    ironic_api_port => 6385,
    ironic_api_ssl_port => 13385,
    ironic_inspector_port => 5050,
    ironic_inspector_ssl_port => 13050,
    keystone_admin_api_port => 35357,
    keystone_public_api_port => 5000,
    keystone_public_api_ssl_port => 13000,
    manila_api_port => 8786,
    manila_api_ssl_port => 13786,
    metrics_qdr_port => 5666,
    neutron_api_port => 9696,
    neutron_api_ssl_port => 13696,
    nova_api_port => 8774,
    nova_api_ssl_port => 13774,
    nova_metadata_port => 8775,
    nova_novnc_port => 6080,
    nova_novnc_ssl_port => 13080,
    octavia_api_port => 9876,
    octavia_api_ssl_port => 13876,
    placement_port => 8778,
    placement_ssl_port => 13778,
    ovn_nbdb_port => 6641,
    ovn_nbdb_ssl_port => 13641,
    ovn_sbdb_port => 6642,
    ovn_sbdb_ssl_port => 13642,
    swift_proxy_port => 8080,
    swift_proxy_ssl_port => 13808,
    ceph_rgw_port => 8080,
    ceph_rgw_ssl_port => 13808,
    ceph_grafana_port => 3100,
    ceph_grafana_ssl_port => 3100,
    ceph_prometheus_port => 9092,
    ceph_prometheus_ssl_port => 9092,
    ceph_alertmanager_port => 9093,
    ceph_alertmanager_ssl_port => 9093,
    ceph_dashboard_port => 8444,
    ceph_dashboard_ssl_port => 8444,
  }
  $ports = merge($default_service_ports, $service_ports)

  if $enable_internal_tls {
    $base_internal_tls_member_options = ['ssl', 'verify required', "ca-file ${ca_bundle}"]

    if $crl_file {
      $internal_tls_member_options = concat($base_internal_tls_member_options, "crl-file ${crl_file}")
    } else {
      $internal_tls_member_options = $base_internal_tls_member_options
    }
    Haproxy::Balancermember {
      verifyhost => true
    }
  } else {
    $internal_tls_member_options = []
  }

  $controller_hosts_real = any2array(split($controller_hosts, ','))
  if ! $controller_hosts_names {
    $controller_hosts_names_real = $controller_hosts_real
  } else {
    $controller_hosts_names_real = downcase(any2array(split($controller_hosts_names, ',')))
  }

  $mysql_vip = lookup('mysql_vip', undef, undef, $controller_virtual_ip)
  $mysql_bind_opts = {
    "${mysql_vip}:3306" => $haproxy_listen_bind_param,
  }

  $rabbitmq_vip = lookup('rabbitmq_vip', undef, undef, $controller_virtual_ip)
  $rabbitmq_bind_opts = {
    "${rabbitmq_vip}:5672" => $haproxy_listen_bind_param,
  }


  $haproxy_global_options = {
    'log'                      => "${haproxy_log_address} ${haproxy_log_facility}",
    'pidfile'                  => '/var/run/haproxy.pid',
    'user'                     => 'haproxy',
    'group'                    => 'haproxy',
    'maxconn'                  => $haproxy_global_maxconn,
    'ssl-default-bind-ciphers' => $ssl_cipher_suite,
    'ssl-default-bind-options' => $ssl_options,
    'stats'                    => [
      "socket /var/lib/haproxy/stats mode 600 level ${haproxy_socket_access_level}",
      'timeout 2m'
    ],
  }
  if $haproxy_daemon == true {
    $haproxy_daemonize = {
      'daemon' => '',
    }
  } else {
    $haproxy_daemonize = {}
  }

  $haproxy_defaults_options = {
    'mode'    => 'tcp',
    'log'     => 'global',
    'retries' => '3',
    'timeout' => $haproxy_default_timeout,
    'maxconn' => $haproxy_default_maxconn,
  }

  class { 'haproxy':
    service_manage   => $haproxy_service_manage,
    global_options   => merge($haproxy_global_options, $haproxy_daemonize, $haproxy_globals_override),
    defaults_options => merge($haproxy_defaults_options, $haproxy_defaults_override),
  }


  # NOTE(bogdando): the rule is: *log is only needed for frontend usually,
  # but tcpka and other "durability" related options should be set for both
  # sides, based on a service case by case.
  $default_frontend_options = {
    'option'       => [ 'httplog', 'forwardfor'],
    'http-request' => [
      'set-header X-Forwarded-Proto https if { ssl_fc }',
      'set-header X-Forwarded-Proto http if !{ ssl_fc }',
      'set-header X-Forwarded-Port %[dst_port]'],
  }
  $default_backend_options = {
    'option' => [ 'httpchk' ],
  }
  $default_listen_options = merge_hash_values($default_frontend_options,
                                              $default_backend_options)
  Tripleo::Haproxy::Endpoint {
    haproxy_listen_bind_param   => $haproxy_listen_bind_param,
    member_options              => $haproxy_member_options,
    public_certificate          => $service_certificate,
    use_internal_certificates   => $use_internal_certificates,
    internal_certificates_specs => $internal_certificates_specs,
    listen_options              => $default_listen_options,
    frontend_options            => $default_frontend_options,
    backend_options             => $default_backend_options,
  }

  $service_names = lookup('enabled_services', undef, undef, [])
  tripleo::haproxy::service_endpoints { $service_names: }

  if $haproxy_stats {
    if $haproxy_stats_certificate {
      $haproxy_stats_certificate_real = $haproxy_stats_certificate
    } elsif $use_internal_certificates {
      # NOTE(jaosorior): Right now it's hardcoded to use the ctlplane network
      $haproxy_stats_certificate_real = $internal_certificates_specs["haproxy-ctlplane"]['service_pem']
    } else {
      $haproxy_stats_certificate_real = undef
    }
    $haproxy_stats_ips_raw = union(any2array($controller_virtual_ip), any2array($haproxy_stats_bind_address))
    $haproxy_stats_ips = delete_undef_values($haproxy_stats_ips_raw)

    class { 'tripleo::haproxy::stats':
      haproxy_listen_bind_param => $haproxy_listen_bind_param,
      ip                        => $haproxy_stats_ips,
      password                  => $haproxy_stats_password,
      certificate               => $haproxy_stats_certificate_real,
      user                      => $haproxy_stats_user,
    }
  }

  $keystone_frontend_opts = {
    'option' => [ 'httplog', 'forwardfor' ]
  }
  $keystone_backend_opts = {
    'option' => [ 'httpchk GET /healthcheck' ]
  }
  $keystone_listen_opts = merge_hash_values($keystone_frontend_opts,
                                              $keystone_backend_opts)
  if $keystone_admin {
    # NOTE(jaosorior): Given that the admin endpoint is in the same vhost
    # nowadays as the public/internal one. We can just loadbalance towards the
    # same IP.
    ::tripleo::haproxy::endpoint { 'keystone_admin':
      internal_ip      => lookup('keystone_admin_api_vip', undef, undef, $controller_virtual_ip),
      service_port     => $ports[keystone_public_api_port],
      haproxy_port     => $ports[keystone_admin_api_port],
      ip_addresses     => lookup('keystone_public_api_node_ips', undef, undef, $controller_hosts_real),
      server_names     => lookup('keystone_public_api_node_names', undef, undef, $controller_hosts_names_real),
      mode             => 'http',
      listen_options   => merge($default_listen_options, $keystone_listen_opts),
      frontend_options => merge($default_frontend_options, $keystone_frontend_opts),
      backend_options  => merge($default_backend_options, $keystone_backend_opts),
      service_network  => $keystone_admin_network,
      member_options   => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $keystone_public {
    ::tripleo::haproxy::endpoint { 'keystone_public':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('keystone_public_api_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[keystone_public_api_port],
      ip_addresses      => lookup('keystone_public_api_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('keystone_public_api_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      listen_options    => merge($default_listen_options, $keystone_listen_opts),
      frontend_options  => merge($default_frontend_options, $keystone_frontend_opts),
      backend_options   => merge($default_backend_options, $keystone_backend_opts),
      public_ssl_port   => $ports[keystone_public_api_ssl_port],
      service_network   => $keystone_public_network,
      sticky_sessions   => $keystone_sticky_sessions,
      session_cookie    => $keystone_session_cookie,
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $neutron {
    $neutron_frontend_opts = {
      'timeout client' => '10m',
      'option'         => [ 'httplog', 'forwardfor' ]
    }
    $neutron_backend_opts = {
      'timeout server' => '10m',
      'balance'        => $haproxy_lb_mode_longrunning,
      'option'         => [ 'httpchk GET /healthcheck' ]
    }
    $neutron_listen_opts = merge_hash_values($neutron_frontend_opts,
                                                $neutron_backend_opts)
    ::tripleo::haproxy::endpoint { 'neutron':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('neutron_api_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[neutron_api_port],
      ip_addresses      => lookup('neutron_api_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('neutron_api_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      listen_options    => merge($default_listen_options, $neutron_listen_opts),
      frontend_options  => merge($default_frontend_options, $neutron_frontend_opts),
      backend_options   => merge($default_backend_options, $neutron_backend_opts),
      public_ssl_port   => $ports[neutron_api_ssl_port],
      service_network   => $neutron_network,
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $cinder {
    $cinder_frontend_opts = {
      'option'  => [ 'httplog', 'forwardfor' ],
    }
    $cinder_backend_opts = {
      'option'  => [ 'httpchk GET /healthcheck' ],
      'balance' => $haproxy_lb_mode_longrunning,
    }
    $cinder_listen_opts = merge_hash_values($cinder_frontend_opts,
                                              $cinder_backend_opts)
    ::tripleo::haproxy::endpoint { 'cinder':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('cinder_api_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[cinder_api_port],
      ip_addresses      => lookup('cinder_api_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('cinder_api_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      listen_options    => merge($default_listen_options, $cinder_listen_opts),
      frontend_options  => merge($default_frontend_options, $cinder_frontend_opts),
      backend_options   => merge($default_backend_options, $cinder_backend_opts),
      public_ssl_port   => $ports[cinder_api_ssl_port],
      service_network   => $cinder_network,
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $manila {
    $manila_frontend_opts = {
      'option' => [ 'httplog', 'forwardfor' ],
    }
    $manila_backend_opts = {
      'option' => [ 'httpchk GET /healthcheck' ],
    }
    $manila_listen_opts = merge_hash_values($manila_frontend_opts,
                                              $manila_backend_opts)
    ::tripleo::haproxy::endpoint { 'manila':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('manila_api_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[manila_api_port],
      ip_addresses      => lookup('manila_api_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('manila_api_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      listen_options    => merge($default_listen_options, $manila_listen_opts),
      frontend_options  => merge($default_frontend_options, $manila_frontend_opts),
      backend_options   => merge($default_backend_options, $manila_backend_opts),
      public_ssl_port   => $ports[manila_api_ssl_port],
      service_network   => $manila_network,
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $glance_api {
    $glance_frontend_opts = {
      'option' => [ 'httplog', 'forwardfor' ],
    }
    $glance_backend_opts = {
      'option' => [ 'httpchk GET /healthcheck' ],
    }
    $glance_listen_opts = merge_hash_values($glance_frontend_opts,
                                              $glance_backend_opts)
    ::tripleo::haproxy::endpoint { 'glance_api':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('glance_api_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[glance_api_port],
      ip_addresses      => lookup('glance_api_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('glance_api_node_names', undef, undef, $controller_hosts_names_real),
      public_ssl_port   => $ports[glance_api_ssl_port],
      mode              => 'http',
      listen_options    => merge($default_listen_options, $glance_listen_opts),
      frontend_options  => merge($default_frontend_options, $glance_frontend_opts),
      backend_options   => merge($default_backend_options, $glance_backend_opts),
      service_network   => $glance_api_network,
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $glance_api_internal {
    $glance_internal_frontend_opts = {
      'option' => [ 'httplog', 'forwardfor' ],
    }
    $glance_internal_backend_opts = {
      'option' => [ 'httpchk GET /healthcheck' ],
    }
    $glance_internal_listen_opts = merge_hash_values($glance_internal_frontend_opts,
                                                      $glance_internal_backend_opts)

    # The glance_api_internal service uses the same network and internal VIP as the
    # glance_api service. There is no public VIP (that's handled by the glance_api service).
    ::tripleo::haproxy::endpoint { 'glance_api_internal':
      internal_ip      => lookup('glance_api_vip', undef, undef, $controller_virtual_ip),
      service_port     => $ports[glance_api_internal_port],
      ip_addresses     => lookup('glance_api_internal_node_ips', undef, undef, $controller_hosts_real),
      server_names     => lookup('glance_api_internal_node_names', undef, undef, $controller_hosts_names_real),
      mode             => 'http',
      listen_options   => merge($default_listen_options, $glance_internal_listen_opts),
      frontend_options => merge($default_frontend_options, $glance_internal_frontend_opts),
      backend_options  => merge($default_backend_options, $glance_internal_backend_opts),
      service_network  => $glance_api_network,
      member_options   => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $ceph_grafana {
    if $enable_internal_tls {
      $ceph_grafana_tls_member_options = ['ssl check verify none']
    } else {
      $ceph_grafana_tls_member_options = []
    }
    ::tripleo::haproxy::endpoint { 'ceph_grafana':
      internal_ip      => lookup('ceph_dashboard_vip', undef, undef, $controller_virtual_ip),
      service_port     => $ports[ceph_grafana_port],
      ip_addresses     => lookup('ceph_grafana_node_ips', undef, undef, $controller_hosts_real),
      server_names     => lookup('ceph_grafana_node_names', undef, undef, $controller_hosts_names_real),
      mode             => 'http',
      public_ssl_port  => $ports[ceph_grafana_ssl_port],
      listen_options   => merge($default_listen_options, {
        'option'  => [ 'httpchk HEAD /', 'httplog', 'forwardfor' ],
        'balance' => 'source',
      }),
      frontend_options => $default_frontend_options,
      backend_options  => merge($default_backend_options, {
        'option'  => [ 'httpchk HEAD /' ],
        'balance' => 'source',
      }),
      service_network  => $ceph_grafana_network,
      member_options   => union($haproxy_member_options, $ceph_grafana_tls_member_options),
    }
    ::tripleo::haproxy::endpoint { 'ceph_prometheus':
      internal_ip      => lookup('ceph_grafana_vip', undef, undef, $controller_virtual_ip),
      service_port     => $ports[ceph_prometheus_port],
      ip_addresses     => lookup('ceph_grafana_node_ips', undef, undef, $controller_hosts_real),
      server_names     => lookup('ceph_grafana_node_names', undef, undef, $controller_hosts_names_real),
      mode             => 'http',
      public_ssl_port  => $ports[ceph_prometheus_ssl_port],
      listen_options   => merge($default_listen_options, {
        'option'  => [ 'httpchk GET /metrics', 'httplog', 'forwardfor' ],
        'balance' => 'source',
      }),
      frontend_options => $default_frontend_options,
      backend_options  => merge($default_backend_options, {
        'option'  => [ 'httpchk GET /metrics' ],
        'balance' => 'source',
      }),
      service_network  => $ceph_grafana_network,
      member_options   => $haproxy_member_options,
    }
    ::tripleo::haproxy::endpoint { 'ceph_alertmanager':
      internal_ip      => lookup('ceph_grafana_vip', undef, undef, $controller_virtual_ip),
      service_port     => $ports[ceph_alertmanager_port],
      ip_addresses     => lookup('ceph_grafana_node_ips', undef, undef, $controller_hosts_real),
      server_names     => lookup('ceph_grafana_node_names', undef, undef, $controller_hosts_names_real),
      mode             => 'http',
      public_ssl_port  => $ports[ceph_alertmanager_ssl_port],
      listen_options   => merge($default_listen_options, {
        'option'  => [ 'httpchk GET /', 'httplog', 'forwardfor' ],
        'balance' => 'source',
      }),
      frontend_options => $default_frontend_options,
      backend_options  => merge($default_backend_options, {
        'option'  => [ 'httpchk GET /' ],
        'balance' => 'source',
      }),
      service_network  => $ceph_grafana_network,
      member_options   => $haproxy_member_options,
    }
  }

  if $ceph_dashboard {
    if $enable_internal_tls {
      $ceph_dashboard_tls_member_options = ['ssl check verify none']
    } else {
      $ceph_dashboard_tls_member_options = []
    }
    $ceph_dashboard_backend_opts = {
      'option'     => [ 'httpchk HEAD /' ],
      'balance'    => 'source',
      'http-check' => 'expect rstatus 2[0-9][0-9]',
    }
    $ceph_dashboard_listen_opts = merge_hash_values($default_frontend_options,
                                                      $ceph_dashboard_backend_opts)
    ::tripleo::haproxy::endpoint { 'ceph_dashboard':
      internal_ip      => lookup('ceph_dashboard_vip', undef, undef, $controller_virtual_ip),
      service_port     => $ports[ceph_dashboard_port],
      ip_addresses     => lookup('ceph_grafana_node_ips', undef, undef, $controller_hosts_real),
      server_names     => lookup('ceph_grafana_node_names', undef, undef, $controller_hosts_names_real),
      mode             => 'http',
      public_ssl_port  => $ports[ceph_dashboard_ssl_port],
      listen_options   => merge($default_listen_options, $ceph_dashboard_listen_opts),
      frontend_options => $default_frontend_options,
      backend_options  => merge($default_backend_options, $ceph_dashboard_backend_opts),
      service_network  => $ceph_dashboard_network,
      member_options   => union($haproxy_member_options, $ceph_dashboard_tls_member_options),
    }
  }

  $nova_api_vip = lookup('nova_api_vip', undef, undef, $controller_virtual_ip)
  if $nova_osapi {
    # NOTE(tkajinam): Nova doesn't provide healthcheck API
    ::tripleo::haproxy::endpoint { 'nova_osapi':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => $nova_api_vip,
      service_port      => $ports[nova_api_port],
      ip_addresses      => lookup('nova_api_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('nova_api_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      public_ssl_port   => $ports[nova_api_ssl_port],
      service_network   => $nova_osapi_network,
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  $placement_vip = lookup('placement_vip', undef, undef, $controller_virtual_ip)
  if $placement {
    # NOTE(tkajinam): Placement doesn't provide healthcheck API
    ::tripleo::haproxy::endpoint { 'placement':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => $placement_vip,
      service_port      => $ports[placement_port],
      ip_addresses      => lookup('placement_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('placement_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      public_ssl_port   => $ports[placement_ssl_port],
      service_network   => $placement_network,
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $nova_metadata {
    # NOTE(tkajinam): Nova doesn't provide healthcheck API
    if lookup('nova_is_additional_cell', undef, undef, undef) {
      $nova_metadata_server_names_real = lookup('nova_metadata_cell_node_names', undef, undef, $controller_hosts_names_real)
    } else {
      $nova_metadata_server_names_real = lookup('nova_metadata_node_names', undef, undef, $controller_hosts_names_real)
    }
    $nova_metadata_backend_opts = {
      'balance'   => 'source',
      'hash-type' => 'consistent',
    }
    $nova_metadata_listen_opts = merge_hash_values($default_listen_options,
                                                      $nova_metadata_backend_opts)
    ::tripleo::haproxy::endpoint { 'nova_metadata':
      internal_ip      => lookup('nova_metadata_vip', undef, undef, $controller_virtual_ip),
      service_port     => $ports[nova_metadata_port],
      ip_addresses     => lookup('nova_metadata_node_ips', undef, undef, $controller_hosts_real),
      server_names     => $nova_metadata_server_names_real,
      mode             => 'http',
      service_network  => $nova_metadata_network,
      member_options   => union($haproxy_member_options, $internal_tls_member_options),
      listen_options   => merge($default_listen_options, $nova_metadata_listen_opts),
      frontend_options => $default_frontend_options,
      backend_options  => merge($default_backend_options, $nova_metadata_backend_opts),
    }
  }

  $nova_vnc_proxy_vip = lookup('nova_vnc_proxy_vip', undef, undef, $controller_virtual_ip)
  if $nova_novncproxy {
    # NOTE(tkajinam): Nova-VNCProxy doesn't provide healthcheck API
    if $enable_internal_tls {
      # we need to make sure we use ssl for checks.
      $haproxy_member_options_real   = delete($haproxy_member_options, 'check')
      $novncproxy_ssl_member_options = ['check-ssl']
    } else {
      $haproxy_member_options_real   = $haproxy_member_options
      $novncproxy_ssl_member_options = []
    }
    if lookup('nova_is_additional_cell', undef, undef, undef) {
      $novncproxy_server_names_real = lookup('nova_vnc_proxy_cell_node_names', undef, undef, $controller_hosts_names_real)
    } else {
      $novncproxy_server_names_real = lookup('nova_vnc_proxy_node_names', undef, undef, $controller_hosts_names_real)
    }
    $nova_vncproxy_frontend_opts = {
      'option'  => [ 'tcpka', 'tcplog' ],
    }
    $nova_vncproxy_backend_opts = {
      'option'  => [ 'tcpka' ],
      'balance' => 'source',
      'timeout' => [ 'tunnel 1h' ],
    }
    $nova_vncproxy_listen_opts = merge_hash_values($nova_vncproxy_frontend_opts,
                                                      $nova_vncproxy_backend_opts)
    ::tripleo::haproxy::endpoint { 'nova_novncproxy':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => $nova_vnc_proxy_vip,
      service_port      => $ports[nova_novnc_port],
      ip_addresses      => lookup('nova_vnc_proxy_node_ips', undef, undef, $controller_hosts_real),
      server_names      => $novncproxy_server_names_real,
      mode              => 'http',
      listen_options    => merge($default_listen_options, $nova_vncproxy_listen_opts),
      frontend_options  => merge($default_frontend_options, $nova_vncproxy_frontend_opts),
      backend_options   => merge($default_backend_options, $nova_vncproxy_backend_opts),
      public_ssl_port   => $ports[nova_novnc_ssl_port],
      service_network   => $nova_novncproxy_network,
      member_options    => union($haproxy_member_options_real, $internal_tls_member_options, $novncproxy_ssl_member_options),
    }
  }

  if $aodh {
    $aodh_frontend_opts = {
      'option' => [ 'httplog', 'forwardfor' ],
    }
    $aodh_backend_opts = {
      'option' => [ 'httpchk GET /healthcheck' ],
    }
    $aodh_listen_opts = merge_hash_values($aodh_frontend_opts,
                                            $aodh_backend_opts)
    ::tripleo::haproxy::endpoint { 'aodh':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('aodh_api_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[aodh_api_port],
      ip_addresses      => lookup('aodh_api_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('aodh_api_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      listen_options    => merge($default_listen_options, $aodh_listen_opts),
      frontend_options  => merge($default_frontend_options, $aodh_frontend_opts),
      backend_options   => merge($default_backend_options, $aodh_backend_opts),
      public_ssl_port   => $ports[aodh_api_ssl_port],
      service_network   => $aodh_network,
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $barbican {
    $barbican_frontend_opts = {
      'option' => [ 'httplog', 'forwardfor' ],
    }
    $barbican_backend_opts = {
      'option' => [ 'httpchk GET /healthcheck' ],
    }
    $barbican_listen_opts = merge_hash_values($barbican_frontend_opts,
                                                $barbican_backend_opts)
    ::tripleo::haproxy::endpoint { 'barbican':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('barbican_api_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[barbican_api_port],
      ip_addresses      => lookup('barbican_api_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('barbican_api_node_names', undef, undef, $controller_hosts_names_real),
      public_ssl_port   => $ports[barbican_api_ssl_port],
      service_network   => $barbican_network,
      mode              => 'http',
      listen_options    => merge($default_listen_options, $barbican_listen_opts),
      frontend_options  => merge($default_frontend_options, $barbican_frontend_opts),
      backend_options   => merge($default_backend_options, $barbican_backend_opts),
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $gnocchi {
    # NOTE(tkajinam): Gnocchi doesn't provide healthcheck API
    ::tripleo::haproxy::endpoint { 'gnocchi':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('gnocchi_api_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[gnocchi_api_port],
      ip_addresses      => lookup('gnocchi_api_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('gnocchi_api_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      public_ssl_port   => $ports[gnocchi_api_ssl_port],
      service_network   => $gnocchi_network,
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $swift_proxy_server {
    $swift_proxy_server_frontend_options = {
      'option'         => [ 'httplog', 'forwardfor' ],
      'timeout client' => '2m',
    }
    $swift_proxy_server_backend_options = {
      'option'         => [ 'httpchk GET /healthcheck' ],
      'balance'        => $haproxy_lb_mode_longrunning,
      'timeout server' => '2m',
    }
    $swift_proxy_server_listen_options = merge_hash_values($swift_proxy_server_frontend_options,
                                                              $swift_proxy_server_backend_options)
    ::tripleo::haproxy::endpoint { 'swift_proxy_server':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('swift_proxy_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[swift_proxy_port],
      ip_addresses      => lookup('swift_proxy_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('swift_proxy_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      listen_options    => merge($default_listen_options, $swift_proxy_server_listen_options),
      frontend_options  => merge($default_frontend_options, $swift_proxy_server_frontend_options),
      backend_options   => merge($default_backend_options, $swift_proxy_server_backend_options),
      public_ssl_port   => $ports[swift_proxy_ssl_port],
      service_network   => $swift_proxy_server_network,
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  $heat_api_vip = lookup('heat_api_vip', undef, undef, $controller_virtual_ip)
  $heat_ip_addresses = lookup('heat_api_node_ips', undef, undef, $controller_hosts_real)
  $heat_frontend_options = {
    'option'         => [ 'httplog', 'forwardfor' ],
    'timeout client' => '10m',
  }
  $heat_durability_options = {
    'option'         => [ 'tcpka', 'httpchk GET /healthcheck' ],
    'balance'        => $haproxy_lb_mode_longrunning,
    'timeout server' => '10m',
  }
  if $service_certificate {
    $heat_ssl_options = {
      'http-response' => "replace-header Location http://${public_virtual_ip}(.*) https://${public_virtual_ip}\\1",
    }
    $heat_listen_options = merge($default_listen_options, $heat_ssl_options, $heat_frontend_options)
    $heat_frontend_options_real = merge($default_frontend_options, $heat_ssl_options, $heat_frontend_options)
  } else {
    $heat_listen_options = merge($default_listen_options, $heat_frontend_options)
    $heat_frontend_options_real = merge($default_frontend_options, $heat_frontend_options)
  }
  $heat_listen_options_real = merge_hash_values($heat_listen_options, $heat_durability_options)
  $heat_backend_options = merge($default_backend_options, $heat_durability_options)

  if $heat_api {
    ::tripleo::haproxy::endpoint { 'heat_api':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => $heat_api_vip,
      service_port      => $ports[heat_api_port],
      ip_addresses      => $heat_ip_addresses,
      server_names      => lookup('heat_api_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      listen_options    => $heat_listen_options_real,
      frontend_options  => $heat_frontend_options_real,
      backend_options   => $heat_backend_options,
      public_ssl_port   => $ports[heat_api_ssl_port],
      service_network   => $heat_api_network,
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $heat_cfn {
    ::tripleo::haproxy::endpoint { 'heat_cfn':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => $heat_api_vip,
      service_port      => $ports[heat_cfn_port],
      ip_addresses      => $heat_ip_addresses,
      server_names      => lookup('heat_api_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      listen_options    => $heat_listen_options_real,
      frontend_options  => $heat_frontend_options_real,
      backend_options   => $heat_backend_options,
      public_ssl_port   => $ports[heat_cfn_ssl_port],
      service_network   => $heat_cfn_network,
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $horizon {
    class { 'tripleo::haproxy::horizon_endpoint':
      public_virtual_ip           => $public_virtual_ip,
      internal_ip                 => lookup('horizon_vip', undef, undef, $controller_virtual_ip),
      haproxy_listen_bind_param   => $haproxy_listen_bind_param,
      ip_addresses                => lookup('horizon_node_ips', undef, undef, $controller_hosts_real),
      server_names                => lookup('horizon_node_names', undef, undef, $controller_hosts_names_real),
      member_options              => union($haproxy_member_options, $internal_tls_member_options),
      public_certificate          => $service_certificate,
      use_internal_certificates   => $use_internal_certificates,
      internal_certificates_specs => $internal_certificates_specs,
      service_network             => $horizon_network,
    }
  }

  if $ironic {
    $ironic_frontend_opts = {
      'option' => [ 'httplog', 'forwardfor' ],
    }
    $ironic_backend_opts = {
      'option' => [ 'httpchk GET /healthcheck' ],
    }
    $ironic_listen_opts = merge_hash_values($ironic_frontend_opts,
                                            $ironic_backend_opts)
    ::tripleo::haproxy::endpoint { 'ironic':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('ironic_api_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[ironic_api_port],
      ip_addresses      => lookup('ironic_api_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('ironic_api_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      frontend_options  => merge($default_frontend_options, $ironic_frontend_opts),
      backend_options   => merge($default_backend_options, $ironic_backend_opts),
      listen_options    => merge($default_listen_options, $ironic_listen_opts),
      public_ssl_port   => $ports[ironic_api_ssl_port],
      service_network   => $ironic_network,
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $ironic_inspector {
    $ironic_inspector_frontend_opts = {
      'option' => [ 'httplog', 'forwardfor' ],
    }
    $ironic_inspector_backend_opts = {
      'option'  => [ 'httpchk' ],
      'balance' => $haproxy_lb_mode_longrunning
    }
    $ironic_inspector_listen_opts = merge_hash_values($ironic_inspector_frontend_opts,
                                                        $ironic_inspector_backend_opts)
    # NOTE(tkajinam): Ironic-inspector doesn't provide healthcheck API
    ::tripleo::haproxy::endpoint { 'ironic-inspector':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('ironic_inspector_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[ironic_inspector_port],
      ip_addresses      => lookup('ironic_inspector_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('ironic_inspector_node_names', undef, undef, $controller_hosts_names_real),
      public_ssl_port   => $ports[ironic_inspector_ssl_port],
      service_network   => $ironic_inspector_network,
      mode              => 'http',
      listen_options    => merge($default_listen_options, $ironic_inspector_listen_opts),
      frontend_options  => merge($default_frontend_options, $ironic_inspector_frontend_opts),
      backend_options   => merge($default_backend_options, $ironic_inspector_backend_opts),
    }
  }

  if $designate {
    $designate_frontend_opts = {
      'option' => [ 'httplog', 'forwardfor' ],
    }
    $designate_backend_opts = {
      'option' => [ 'httpchk GET /healthcheck' ],
    }
    $designate_listen_opts = merge_hash_values($designate_frontend_opts,
                                                  $designate_backend_opts)
    ::tripleo::haproxy::endpoint { 'designate':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('designate_api_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[designate_api_port],
      ip_addresses      => lookup('designate_api_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('designate_api_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      listen_options    => merge($default_listen_options, $designate_listen_opts),
      frontend_options  => merge($default_frontend_options, $designate_frontend_opts),
      backend_options   => merge($default_backend_options, $designate_backend_opts),
      public_ssl_port   => $ports[designate_api_ssl_port],
      service_network   => $designate_network,
    }

    # Create a reverse proxy for each miniDNS server running on the internal network so
    # external bind instances can access them without having to have access to the internal
    # network.
    #
    if $designate_mdns_proxy_baseport {
      $mdns_nodes = zip(
        lookup('designate_mdns_node_ips', undef, undef, $controller_hosts_real),
        lookup('designate_mdns_node_names', undef, undef, $controller_hosts_names_real))

      # TODO(beagles): it would preferable to implement in terms of
      # tripleo::haproxy::endpoint. I'm leaving as a follow up as
      # it seems like it would require more intrusive changes on a
      # shared and critical bit of haproxy related code.
      #
      $mdns_nodes.each |$index, $mdns_node| {
        if $use_backend_syntax {
          haproxy::frontend { "designate_mdns_${index}":
            ipaddress => $public_virtual_ip,
            ports     => String($designate_mdns_proxy_baseport + $index),
            mode      => 'tcp',
            options   => {
              'default_backend ' => "designate_mdns_${index}_be",
              'option'           => [ 'tcplog' ],
              },
          }

          haproxy::backend { "designate_mdns_${index}_be":
            mode    => 'tcp',
            options => {
              'option' => [ 'tcplog' ],
              },
          }
          $designate_minidns_service = "designate_mdns_${index}_be"
        } else {
          haproxy::listen { "designate_mdns_${index}":
            ipaddress => $public_virtual_ip,
            ports     => String($designate_mdns_proxy_baseport + $index),
            mode      => 'tcp',
            options   => {
              'option' => [ 'tcplog']
            }
          }
          $designate_minidns_service = "designate_mdns_${index}"
        }
        haproxy::balancermember { "designate_mdns_${index}":
          listening_service => $designate_minidns_service,
          ports             => '5354',
          ipaddresses       => $mdns_node[0],
          server_names      => $mdns_node[1],
          verifyhost        => false,
        }
      }
    }
  }

  if $metrics_qdr {
    $metrics_bind_opts = {
      "${public_virtual_ip}:${ports[metrics_qdr_port]}" => $haproxy_listen_bind_param,
    }
    if $use_backend_syntax {
      haproxy::frontend { 'metrics_qdr':
        bind             => $metrics_bind_opts,
        options          => {
          'default_backend' => 'metrics_qdr_be',
          'option'          => [ 'tcplog' ],
        },
        collect_exported => false,
      }
      haproxy::backend { 'metrics_qdr_be':
        options => {
          'option'    => [ 'tcp-check' ],
          'tcp-check' => ["connect port ${ports[metrics_qdr_port]}"],
        },
      }
      $metrics_qdr_service = 'metrics_qdr_be'
    } else {
      haproxy::listen { 'metrics_qdr':
        bind             => $metrics_bind_opts,
        options          => {
          'option'    => [ 'tcp-check', 'tcplog' ],
          'tcp-check' => ["connect port ${ports[metrics_qdr_port]}"],
        },
        collect_exported => false,
      }
      $metrics_qdr_service = 'metrics_qdr'
    }
    # Note(mmagr): while MetricsQdr service runs on all overcloud nodes, we need load balancing
    # only on controllers as those are only QDRs forming mesh (listening on connection
    # from QDRs running other nodes [storage, compute, etc.]). Sadly we don't have another
    # reasonable way to get list of internal_api interfaces of controllers than using list
    # of other services running only on controllers and also using internal_api network.
    # MetricsQdr will be refactored (split to QDR running on controller or on other node)
    # to better integrate, but for now we need this hack to enable the feature
    haproxy::balancermember { 'metrics_qdr':
      listening_service => $metrics_qdr_service,
      ports             => $ports[metrics_qdr_port],
      ipaddresses       => lookup('pacemaker_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('pacemaker_node_names', undef, undef, $controller_hosts_names_real),
      options           => union($haproxy_member_options, ['on-marked-down shutdown-sessions']),
      verifyhost        => false,
    }
  }

  if $mysql_clustercheck {
    $mysql_frontend_opts = {
      'option'         => [ 'tcpka', 'tcplog' ],
      'timeout client' => '90m',
      'maxconn'        => $mysql_max_conn
    }
    $mysql_backend_opts = {
      'option'         => [ 'tcpka', 'httpchk' ],
      'stick-table'    => 'type ip size 1000',
      'stick'          => 'on dst',
      'timeout server' => '90m',
    }
    $mysql_listen_opts = merge_hash_values($mysql_frontend_opts,
                                              $mysql_backend_opts)
    if $mysql_member_options {
        $mysql_member_options_real = $mysql_member_options
    } else {
        $mysql_member_options_real = ['backup', 'port 9200', 'on-marked-down shutdown-sessions', 'check', 'inter 1s']
    }
  } else {
    $mysql_frontend_opts = {
      'timeout client' => '90m',
      'maxconn'        => $mysql_max_conn
    }
    $mysql_backend_opts = {
      'timeout server' => '90m',
    }
    $mysql_listen_opts = merge_hash_values($mysql_frontend_opts,
                                              $mysql_backend_opts)
    if $mysql_member_options {
        $mysql_member_options_real = $mysql_member_options
    } else {
        $mysql_member_options_real = union($haproxy_member_options, ['backup'])
    }
  }

  if $mysql {
    if lookup('nova_is_additional_cell', undef, undef, undef) {
      $mysql_server_names_real = lookup('mysql_cell_node_names', undef, undef, $controller_hosts_names_real)
    } else {
      $mysql_server_names_real = lookup('mysql_node_names', undef, undef, $controller_hosts_names_real)
    }
    if $use_backend_syntax {
      haproxy::frontend { 'mysql':
        bind             => $mysql_bind_opts,
        options          => deep_merge($mysql_frontend_opts,
                                          { 'default_backend' => 'mysql_be' },
                                          $mysql_custom_frontend_options),
        collect_exported => false,
      }
      haproxy::backend { 'mysql_be':
        options => deep_merge($mysql_backend_opts, $mysql_custom_backend_options),
      }
      $mysql_service = 'mysql_be'
    } else {
      haproxy::listen { 'mysql':
        bind             => $mysql_bind_opts,
        options          => deep_merge($mysql_listen_opts, $mysql_custom_listen_options),
        collect_exported => false,
      }
      $mysql_service = 'mysql'
    }
    haproxy::balancermember { 'mysql-backup':
      listening_service => $mysql_service,
      ports             => '3306',
      ipaddresses       => lookup('mysql_node_ips', undef, undef, $controller_hosts_real),
      server_names      => $mysql_server_names_real,
      options           => $mysql_member_options_real,
    }
  }

  if $rabbitmq {
    if $use_backend_syntax {
      haproxy::frontend { 'rabbitmq':
        bind             => $rabbitmq_bind_opts,
        collect_exported => false,
        options          => {
          'default_backend' => 'rabbitmq_be',
          'option'          => [ 'tcpka', 'tcplog' ],
          'timeout'         => [ 'client 0' ],
        },
      }
      haproxy::backend { 'rabbitmq_be':
        options => {
          'option'  => [ 'tcpka' ],
          'timeout' => [ 'server 0' ],
        },
      }
      $rabbitmq_service = 'rabbitmq_be'
    } else {
      haproxy::listen { 'rabbitmq':
        bind             => $rabbitmq_bind_opts,
        options          => {
          'option'  => [ 'tcpka', 'tcplog' ],
          'timeout' => [ 'client 0', 'server 0' ],
        },
        collect_exported => false,
      }
      $rabbitmq_service = 'rabbitmq'
    }
    haproxy::balancermember { 'rabbitmq':
      listening_service => $rabbitmq_service,
      ports             => '5672',
      ipaddresses       => lookup('rabbitmq_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('rabbitmq_node_names', undef, undef, $controller_hosts_names_real),
      options           => $haproxy_member_options,
    }
  }

  if $etcd {
    ::tripleo::haproxy::endpoint { 'etcd':
      internal_ip     => lookup('etcd_vip', undef, undef, $controller_virtual_ip),
      service_port    => $ports[etcd_port],
      ip_addresses    => lookup('etcd_node_ips', undef, undef, $controller_hosts_real),
      server_names    => lookup('etcd_node_names', undef, undef, $controller_hosts_names_real),
      service_network => $etcd_network,
      member_options  => union($haproxy_member_options, $internal_tls_member_options),
      listen_options  => {
        'balance' => 'source',
      },
      backend_options => {
        'balance' => 'source',
      }
    }
  }

  if $docker_registry {
    ::tripleo::haproxy::endpoint { 'docker-registry':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('docker_registry_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[docker_registry_port],
      ip_addresses      => lookup('docker_registry_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('docker_registry_node_names', undef, undef, $controller_hosts_names_real),
      public_ssl_port   => $ports[docker_registry_ssl_port],
      service_network   => $docker_registry_network,
    }
  }

  if $redis {
    $redis_vip = lookup('redis_vip', undef, undef, $controller_virtual_ip)
    $redis_bind_opts = {
      "${redis_vip}:6379" => $haproxy_listen_bind_param,
    }

    if $enable_internal_tls {
      $redis_tcp_check_ssl_options = ['connect port 6379 ssl']
      $redis_ssl_member_options = ['check-ssl', "ca-file ${ca_bundle}"]
    } else {
      $redis_tcp_check_ssl_options = ['connect port 6379']
      $redis_ssl_member_options = []
    }
    if $redis_password {
      $redis_tcp_check_password_options = ["send AUTH\\ ${redis_password}\\r\\n",
                                            'expect string +OK']
    } else {
      $redis_tcp_check_password_options = []
    }
    $redis_tcp_check_connect_options = union($redis_tcp_check_ssl_options, $redis_tcp_check_password_options)
    $redis_tcp_check_common_options = ['send PING\r\n',
                                        'expect string +PONG',
                                        'send info\ replication\r\n',
                                        'expect string role:master',
                                        'send QUIT\r\n',
                                        'expect string +OK']
    $redis_tcp_check_options = $redis_tcp_check_connect_options + $redis_tcp_check_common_options
    if $use_backend_syntax {
      haproxy::frontend { 'redis':
        bind             => $redis_bind_opts,
        collect_exported => false,
        options          => {
          'timeout client'  => '90m',
          'default_backend' => 'redis_be',
          'option'          => [ 'tcplog' ],
        },
      }
      haproxy::backend { 'redis_be':
        options => {
          'timeout server' => '90m',
          'balance'        => 'first',
          'option'         => [ 'tcp-check' ],
          'tcp-check'      => $redis_tcp_check_options,
        },
      }
      $redis_service = 'redis_be'
    } else {
      haproxy::listen { 'redis':
        bind             => $redis_bind_opts,
        options          => {
          'balance'        => 'first',
          'timeout client' => '90m',
          'timeout server' => '90m',
          'option'         => [ 'tcp-check', 'tcplog' ],
          'tcp-check'      => $redis_tcp_check_options,
        },
        collect_exported => false,
      }
      $redis_service = 'redis'
    }
    haproxy::balancermember { 'redis':
      listening_service => $redis_service,
      ports             => '6379',
      ipaddresses       => lookup('redis_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('redis_node_names', undef, undef, $controller_hosts_names_real),
      options           => union($haproxy_member_options, ['on-marked-down shutdown-sessions'], $redis_ssl_member_options),
      verifyhost        => false,
    }
  }

  if $ceph_rgw {
    $ceph_rgw_backend_opts = {
      'option'  => [ 'httpchk GET /swift/healthcheck' ],
      'balance' => $haproxy_lb_mode_longrunning
    }
    $ceph_rgw_listen_opts = merge_hash_values($default_frontend_options,
                                                $ceph_rgw_backend_opts)
    ::tripleo::haproxy::endpoint { 'ceph_rgw':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('ceph_rgw_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[ceph_rgw_port],
      ip_addresses      => lookup('ceph_rgw_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('ceph_rgw_node_names', undef, undef, $controller_hosts_names_real),
      mode              => 'http',
      public_ssl_port   => $ports[ceph_rgw_ssl_port],
      service_network   => $ceph_rgw_network,
      listen_options    => merge($default_listen_options, $ceph_rgw_listen_opts),
      frontend_options  => $default_frontend_options,
      backend_options   => merge($default_backend_options, $ceph_rgw_backend_opts),
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
    }
  }

  if $octavia {
    $octavia_frontend_opts = {
      'option'    => [ 'httplog', 'forwardfor' ],
    }
    $octavia_backend_opts = {
      'hash-type' => 'consistent',
      'option'    => [ 'httpchk GET /healthcheck' ],
      'balance'   => 'source',
    }
    $octavia_listen_opts = merge_hash_values($octavia_frontend_opts,
                                                $octavia_backend_opts)
    ::tripleo::haproxy::endpoint { 'octavia':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('octavia_api_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[octavia_api_port],
      ip_addresses      => lookup('octavia_api_node_ips'),
      server_names      => lookup('octavia_api_node_names'),
      public_ssl_port   => $ports[octavia_api_ssl_port],
      service_network   => $octavia_network,
      mode              => 'http',
      member_options    => union($haproxy_member_options, $internal_tls_member_options),
      listen_options    => merge($default_listen_options, $octavia_listen_opts),
      frontend_options  => merge($default_frontend_options, $octavia_frontend_opts),
      backend_options   => $octavia_backend_opts,
    }
  }

  if $ovn_dbs and $ovn_dbs_manage_lb {
    # FIXME: is this config enough to ensure we only hit the first node in
    # ovn_northd_node_ips ?
    # We only configure ovn_dbs_vip in haproxy if HA for OVN DB servers is
    # disabled.
    # If HA is enabled, pacemaker configures the OVN DB servers accordingly.
    $ovn_db_frontend_opts = {
      'option'         => [ 'tcpka', 'tcplog' ],
      'timeout client' => '90m',
    }
    $ovn_db_backend_opts = {
      'option'         => [ 'tcpka' ],
      'timeout server' => '90m',
      'stick-table'    => 'type ip size 1000',
      'stick'          => 'on dst',
    }
    $ovn_db_listen_opts = merge_hash_values($ovn_db_frontend_opts,
                                              $ovn_db_backend_opts)
    ::tripleo::haproxy::endpoint { 'ovn_nbdb':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('ovn_dbs_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[ovn_nbdb_port],
      ip_addresses      => lookup('ovn_dbs_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('ovn_dbs_node_names', undef, undef, $controller_hosts_names_real),
      service_network   => $ovn_dbs_network,
      public_ssl_port   => $ports[ovn_nbdb_ssl_port],
      listen_options    => $ovn_db_listen_opts,
      frontend_options  => $ovn_db_frontend_opts,
      backend_options   => $ovn_db_backend_opts,
      mode              => 'tcp'
    }
    ::tripleo::haproxy::endpoint { 'ovn_sbdb':
      public_virtual_ip => $public_virtual_ip,
      internal_ip       => lookup('ovn_dbs_vip', undef, undef, $controller_virtual_ip),
      service_port      => $ports[ovn_sbdb_port],
      ip_addresses      => lookup('ovn_dbs_node_ips', undef, undef, $controller_hosts_real),
      server_names      => lookup('ovn_dbs_node_names', undef, undef, $controller_hosts_names_real),
      service_network   => $ovn_dbs_network,
      public_ssl_port   => $ports[ovn_sbdb_ssl_port],
      listen_options    => $ovn_db_listen_opts,
      frontend_options  => $ovn_db_frontend_opts,
      backend_options   => $ovn_db_backend_opts,
      mode              => 'tcp'
    }
  }
}