From 11f4138051256e37ec10514794a9a0c02864bae6 Mon Sep 17 00:00:00 2001 From: Swann Croiset Date: Wed, 16 Dec 2015 16:32:09 +0100 Subject: [PATCH] Configure HAProxy for Elasticsearch and Kibana Change-Id: Ib6176f6ec851f3fcb647faf9d4649f83d7acaffe --- .../puppet/manifests/haproxy.pp | 65 +++++++++++++++++++ deployment_tasks.yaml | 9 +++ pre_build_hook | 4 +- 3 files changed, 76 insertions(+), 2 deletions(-) create mode 100644 deployment_scripts/puppet/manifests/haproxy.pp diff --git a/deployment_scripts/puppet/manifests/haproxy.pp b/deployment_scripts/puppet/manifests/haproxy.pp new file mode 100644 index 0000000..d765154 --- /dev/null +++ b/deployment_scripts/puppet/manifests/haproxy.pp @@ -0,0 +1,65 @@ +# Copyright 2015 Mirantis, Inc. +# +# 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. +# +$plugin_name = 'elasticsearch_kibana' +$es_port = '9200' +$nginx_port = '80' +$vip_name = 'es_vip_mgmt' + +$network_metadata = hiera_hash('network_metadata') +if ! $network_metadata['vips'][$vip_name] { + fail('Elasticsearch VIP is not defined') +} +$vip = $network_metadata['vips'][$vip_name]['ipaddr'] +notice($vip) +$roles = [ $plugin_name ] +$es_nodes = get_nodes_hash_by_roles($network_metadata, $roles) +$es_address_map = get_node_to_ipaddr_map_by_network_role($es_nodes, 'elasticsearch') +$es_nodes_ips = values($es_address_map) +$es_nodes_names = keys($es_address_map) +notice($es_address_map) +notice($es_nodes_ips) + +Openstack::Ha::Haproxy_service { + server_names => $es_nodes_names, + ipaddresses => $es_nodes_ips, + public => false, + public_ssl => false, + internal => true, + internal_virtual_ip => $vip, +} + +openstack::ha::haproxy_service { 'elasticsearch-rest': + order => '920', + listen_port => $es_port, + balancermember_port => $es_port, + balancermember_options => 'check inter 10s fastinter 2s downinter 3s rise 3 fall 3', + haproxy_config_options => { + 'option' => ['httplog', 'http-keep-alive', 'prefer-last-server'], + 'balance' => 'roundrobin', + 'mode' => 'http', + } +} + +openstack::ha::haproxy_service { 'kibana': + order => '921', + listen_port => $nginx_port, + balancermember_port => $nginx_port, + balancermember_options => 'check inter 10s fastinter 2s downinter 3s rise 3 fall 3', + haproxy_config_options => { + 'option' => ['httplog', 'http-keep-alive', 'prefer-last-server'], + 'balance' => 'roundrobin', + 'mode' => 'http', + } +} diff --git a/deployment_tasks.yaml b/deployment_tasks.yaml index 7d2b3a8..6c306c6 100644 --- a/deployment_tasks.yaml +++ b/deployment_tasks.yaml @@ -40,3 +40,12 @@ puppet_modules: "puppet/modules" timeout: 120 +- id: es-kibana-haproxy + type: puppet + groups: [elasticsearch_kibana] + requires: [cluster-haproxy, es-virtual-ip] + required_for: [deploy_end] + parameters: + puppet_manifest: "puppet/manifests/haproxy.pp" + puppet_modules: "puppet/modules" + timeout: 120 diff --git a/pre_build_hook b/pre_build_hook index 05c5ff6..c47b64b 100755 --- a/pre_build_hook +++ b/pre_build_hook @@ -43,7 +43,7 @@ mkdir -p "${KIBANA_FOLDER}" wget -qO- "${KIBANA_TARBALL_URL}" | tar -C "${KIBANA_FOLDER}" --strip-components=1 -xz # Extract dependent manifests from fuel-library -rm -rf "${MODULES_DIR:?}"/{l23network,osnailyfacter,cluster,pacemaker_wrappers,pacemaker,openstack} +rm -rf "${MODULES_DIR:?}"/{l23network,osnailyfacter,cluster,pacemaker_wrappers,pacemaker,openstack,haproxy} wget -qO- "${FUEL_LIB_TARBALL_URL}" | \ tar -C "${MODULES_DIR}" --strip-components=3 -zxvf - \ - fuel-library-${FUEL_LIB_COMMIT}/deployment/puppet/{l23network,osnailyfacter,cluster,pacemaker_wrappers,pacemaker,openstack} + fuel-library-${FUEL_LIB_COMMIT}/deployment/puppet/{l23network,osnailyfacter,cluster,pacemaker_wrappers,pacemaker,openstack,haproxy}