Repository: stratos Updated Branches: refs/heads/4.0.0 862a71d67 -> 37372c2e7
STRATOS-699 - HAProxy Puppet Configurations Project: http://git-wip-us.apache.org/repos/asf/stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/stratos/commit/335a4e34 Tree: http://git-wip-us.apache.org/repos/asf/stratos/tree/335a4e34 Diff: http://git-wip-us.apache.org/repos/asf/stratos/diff/335a4e34 Branch: refs/heads/4.0.0 Commit: 335a4e342e3209be686467bd996f18a5573dbdaa Parents: 6a45473 Author: Dinesh Bandara <[email protected]> Authored: Thu Jul 3 16:40:48 2014 +0530 Committer: Dinesh Bandara <[email protected]> Committed: Thu Jul 3 16:40:48 2014 +0530 ---------------------------------------------------------------------- tools/puppet3/modules/haproxy/files/README.txt | 12 +++ tools/puppet3/modules/haproxy/manifests/init.pp | 70 ++++++++++++++++++ .../modules/haproxy/manifests/initialize.pp | 77 ++++++++++++++++++++ .../modules/haproxy/manifests/push_templates.pp | 30 ++++++++ .../puppet3/modules/haproxy/manifests/start.pp | 25 +++++++ .../templates/bin/haproxy-extension.sh.erb | 48 ++++++++++++ .../haproxy/templates/conf/jndi.properties.erb | 33 +++++++++ 7 files changed, 295 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/stratos/blob/335a4e34/tools/puppet3/modules/haproxy/files/README.txt ---------------------------------------------------------------------- diff --git a/tools/puppet3/modules/haproxy/files/README.txt b/tools/puppet3/modules/haproxy/files/README.txt new file mode 100644 index 0000000..b9c3baa --- /dev/null +++ b/tools/puppet3/modules/haproxy/files/README.txt @@ -0,0 +1,12 @@ +This folder should have following: + +1. apache-stratos-haproxy-extension-${version}.zip file + +2. Folder having a name as $mb_type which is defined in the nodes.pp file. + +eg: +if $mb_type = activemq, folder structure of this folder would be: +>$ls +>activemq apache-stratos-haproxy-extension-4.0.0.zip + +3. Under $mb_type folder, please add all the client jars, that should be copied to the haproxy-extension's lib directory. http://git-wip-us.apache.org/repos/asf/stratos/blob/335a4e34/tools/puppet3/modules/haproxy/manifests/init.pp ---------------------------------------------------------------------- diff --git a/tools/puppet3/modules/haproxy/manifests/init.pp b/tools/puppet3/modules/haproxy/manifests/init.pp new file mode 100755 index 0000000..f8ce3ed --- /dev/null +++ b/tools/puppet3/modules/haproxy/manifests/init.pp @@ -0,0 +1,70 @@ +#-------------------------------------------------------------- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# +#-------------------------------------------------------------- + +class haproxy( + $network_partition_id = $stratos_network_partition_id, + $service_filter = $stratos_load_balanced_service_type, + $version = '4.0.0', + $owner = 'root', + $group = 'root', + $target = '/mnt', +){ + + $deployment_code = 'haproxy-extension' + $carbon_version = $version + $service_code = 'haproxy-extension' + $carbon_home = "${target}/apache-stratos-${service_code}-${carbon_version}" + + tag($service_code) + + $service_templates = [ + 'bin/haproxy-extension.sh', + 'conf/jndi.properties', + ] + + package { ['haproxy', 'socat']: + ensure => installed, + } + + haproxy::initialize { $deployment_code: + repo => $package_repo, + version => $carbon_version, + service => $service_code, + local_dir => $local_package_dir, + target => $target, + owner => $owner, + } + + haproxy::push_templates { + $service_templates: + target => $carbon_home, + require => Haproxy::Initialize[$deployment_code]; + } + + haproxy::start { $deployment_code: + owner => $owner, + target => $carbon_home, + require => [ + Package['haproxy'], + Haproxy::Push_templates[$service_templates], + ]; + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/335a4e34/tools/puppet3/modules/haproxy/manifests/initialize.pp ---------------------------------------------------------------------- diff --git a/tools/puppet3/modules/haproxy/manifests/initialize.pp b/tools/puppet3/modules/haproxy/manifests/initialize.pp new file mode 100755 index 0000000..65bd795 --- /dev/null +++ b/tools/puppet3/modules/haproxy/manifests/initialize.pp @@ -0,0 +1,77 @@ +#-------------------------------------------------------------- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 haproxy::initialize ($repo, $version, $service, $local_dir, $target, $owner,) { + file { + "/${local_dir}/apache-stratos-${service}-${version}.zip": + ensure => present, + source => "puppet:///modules/haproxy/apache-stratos-${service}-${version}.zip"; + } + + exec { + "creating_target_for_${name}": + path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + command => "mkdir -p ${target}"; + + "creating_local_package_repo_for_${name}": + path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/java/bin/', + unless => "test -d ${local_dir}", + command => "mkdir -p ${local_dir}"; + + "downloading_stratos${service}-${version}.zip_for_${name}": + path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + cwd => $local_dir, + unless => "test -f ${local_dir}/apache-stratos-${service}-${version}.zip", + command => "puppet:///modules/haproxy/apache-stratos-${service}-${version}.zip", + logoutput => 'on_failure', + creates => "${local_dir}/apache-stratos-${service}-${version}.zip", + timeout => 0, + require => Exec["creating_local_package_repo_for_${name}", "creating_target_for_${name}"]; + + "extracting_stratos${service}-${version}.zip_for_${name}": + path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + cwd => $target, + unless => "test -d ${target}/apache-stratos-${service}-${version}/conf", + command => "unzip ${local_dir}/apache-stratos-${service}-${version}.zip", + logoutput => 'on_failure', + creates => "${target}/apache-stratos-${service}-${version}/repository", + timeout => 0, + require => Exec["downloading_stratos${service}-${version}.zip_for_${name}"]; + + "setting_permission_for_${name}": + path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', + cwd => $target, + command => "chown -R ${owner}:${owner} ${target}/apache-stratos-${service}-${version} ; + chmod -R 755 ${target}/apache-stratos-${service}-${version}", + logoutput => 'on_failure', + timeout => 0, + require => Exec["extracting_stratos${service}-${version}.zip_for_${name}"]; + } + + file { "/${target}/apache-stratos-${service}-${version}/lib": + path => "/${target}/apache-stratos-${service}-${version}/lib", + ensure => directory, + require => Exec["setting_permission_for_${name}"], + source => ["puppet:///modules/haproxy/${mb_type}"], + sourceselect => all, + recurse => true, + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/335a4e34/tools/puppet3/modules/haproxy/manifests/push_templates.pp ---------------------------------------------------------------------- diff --git a/tools/puppet3/modules/haproxy/manifests/push_templates.pp b/tools/puppet3/modules/haproxy/manifests/push_templates.pp new file mode 100755 index 0000000..b8ba309 --- /dev/null +++ b/tools/puppet3/modules/haproxy/manifests/push_templates.pp @@ -0,0 +1,30 @@ +#-------------------------------------------------------------- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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 haproxy::push_templates ($target) { + file { "${target}/${name}": + ensure => present, + owner => $haproxy::owner, + group => $haproxy::group, + mode => '0755', + content => template("haproxy/${name}.erb"), + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/335a4e34/tools/puppet3/modules/haproxy/manifests/start.pp ---------------------------------------------------------------------- diff --git a/tools/puppet3/modules/haproxy/manifests/start.pp b/tools/puppet3/modules/haproxy/manifests/start.pp new file mode 100755 index 0000000..351c4c3 --- /dev/null +++ b/tools/puppet3/modules/haproxy/manifests/start.pp @@ -0,0 +1,25 @@ +# ---------------------------------------------------------------------------- +# Copyright 2005-2013 WSO2, Inc. http://www.wso2.org +# +# 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 haproxy::start ($target, $owner) { + exec { "starting_${name}": + user => $owner, + path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/java/bin/', + unless => "test -f ${target}/wso2carbon.lck", + cwd => "${target}/bin/", + command => "touch ${target}/wso2carbon.lck; bash haproxy-extension.sh > /dev/null 2>&1 &", + } +} http://git-wip-us.apache.org/repos/asf/stratos/blob/335a4e34/tools/puppet3/modules/haproxy/templates/bin/haproxy-extension.sh.erb ---------------------------------------------------------------------- diff --git a/tools/puppet3/modules/haproxy/templates/bin/haproxy-extension.sh.erb b/tools/puppet3/modules/haproxy/templates/bin/haproxy-extension.sh.erb new file mode 100755 index 0000000..7f17d2e --- /dev/null +++ b/tools/puppet3/modules/haproxy/templates/bin/haproxy-extension.sh.erb @@ -0,0 +1,48 @@ +#!/bin/bash +# -------------------------------------------------------------- +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# +# -------------------------------------------------------------- + +echo "Starting haproxy extension..." +script_path="$( cd -P "$( dirname "$SOURCE" )" && pwd )/`dirname $0`" +lib_path=${script_path}/../lib/ +class_path=`echo ${lib_path}/*.jar | tr ' ' ':'` +#properties="-Dhaproxy.private.ip=<%= @ipaddress %> +properties="-Dhaproxy.private.ip=0.0.0.0 + -Djndi.properties.dir=${script_path}/../conf + -Dexecutable.file.path=haproxy + -Dtemplates.path=${script_path}/../templates + -Dtemplates.name=haproxy.cfg.template + -Dscripts.path=${script_path}/../scripts + -Dconf.file.path=/tmp/haproxy.cfg + -Dstats.socket.file.path=/tmp/haproxy-stats.socket + -Dlog4j.properties.file.path=${script_path}/../conf/log4j.properties + -Djavax.net.ssl.trustStore=${script_path}/../security/client-truststore.jks + -Djavax.net.ssl.trustStorePassword=<%= @truststore_password %> + -Dthrift.receiver.ip=<%= @cep_ip %> + -Dthrift.receiver.port=<%= @cep_port %> + -Dnetwork.partition.id=<%= @network_partition_id %> + <% if @stratos_lb_category == 'service.aware.load.balancer' %>-Dstratos.topology.service.filter=service-name=<%= @service_filter %><% end %> + -Dcep.stats.publisher.enabled=true" + +# Uncomment below line to enable remote debugging +#debug="-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005" + +/opt/java/bin/java -cp "${class_path}" ${properties} ${debug} org.apache.stratos.haproxy.extension.Main $* http://git-wip-us.apache.org/repos/asf/stratos/blob/335a4e34/tools/puppet3/modules/haproxy/templates/conf/jndi.properties.erb ---------------------------------------------------------------------- diff --git a/tools/puppet3/modules/haproxy/templates/conf/jndi.properties.erb b/tools/puppet3/modules/haproxy/templates/conf/jndi.properties.erb new file mode 100644 index 0000000..e4b4462 --- /dev/null +++ b/tools/puppet3/modules/haproxy/templates/conf/jndi.properties.erb @@ -0,0 +1,33 @@ +# +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. +# +# This is a generated file and will be overwritten at the next load balancer startup. +# Please use loadbalancer.conf for updating mb-ip, mb-port and templates/jndi.properties.template +# file for updating other configurations. +# +<% if @mb_type == 'wso2mb' %> + connectionfactoryName=topicConnectionfactory + connectionfactory.topicConnectionfactory=amqp://admin:admin@carbon/carbon?brokerlist='tcp://<%= @mb_ip %>:<%= @mb_port %>' + java.naming.factory.initial=org.wso2.andes.jndi.PropertiesFileInitialContextFactory + java.naming.provider.url=<%= @carbon_home %>/conf/jndi.properties +<% end %> +<% if @mb_type == 'activemq' %> + connectionfactoryName=TopicConnectionFactory + java.naming.provider.url=tcp://<%= @mb_ip %>:<%= @mb_port %> + java.naming.factory.initial=org.apache.activemq.jndi.ActiveMQInitialContextFactory +<% end %>
