From 4b74492e1e7f1adae2b1e9e6661c0856829090e9 Mon Sep 17 00:00:00 2001 From: Yanis Guenane Date: Mon, 16 Jun 2014 15:03:07 -0400 Subject: [PATCH] loadbalancer: Use binding class but keep listen_https compat Remove the use of the listen_https class but remain compatible with previous use of listen_https --- manifests/loadbalancer/binding.pp | 22 ++++---------- manifests/loadbalancer/listen_http.pp | 2 +- manifests/loadbalancer/listen_https.pp | 40 ------------------------- spec/classes/cloud_loadbalancer_spec.rb | 8 ++--- 4 files changed, 11 insertions(+), 61 deletions(-) delete mode 100644 manifests/loadbalancer/listen_https.pp diff --git a/manifests/loadbalancer/binding.pp b/manifests/loadbalancer/binding.pp index 935d2a18..d24fc195 100644 --- a/manifests/loadbalancer/binding.pp +++ b/manifests/loadbalancer/binding.pp @@ -55,22 +55,12 @@ define cloud::loadbalancer::binding ( fail("${ip} is not part of VIP pools.") } } - if 'ssl' in $bind_options { - cloud::loadbalancer::listen_https { $name : - ports => $port, - httpchk => $httpchk, - options => $options, - listen_ip => $listen_ip_real, - bind_options => $bind_options; - } - } else { - cloud::loadbalancer::listen_http { $name : - ports => $port, - httpchk => $httpchk, - options => $options, - listen_ip => $listen_ip_real, - bind_options => $bind_options; - } + cloud::loadbalancer::listen_http { $name : + ports => $port, + httpchk => $httpchk, + options => $options, + listen_ip => $listen_ip_real, + bind_options => $bind_options; } } diff --git a/manifests/loadbalancer/listen_http.pp b/manifests/loadbalancer/listen_http.pp index 9b33200d..b94ee7b2 100644 --- a/manifests/loadbalancer/listen_http.pp +++ b/manifests/loadbalancer/listen_http.pp @@ -27,7 +27,7 @@ define cloud::loadbalancer::listen_http( $options_basic = {'mode' => 'http', 'balance' => 'roundrobin', 'http-check' => 'expect ! rstatus ^5', - 'option' => ['tcpka', 'tcplog', $httpchk] } + 'option' => ['tcpka', 'forwardfor', 'tcplog', $httpchk] } $options_custom = merge($options_basic, $options) diff --git a/manifests/loadbalancer/listen_https.pp b/manifests/loadbalancer/listen_https.pp deleted file mode 100644 index 67fc221a..00000000 --- a/manifests/loadbalancer/listen_https.pp +++ /dev/null @@ -1,40 +0,0 @@ -# -# Copyright (C) 2014 eNovance SAS -# -# Licensed under the Apache License, Version 2.0 (the "License"); you may -# not use this file except in compliance with the License. You may obtain -# a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT -# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the -# License for the specific language governing permissions and limitations -# under the License. -# -# Define:: -# -# cloud::loadbalancer::listen_https -# -define cloud::loadbalancer::listen_https( - $ports = 'unset', - $httpchk = 'ssl-hello-chk', - $options = {}, - $bind_options = [], - $listen_ip = '0.0.0.0') { - - $options_basic = {'mode' => 'http', - 'balance' => 'roundrobin', - 'http-check' => 'expect ! rstatus ^5', - 'option' => ['tcpka', 'forwardfor', 'tcplog', $httpchk] } - - $options_custom = merge($options_basic, $options) - - haproxy::listen { $name: - ipaddress => $listen_ip, - ports => $ports, - options => $options_custom, - bind_options => $bind_options, - } -} diff --git a/spec/classes/cloud_loadbalancer_spec.rb b/spec/classes/cloud_loadbalancer_spec.rb index 7d0982a0..ce21585d 100644 --- a/spec/classes/cloud_loadbalancer_spec.rb +++ b/spec/classes/cloud_loadbalancer_spec.rb @@ -207,7 +207,7 @@ describe 'cloud::loadbalancer' do :ports => '6082', :options => { 'mode' => 'http', - 'option' => ['tcpka','tcplog','httpchk GET /'], + 'option' => ['tcpka', 'forwardfor', 'tcplog','httpchk GET /'], 'http-check' => 'expect ! rstatus ^5', 'balance' => 'leastconn', 'timeout server' => '120m', @@ -309,7 +309,7 @@ describe 'cloud::loadbalancer' do :ports => '8774', :options => { 'mode' => 'http', - 'option' => ['tcpka','forwardfor','tcplog','ssl-hello-chk'], + 'option' => ['tcpka','forwardfor','tcplog','httpchk'], 'http-check' => 'expect ! rstatus ^5', 'balance' => 'roundrobin', }, @@ -328,7 +328,7 @@ describe 'cloud::loadbalancer' do :ports => '8776', :options => { 'mode' => 'http', - 'option' => ['tcpka','tcplog','httpchk'], + 'option' => ['tcpka','forwardfor','tcplog', 'httpchk'], 'http-check' => 'expect ! rstatus ^5', 'balance' => 'roundrobin', }, @@ -349,7 +349,7 @@ describe 'cloud::loadbalancer' do :options => { 'mode' => 'tcp', 'http-check' => 'expect ! rstatus ^5', - 'option' => ['tcpka','tcplog','ssl-hello-chk'], + 'option' => ['tcpka','forwardfor','tcplog', 'ssl-hello-chk'], 'cookie' => 'sessionid prefix', 'balance' => 'leastconn', },