Skip to content
Snippets Groups Projects
haproxy.pp 13.9 KiB
Newer Older
  • Learn to ignore specific revisions
  • Quentin MACHU's avatar
    Quentin MACHU committed
    class iaas::profile::haproxy (
      $stats_enabled = undef,
      $stats_ports = undef,
      $stats_refresh = undef,
      $stats_login = undef,
      $stats_password = undef,
      $stats_uri = undef,
    
      $percona_servers = undef,
    
      $main_address = undef,
      $admin_address = undef,
    
      $controller_hosts = undef,
      $controller_ips = undef,
    
    Quentin MACHU's avatar
    Quentin MACHU committed
    ) {
    
      if $admin_address == undef {
        $internal_address = $main_address
      } else {
        $internal_address = $admin_address
      }
    
      class { '::haproxy':
        defaults_options => {
    
    Riccardo Bucchi's avatar
    Riccardo Bucchi committed
    #     'log' => 'global',
    
    Riccardo Bucchi's avatar
    Riccardo Bucchi committed
    #	'tcplog',
    
    	'dontlognull',
    	'redispatch',
          ],
    
          'retries' => '3',
          'timeout' => [
            'http-request 10s',
    
    	'http-keep-alive 10s',
    
          'maxconn' => '4096',
    
    Quentin MACHU's avatar
    Quentin MACHU committed
        haproxy::listen { 'stats':
    
    Quentin MACHU's avatar
    Quentin MACHU committed
          mode => 'http',
          ports => $stats_ports,
          options => {
            'stats' => [
              'enable',
              'hide-version',
              "refresh ${stats_refresh}",
              'show-node',
              "auth ${stats_login}:${stats_password}",
              "uri ${stats_uri}"
            ],
          }
        }
      }
    
    
      haproxy::listen { 'percona_cluster':
    
        ipaddress => $internal_address,
    
        mode => 'tcp',
        ports => '3306',
        options => {
    
          'option' => ['tcplog','httpchk','tcpka'],
    
          'balance' => 'leastconn',
    
    Riccardo Bucchi's avatar
    Riccardo Bucchi committed
          'timeout' => [
             'client 90m',
             'server 90m',
           ],
    
      if $percona_servers != undef { 
    
         haproxy::balancermember { 'percona_cluster_prior':
           listening_service => 'percona_cluster',
           ports             => '3307',
    
           server_names      => $percona_servers[priority_hostname],
           ipaddresses       => $percona_servers[priority_ip],
    
           options           => 'check port 9200',
         }
         haproxy::balancermember { 'percona_cluster_secondaries':
           listening_service => 'percona_cluster',
           ports             => '3307',
    
           server_names      => $percona_servers[hostnames], 
           ipaddresses       => $percona_servers[ips], 
    
           options           => 'check port 9200 backup',
         }
    
      haproxy::listen { 'keystone_admin_cluster':
        bind    => {"${internal_address}:35357"  => [],},
    
          'option' => ['tcplog','httpchk','tcpka'],
    
          'balance' => 'source',
    
      haproxy::balancermember { 'keystone_admin_cluster':
         listening_service => 'keystone_admin_cluster',
         ports             => '35357',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
    
      if $admin_address == undef {
           haproxy::listen { 'keystone_api_cluster':
             bind    => {
                     "${main_address}:5000"  => [],
                   },
             options => {
               'option' => ['tcplog','httpchk','tcpka'],
               'balance' => 'source',
             }
           }
      } else {
      	haproxy::listen { 'keystone_api_cluster':
        		bind    => {
        		        "${main_address}:5000"  => [],
        		        "${internal_address}:5000" => [],
        		      },
        		options => {
        		  'option' => ['tcplog','httpchk','tcpka'],
        		  'balance' => 'source',
        		}
           }
    
      haproxy::balancermember { 'keystone_api_cluster':
         listening_service => 'keystone_api_cluster',
         ports             => '5000',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
      }
    
    
      if $admin_address == undef {
           haproxy::listen { 'glance_api_cluster':
             ipaddress => $main_address,
             ports => '9292',
             options => {
    
               'option' => ['tcplog','httpchk','tcpka'],
    
               'balance' => 'source',
             }
           }
      } else {
           haproxy::listen { 'glance_api_cluster':
             bind    => {
               "${main_address}:9292"  => [],
    
               "${internal_address}:9292" => [],
    
               'option' => ['tcplog','httpchk','tcpka'],
    
      }
    
      haproxy::balancermember { 'glance_api_cluster':
         listening_service => 'glance_api_cluster',
         ports             => '9292',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
      }
    
    
     haproxy::listen { 'glance_registry_cluster':
    
        ipaddress => $internal_address,
    
        ports => '9191',
        options => {
    
          'option' => ['tcplog','tcpka'],
    
          'balance' => 'source',
        }
      }
    
      haproxy::balancermember { 'glance_registry_cluster':
         listening_service => 'glance_registry_cluster',
         ports             => '9191',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
    
      if $admin_address == undef {
            haproxy::listen { 'cinder_api_cluster':
              ipaddress => $main_address,
              ports => '8776',
              options => {
    
                'option' => ['tcplog','httpchk','tcpka'],
    
                'balance' => 'source',
              }
            }
      } else {
            haproxy::listen { 'cinder_api_cluster':
              bind    => {
                "${main_address}:8776"  => [],
    
                "${internal_address}:8776" => [],
    
                'option' => ['tcplog','httpchk','tcpka'],
    
      }
    
      haproxy::balancermember { 'cinder_api_cluster':
         listening_service => 'cinder_api_cluster',
         ports             => '8776',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
      }
    
    
           haproxy::listen { 'nova_compute_api_cluster':
    
              ipaddress => $main_address,
              ports => '8774',
              options => {
    
                'option' => ['tcplog','httpchk','tcpka'],
    
            haproxy::listen { 'nova_compute_api_cluster':
    
                "${internal_address}:8774" => [],
    
                'option' => ['tcplog','httpchk','tcpka'],
    
      haproxy::balancermember { 'nova_compute_api_cluster':
         listening_service => 'nova_compute_api_cluster',
    
         ports             => '8774',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
      }
    
     haproxy::listen { 'nova_metadata_api_cluster':
    
        ipaddress => $internal_address,
    
        ports => '8775',
        options => {
    
          'option' => ['tcplog','tcpka'],
    
          'balance' => 'source',
        }
      }
    
      haproxy::balancermember { 'nova_metadata_api_cluster':
         listening_service => 'nova_metadata_api_cluster',
         ports             => '8775',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
      }
    
    
      if $admin_address == undef {
            haproxy::listen { 'nova_novncproxy_cluster':
               ipaddress => $main_address,
               ports => '6080',
               options => {
    
                 'option' => ['tcplog','tcpka'],
    
                 'balance' => 'source',
               }
             }
        } else {
            haproxy::listen { 'nova_novncproxy_cluster':
              bind    => {
                "${main_address}:6080"  => [],
    
                "${internal_address}:6080" => [],
    
                'option' => ['tcplog','tcpka'],
    
      }
    
      haproxy::balancermember { 'nova_novncproxy_cluster':
         listening_service => 'nova_novncproxy_cluster',
         ports             => '6080',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
      }
    
    
        if $admin_address == undef {
            haproxy::listen { 'nova_ec2_api_cluster':
              ipaddress => $main_address,
              ports => '8773',
              options => {
    
                'option' => ['tcplog','tcpka'],
    
                'balance' => 'source',
              }
            }
          } else {
            haproxy::listen { 'nova_ec2_api_cluster':
              bind    => {
                "${main_address}:8773"  => [],
    
                "${internal_address}:8773" => [],
    
                'option' => ['tcplog','tcpka'],
    
      }
    
      haproxy::balancermember { 'nova_ec2_api_cluster':
         listening_service => 'nova_ec2_api_cluster',
         ports             => '8773',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
      }
    
    
    
      if $admin_address == undef {
           haproxy::listen { 'neutron_api_cluster':
             ipaddress => $main_address,
             ports => '9696',
             options => {
               'option' => ['tcplog','httpchk','tcpka'],
               'balance' => 'source',
             }
           }
      } else {
     	 haproxy::listen { 'neutron_api_cluster':
     	   bind    => {
     	           "${main_address}:9696"  => [],
     	           "${internal_address}:9696" => [],
     	         },
     	   options => {
     	     'option' => ['tcplog','httpchk','tcpka'],
     	     'balance' => 'source',
     	   }
     	 }
    
      }
    
      haproxy::balancermember { 'neutron_api_cluster':
         listening_service => 'neutron_api_cluster',
         ports             => '9696',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
      }
    
    
      if $admin_address == undef {
           haproxy::listen { 'heat_api_cluster':
             ipaddress => $main_address,
             ports => '8004',
             options => {
               'option' => ['tcplog','httpchk','tcpka'],
               'balance' => 'source',
             }
           }
      } else {
     	 haproxy::listen { 'heat_api_cluster':
     	   bind    => {
     	           "${main_address}:8004"  => [],
     	           "${internal_address}:8004" => [],
     	         },
     	   options => {
     	     'option' => ['tcplog','httpchk','tcpka'],
     	     'balance' => 'source',
     	   }
     	 }
    
      }
    
      haproxy::balancermember { 'heat_api_cluster':
         listening_service => 'heat_api_cluster',
         ports             => '8004',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
      }
    
    
      if $admin_address == undef {
           haproxy::listen { 'heat_api_cfn_cluster':
             ipaddress => $main_address,
             ports => '8000',
             options => {
               'option' => ['tcplog','httpchk','tcpka'],
               'balance' => 'source',
             }
           }
      } else {
      	haproxy::listen { 'heat_api_cfn_cluster':
      	   bind    => {
      	          "${main_address}:8000"  => [],
      	          "${internal_address}:8000" => [],
      	        },
      	  options => {
      	    'option' => ['tcplog','httpchk','tcpka'],
      	    'balance' => 'source',
      	  }
      	}
    
      }
    
      haproxy::balancermember { 'heat_api_cfn_cluster':
         listening_service => 'heat_api_cfn_cluster',
         ports             => '8000',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
      }
    
    
      if $admin_address == undef {
           haproxy::listen { 'heat_api_watch_cluster':
             ipaddress => $main_address,
             ports => '8003',
             options => {
               'option' => ['tcplog','httpchk','tcpka'],
               'balance' => 'source',
             }
           }
      } else {
     	 haproxy::listen { 'heat_api_watch_cluster':
     	   bind    => {
     	           "${main_address}:8003"  => [],
     	           "${internal_address}:8003" => [],
     	         },
     	   options => {
     	     'option' => ['tcplog','httpchk','tcpka'],
     	     'balance' => 'source',
     	   }
     	 }
    
      }
    
      haproxy::balancermember { 'heat_api_watch_cluster':
         listening_service => 'heat_api_watch_cluster',
         ports             => '8003',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
      }
    
    
      if $admin_address == undef {
           haproxy::listen { 'ceilometer_api_cluster':
             ipaddress => $main_address,
             ports => '8777',
             options => {
               'option' => ['tcplog','tcpka'],
               'balance' => 'source',
             }
           }
      } else {
     	 haproxy::listen { 'ceilometer_api_cluster':
     	   bind    => {
     	           "${main_address}:8777"  => [],
     	           "${internal_address}:8777" => [],
     	         },
     	   options => {
     	     'option' => ['tcplog','tcpka'],
     	     'balance' => 'source',
     	   }
     	 }
    
      }
    
      haproxy::balancermember { 'ceilometer_api_cluster':
         listening_service => 'ceilometer_api_cluster',
         ports             => '8777',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
      }
    
    
      if $admin_address == undef {
           haproxy::listen { 'horizon_api_cluster':
             ipaddress => $main_address,
             ports => '80',
    	 mode	=> 'http',
             options => {
               'option' => ['httpchk','tcpka','forwardfor'],
               'balance' => 'source',
             }
           }
      } else {
     	 haproxy::listen { 'horizon_api_cluster':
     	   bind    => {
     	           "${main_address}:80"  => [],
     	           "${internal_address}:80" => [],
     	         },
     	   mode => 'http',
     	   options => {
     	     'option' => ['httpchk','tcpka','forwardfor'],
     	     'balance' => 'source',
     	   }
     	 }
    
      }
    
      haproxy::balancermember { 'horizon_cluster':
         listening_service => 'horizon_cluster',
         ports             => '80',
         server_names      => $controller_hosts,
         ipaddresses       => $controller_ips,
         options           => 'check inter 2000 rise 2 fall 5',
      }