Updated Branches: refs/heads/master 236a1b375 -> 123a16b74
Puppetting the Load-balancer cartridge Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/94660906 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/94660906 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/94660906 Branch: refs/heads/master Commit: 94660906af5fa1d51785d6bd95ddca79980c585c Parents: 8195f22 Author: Melan Nimesh <[email protected]> Authored: Thu Jan 9 22:16:40 2014 +0530 Committer: Isuru <[email protected]> Committed: Fri Jan 10 15:45:52 2014 +0530 ---------------------------------------------------------------------- tools/puppet/manifests/classes/lb_cartridge.pp | 133 ++++++++++++++++++++ tools/puppet/manifests/classes/stratos.pp | 92 ++++++++++++++ tools/puppet/manifests/nodes.pp | 29 +++++ tools/puppet/templates/load-balancer/.erb | 0 4 files changed, 254 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/94660906/tools/puppet/manifests/classes/lb_cartridge.pp ---------------------------------------------------------------------- diff --git a/tools/puppet/manifests/classes/lb_cartridge.pp b/tools/puppet/manifests/classes/lb_cartridge.pp new file mode 100644 index 0000000..4531d5a --- /dev/null +++ b/tools/puppet/manifests/classes/lb_cartridge.pp @@ -0,0 +1,133 @@ +class stratos::lb ( $version, + $offset=0, + $tribes_port=4000, + $config_db=governance, + $maintenance_mode=true, + $owner=root, + $group=root, + $adc_host="lb.strato.org", + $adc_port=9445, + $target="/opt", + $cartridge_type, + $generic, + $mb_ip, + $mb_port, + $cep_ip, + $cep_port, + $java_truststore, + $java_truststore_password) { + + + $deployment_code = "load-balancer" + + $stratos_version = $version + $service_code = "load-balancer" + $carbon_home = "${target}/apache-stratos-load-balancer-${stratos_version}" + $mgt_port = 8280 + $offset + + + $common_templates = [ + # "conf/datasources/master-datasources.xml", + # "conf/etc/logging-config.xml", + # "conf/log4j.properties" + ] + + + tag ($service_code) + + define push_templates ( $directory, $target ) { + + file { "${target}/repository/${name}": + owner => $owner, + group => $group, + mode => 755, + content => template("${directory}/${name}.erb"), + ensure => present, + } + } + + clean { $deployment_code: + mode => $maintenance_mode, + target => $carbon_home, + } + + initialize { $deployment_code: + version => $stratos_version, + mode => $maintenance_mode, + service => $service_code, + local_dir => $local_package_dir, + owner => $owner, + target => $target, + require => Stratos::Clean[$deployment_code], + } + + deploy { $deployment_code: + service => $service_code, + security => "true", + owner => $owner, + group => $group, + target => $carbon_home, + require => Stratos::Initialize[$deployment_code], + } + + + + push_templates { + $service_templates: + target => $carbon_home, + directory => $service_code, + require => Stratos::Deploy[$deployment_code]; + + $common_templates: + target => $carbon_home, + directory => "commons", + require => Stratos::Deploy[$deployment_code], + } + + start { $deployment_code: + owner => $owner, + target => $carbon_home, + require => [ Stratos::Initialize[$deployment_code], + Push_templates[$service_templates], + Push_templates[$common_templates], + ], + } + + file { "/opt/apache-stratos-cartridge-agent": + ensure => directory + } + + + file { "/opt/apache-stratos-cartridge-agent/apache-stratos-cartridge-agent-4.0.0-SNAPSHOT-bin.zip": + source => "puppet:///commons/apache-stratos-cartridge-agent-4.0.0-SNAPSHOT-bin.zip", + ensure => present, + } + + + file { "/opt/apache-stratos-cartridge-agent/cartridge-agent.sh": + source => "puppet:///commons/cartridge-agent.sh", + ensure => present, + } + + + file { "/opt/apache-stratos-cartridge-agent/get-launch-params.rb": + source => "puppet:///commons/get-launch-params.rb", + ensure => present, + } + + + file {"/tmp/puppet-payload": + ensure => present, + content => ",MB_IP=${mb_ip},MB_PORT=${mb_port},CEP_IP=${cep_ip},CEP_PORT=${cep_port},CERT_TRUSTSTORE=${java_truststore},TRUSTSTORE_PASSWORD=${java_truststore_password}", + } + + exec {"run_agent_script-$deployment_code": + command => "/opt/apache-stratos-cartridge-agent/cartridge-agent.sh", + require => File["/tmp/puppet-payload", + "/opt/apache-stratos-cartridge-agent/apache-stratos-cartridge-agent-4.0.0-SNAPSHOT-bin.zip", + "/opt/apache-stratos-cartridge-agent/cartridge-agent.sh", + "/opt/apache-stratos-cartridge-agent/get-launch-params.rb"]; + } + +} + http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/94660906/tools/puppet/manifests/classes/stratos.pp ---------------------------------------------------------------------- diff --git a/tools/puppet/manifests/classes/stratos.pp b/tools/puppet/manifests/classes/stratos.pp new file mode 100644 index 0000000..b1cc50b --- /dev/null +++ b/tools/puppet/manifests/classes/stratos.pp @@ -0,0 +1,92 @@ +# Parent of a startos service deployment + +class stratos { + +## Cleans the previous deployment. If the maintenance mode is set to true, this will only kill the running service. + + define clean ( $mode, $target ) { + + exec { "remove_${name}_poop": + path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/java/bin/", + onlyif => "test -d ${target}/repository", + command => $mode ? { + "true" => "kill -9 `cat ${target}/stratos.pid` ; /bin/echo Killed", + "false" => "kill -9 `cat ${target}/stratos.pid` ; rm -rf ${target}", + "fresh" => "kill -9 `cat ${target}/stratos.pid` ; rm -rf ${target} ; rm -f ${local_dir}/apache-stratos-${service}-${version}.zip", + }, + } + } + +## Initializing the deployment by placing a customized script in /opt/bin which will download and extract the pack. + + define initialize ( $version, $service, $local_dir, $target, $mode, $owner ) { + + file { "${local_dir}/apache-stratos-${service}-${version}.zip": + source => "puppet:///commons/apache-stratos-${service}-${version}.zip", + ensure => present, + require => [ Exec["creating_target_for_${name}"], + Exec["creating_local_package_repo_for_${name}"] ]; + } + + 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}"; + + + "extracting_apache-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}/repository", + command => "unzip ${local_dir}/apache-stratos-${service}-${version}.zip", + logoutput => "on_failure", + creates => "${target}/apache-stratos-${service}-${version}/repository", + timeout => 0, + require => File["${local_dir}/apache-stratos-${service}-${version}.zip"]; + + "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_apache-stratos-${service}-${version}.zip_for_${name}"]; + + + "update_loadbalancer_conf": + path => ["/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"], + cwd => $target, + command => "sed -i 's/mb-ip: .*;/mb-ip: $mb_ip;/g;s/mb-port: .*;/mb-port: $mb_port;/g;s/cep-ip: .*;/cep-ip: $cep_ip;/g;s/cep-port: .*;/cep-port: $cep_port;/g' ${target}/apache-stratos-${service}-${version}/repository/conf/loadbalancer.conf", + logoutput => "on_failure", + timeout => 0, + require => Exec["setting_permission_for_${name}"]; + + + } + + } + + +## Executes the deployment by pushing all necessary configurations and patches + + define deploy ( $service, $security, $target, $owner, $group ) { + + + } + +## Starts the service once the deployment is successful. + + define start ( $target, $owner ) { + exec { "strating_${name}": + user => $owner, + path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/java/bin/", + command => "${target}/bin/stratos.sh > /dev/null 2>&1 &", + creates => "${target}/repository/wso2server.log", + } + } +} http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/94660906/tools/puppet/manifests/nodes.pp ---------------------------------------------------------------------- diff --git a/tools/puppet/manifests/nodes.pp b/tools/puppet/manifests/nodes.pp index ba933c9..f67c6ba 100755 --- a/tools/puppet/manifests/nodes.pp +++ b/tools/puppet/manifests/nodes.pp @@ -64,3 +64,32 @@ node /[0-9]{1,12}.default.php/ { } } +node /[0-9]{1,12}.default.lb/ inherits confignode{ + $server_ip = $ec2_local_ipv4 + + include java + + class {"stratos::lb": + version => "4.0.0-SNAPSHOT", + offset => 0, + tribes_port => 4100, + maintenance_mode => "false", + owner => "root", + group => "root", + stage => "deploy", + adc_host => "sc.stratos.org", + adc_port => 9445, + cartridge_type => "load-balancer", + generic => 1, + mb_ip => "54.251.196.18", + mb_port => "5677", + cep_ip => "54.251.196.18", + cep_port => "7615", + java_truststore => "client-truststore.jks", + java_truststore_password => "wso2carbon", + + + } + +} + http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/94660906/tools/puppet/templates/load-balancer/.erb ---------------------------------------------------------------------- diff --git a/tools/puppet/templates/load-balancer/.erb b/tools/puppet/templates/load-balancer/.erb new file mode 100644 index 0000000..e69de29
