Repository: incubator-stratos Updated Branches: refs/heads/master 06bb5347f -> 130206b8d
Add puppet modules for php,tomcat,mysql Project: http://git-wip-us.apache.org/repos/asf/incubator-stratos/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-stratos/commit/130206b8 Tree: http://git-wip-us.apache.org/repos/asf/incubator-stratos/tree/130206b8 Diff: http://git-wip-us.apache.org/repos/asf/incubator-stratos/diff/130206b8 Branch: refs/heads/master Commit: 130206b8d4081b2de6acb58b16de2337d7e6804b Parents: 06bb534 Author: Manula Thantriwatte <[email protected]> Authored: Thu Mar 20 19:51:26 2014 +0530 Committer: Manula Thantriwatte <[email protected]> Committed: Thu Mar 20 19:51:26 2014 +0530 ---------------------------------------------------------------------- tools/puppet3/manifests/nodes.pp | 53 ++----- .../lb/templates/conf/axis2/axis2.xml.erb | 4 +- tools/puppet3/modules/mysql/manifests/init.pp | 26 ++++ .../modules/mysql/templates/000-default.erb | 41 ++++++ .../puppet3/modules/mysql/templates/my.cnf.erb | 127 ++++++++++++++++ tools/puppet3/modules/tomcat/manifests/init.pp | 41 +++--- .../modules/tomcat/templates/server.xml.erb | 143 +++++++++++++++++++ 7 files changed, 376 insertions(+), 59 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/130206b8/tools/puppet3/manifests/nodes.pp ---------------------------------------------------------------------- diff --git a/tools/puppet3/manifests/nodes.pp b/tools/puppet3/manifests/nodes.pp index cbcccd0..b73db8e 100644 --- a/tools/puppet3/manifests/nodes.pp +++ b/tools/puppet3/manifests/nodes.pp @@ -3,58 +3,25 @@ node 'base' { #essential variables $package_repo = 'http://10.4.128.7' $local_package_dir = '/mnt/packs' - $mb_ip = '54.251.234.223' + $mb_ip = '54.255.43.95' $mb_port = '5677' - $cep_ip = '54.251.234.223' + $cep_ip = '54.255.43.95' $cep_port = '7615' $truststore_password = 'wso2carbon' $java_distribution = 'jdk-7u7-linux-x64.tar.gz' $java_name = 'jdk1.7.0_07' $member_type_ip = 'private' - - #following variables required only if you want to install stratos using puppet. - #not supported in alpha version - # Service subdomains - #$domain = 'stratos.com' - #$as_subdomain = 'autoscaler' - #$management_subdomain = 'management' - - #$admin_username = 'admin' - #$admin_password = 'admin123' - - #$puppet_ip = '10.4.128.7' - - - - #$cc_ip = '10.4.128.9' - #$cc_port = '9443' - - #$sc_ip = '10.4.128.13' - #$sc_port = '9443' - - #$as_ip = '10.4.128.8' - #$as_port = '9443' - - #$git_hostname = 'git.stratos.com' - #$git_ip = '10.4.128.13' - - #$mysql_server = '10.4.128.13' - #$mysql_user = 'root' - #$mysql_password = 'root' - - #$bam_ip = '10.4.128.15' - #$bam_port = '7611' - - #$internal_repo_user = 'admin' - #$internal_repo_password = 'admin' + $lb_httpPort = '80' + $lb_httpsPort = '443' + $tomcat_version = '7.0.52' } # php cartridge node node /php/ inherits base { - $docroot = "/var/www" + $docroot = "/var/www/" $syslog="/var/log/apache2/error.log" - $samlalias="/var/www" + $samlalias="/var/www/" require java class {'agent':} class {'php':} @@ -72,9 +39,15 @@ node /lb/ inherits base { # tomcat cartridge node node /tomcat/ inherits base { + $docroot = "/mnt/apache-tomcat-7.0.52/webapps/" + $samlalias="/mnt/apache-tomcat-7.0.52/webapps/" + require java class {'agent':} class {'tomcat':} + + #install tomcat befor agent + Class['tomcat'] ~> Class['agent'] } # mysql cartridge node http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/130206b8/tools/puppet3/modules/lb/templates/conf/axis2/axis2.xml.erb ---------------------------------------------------------------------- diff --git a/tools/puppet3/modules/lb/templates/conf/axis2/axis2.xml.erb b/tools/puppet3/modules/lb/templates/conf/axis2/axis2.xml.erb index 8cd8792..83e208a 100755 --- a/tools/puppet3/modules/lb/templates/conf/axis2/axis2.xml.erb +++ b/tools/puppet3/modules/lb/templates/conf/axis2/axis2.xml.erb @@ -214,12 +214,12 @@ <!-- ================================================= --> <!--Default trasnport will be passthrough if you need to change please add it here --> <transportReceiver name="http" class="org.apache.synapse.transport.passthru.PassThroughHttpListener"> - <parameter name="port">8280</parameter> + <parameter name="port"><%= @lb_httpPort %></parameter> <parameter name="non-blocking"> true</parameter> <parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.PassThroughNHttpGetProcessor</parameter> </transportReceiver> <transportReceiver name="https" class="org.apache.synapse.transport.passthru.PassThroughHttpSSLListener"> - <parameter name="port" locked="false">8243</parameter> + <parameter name="port" locked="false"><%= @lb_httpsPort %></parameter> <parameter name="non-blocking" locked="false">true</parameter> <parameter name="httpGetProcessor" locked="false">org.wso2.carbon.transport.nhttp.api.PassThroughNHttpGetProcessor</parameter> <!--parameter name="bind-address" locked="false">hostname or IP address</parameter--> http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/130206b8/tools/puppet3/modules/mysql/manifests/init.pp ---------------------------------------------------------------------- diff --git a/tools/puppet3/modules/mysql/manifests/init.pp b/tools/puppet3/modules/mysql/manifests/init.pp index 83f2a55..d099057 100644 --- a/tools/puppet3/modules/mysql/manifests/init.pp +++ b/tools/puppet3/modules/mysql/manifests/init.pp @@ -53,4 +53,30 @@ class mysql{ Package['apache2'], ]; } + + file { '/etc/mysql/my.cnf': + ensure => present, + content => template('mysql/my.cnf.erb'), + notify => Service['apache2'], + require => [ + Package['phpmyadmin'], + Package['apache2'], + ]; + } + + file { '/etc/apache2/sites-enabled/000-default': + content => template('mysql/000-default.erb'), + notify => Service['apache2'], + require => [ + Package['phpmyadmin'], + Package['apache2'], + ]; + } + + exec { 'Restart MySQL' : + path => "/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin", + command => "/etc/init.d/mysql restart", + require => File['/etc/apache2/sites-enabled/000-default']; + } + } http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/130206b8/tools/puppet3/modules/mysql/templates/000-default.erb ---------------------------------------------------------------------- diff --git a/tools/puppet3/modules/mysql/templates/000-default.erb b/tools/puppet3/modules/mysql/templates/000-default.erb new file mode 100644 index 0000000..2b8c502 --- /dev/null +++ b/tools/puppet3/modules/mysql/templates/000-default.erb @@ -0,0 +1,41 @@ +<VirtualHost *:80> + ServerAdmin webmaster@localhost + + DocumentRoot /usr/share/phpmyadmin/ + <Directory /> + Options FollowSymLinks + AllowOverride None + </Directory> + <Directory /var/www/> + Options Indexes FollowSymLinks MultiViews + AllowOverride None + Order allow,deny + allow from all + </Directory> + + ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ + <Directory "/usr/lib/cgi-bin"> + AllowOverride None + Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch + Order allow,deny + Allow from all + </Directory> + + ErrorLog ${APACHE_LOG_DIR}/error.log + + # Possible values include: debug, info, notice, warn, error, crit, + # alert, emerg. + LogLevel warn + + CustomLog ${APACHE_LOG_DIR}/access.log combined + + Alias /doc/ "/usr/share/doc/" + <Directory "/usr/share/doc/"> + Options Indexes MultiViews FollowSymLinks + AllowOverride None + Order deny,allow + Deny from all + Allow from 127.0.0.0/255.0.0.0 ::1/128 + </Directory> + +</VirtualHost> http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/130206b8/tools/puppet3/modules/mysql/templates/my.cnf.erb ---------------------------------------------------------------------- diff --git a/tools/puppet3/modules/mysql/templates/my.cnf.erb b/tools/puppet3/modules/mysql/templates/my.cnf.erb new file mode 100644 index 0000000..37b2e9a --- /dev/null +++ b/tools/puppet3/modules/mysql/templates/my.cnf.erb @@ -0,0 +1,127 @@ +# +# The MySQL database server configuration file. +# +# You can copy this to one of: +# - "/etc/mysql/my.cnf" to set global options, +# - "~/.my.cnf" to set user-specific options. +# +# One can use all long options that the program supports. +# Run program with --help to get a list of available options and with +# --print-defaults to see which it would actually understand and use. +# +# For explanations see +# http://dev.mysql.com/doc/mysql/en/server-system-variables.html + +# This will be passed to all mysql clients +# It has been reported that passwords should be enclosed with ticks/quotes +# escpecially if they contain "#" chars... +# Remember to edit /etc/mysql/debian.cnf when changing the socket location. +[client] +port = 3306 +socket = /var/run/mysqld/mysqld.sock + +# Here is entries for some specific programs +# The following values assume you have at least 32M ram + +# This was formally known as [safe_mysqld]. Both versions are currently parsed. +[mysqld_safe] +socket = /var/run/mysqld/mysqld.sock +nice = 0 + +[mysqld] +# +# * Basic Settings +# +user = mysql +pid-file = /var/run/mysqld/mysqld.pid +socket = /var/run/mysqld/mysqld.sock +port = 3306 +basedir = /usr +datadir = /var/lib/mysql +tmpdir = /tmp +lc-messages-dir = /usr/share/mysql +skip-external-locking +# +# Instead of skip-networking the default is now to listen only on +# localhost which is more compatible and is not less secure. +bind-address = 0.0.0.0 +# +# * Fine Tuning +# +key_buffer = 16M +max_allowed_packet = 16M +thread_stack = 192K +thread_cache_size = 8 +# This replaces the startup script and checks MyISAM tables if needed +# the first time they are touched +myisam-recover = BACKUP +#max_connections = 100 +#table_cache = 64 +#thread_concurrency = 10 +# +# * Query Cache Configuration +# +query_cache_limit = 1M +query_cache_size = 16M +# +# * Logging and Replication +# +# Both location gets rotated by the cronjob. +# Be aware that this log type is a performance killer. +# As of 5.1 you can enable the log at runtime! +#general_log_file = /var/log/mysql/mysql.log +#general_log = 1 +# +# Error log - should be very few entries. +# +log_error = /var/log/mysql/error.log +# +# Here you can see queries with especially long duration +#log_slow_queries = /var/log/mysql/mysql-slow.log +#long_query_time = 2 +#log-queries-not-using-indexes +# +# The following can be used as easy to replay backup logs or for replication. +# note: if you are setting up a replication slave, see README.Debian about +# other settings you may need to change. +#server-id = 1 +#log_bin = /var/log/mysql/mysql-bin.log +expire_logs_days = 10 +max_binlog_size = 100M +#binlog_do_db = include_database_name +#binlog_ignore_db = include_database_name +# +# * InnoDB +# +# InnoDB is enabled by default with a 10MB datafile in /var/lib/mysql/. +# Read the manual for more InnoDB related options. There are many! +# +# * Security Features +# +# Read the manual, too, if you want chroot! +# chroot = /var/lib/mysql/ +# +# For generating SSL certificates I recommend the OpenSSL GUI "tinyca". +# +# ssl-ca=/etc/mysql/cacert.pem +# ssl-cert=/etc/mysql/server-cert.pem +# ssl-key=/etc/mysql/server-key.pem + + + +[mysqldump] +quick +quote-names +max_allowed_packet = 16M + +[mysql] +#no-auto-rehash # faster start of mysql but no tab completition + +[isamchk] +key_buffer = 16M + +# +# * IMPORTANT: Additional settings that can override those from this file! +# The files must end with '.cnf', otherwise they'll be ignored. +# +!includedir /etc/mysql/conf.d/ http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/130206b8/tools/puppet3/modules/tomcat/manifests/init.pp ---------------------------------------------------------------------- diff --git a/tools/puppet3/modules/tomcat/manifests/init.pp b/tools/puppet3/modules/tomcat/manifests/init.pp index 20b0bb3..6b759fa 100644 --- a/tools/puppet3/modules/tomcat/manifests/init.pp +++ b/tools/puppet3/modules/tomcat/manifests/init.pp @@ -1,30 +1,33 @@ class tomcat( - $version = '7.0.50', $owner = 'root', $group = 'root', $target = '/mnt', ){ - $package_name = "apache-tomcat-${version}" + $package_name = "apache-tomcat-${tomcat_version}" $service_code = 'apache-tomcat' $tomcat_home = "${target}/${package_name}" tag($service_code) - file { "${target}/packs": - ensure => directory, + file { + "${target}/packs": + ensure => directory; + + "${tomcat_home}/conf/server.xml": + ensure => present, + content => template('tomcat/server.xml.erb'), + require => Exec['Extract tomcat package']; } - exec { - 'Download tomcat package': - path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', - cwd => "$target/packs", - unless => "test -f ${target}/${package_name}.tar.gz", - command => "wget -q ${package_repo}/${package_name}.tar.gz", - logoutput => 'on_failure', - creates => "${local_dir}/${package_name}.tar.gz", - require => File["${target}/packs"]; + file { + "/${target}/packs/apache-tomcat-${tomcat_version}.tar.gz": + ensure => present, + source => "puppet:///modules/tomcat/apache-tomcat-${tomcat_version}.tar.gz", + require => File["${target}/packs"]; + } + exec { 'Extract tomcat package': path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', cwd => $target, @@ -32,13 +35,16 @@ class tomcat( command => "tar xvfz ${target}/packs/${package_name}.tar.gz", logoutput => 'on_failure', creates => "${target}/${tomcat_home}/conf", - require => Exec['Download tomcat package']; - + require => File["/${target}/packs/apache-tomcat-${tomcat_version}.tar.gz"]; + 'Set tomcat home permission': path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', cwd => $target, - command => "chown -R ${owner} ${tomcat_home}; chmod 755 ${tomcat_home}", - require => Exec['Extract tomcat package']; + command => "chown -R ${owner} ${tomcat_home}; chmod -R 755 ${tomcat_home}", + require => [ + Exec['Extract tomcat package'], + File["${tomcat_home}/conf/server.xml"], + ]; 'Start tomcat': path => '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', @@ -49,3 +55,4 @@ class tomcat( require => Exec['Set tomcat home permission']; } } + http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/130206b8/tools/puppet3/modules/tomcat/templates/server.xml.erb ---------------------------------------------------------------------- diff --git a/tools/puppet3/modules/tomcat/templates/server.xml.erb b/tools/puppet3/modules/tomcat/templates/server.xml.erb new file mode 100644 index 0000000..5d7e9ed --- /dev/null +++ b/tools/puppet3/modules/tomcat/templates/server.xml.erb @@ -0,0 +1,143 @@ +<?xml version='1.0' encoding='utf-8'?> +<!-- + 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. +--> +<!-- Note: A "Server" is not itself a "Container", so you may not + define subcomponents such as "Valves" at this level. + Documentation at /docs/config/server.html + --> +<Server port="8005" shutdown="SHUTDOWN"> + <!-- Security listener. Documentation at /docs/config/listeners.html + <Listener className="org.apache.catalina.security.SecurityListener" /> + --> + <!--APR library loader. Documentation at /docs/apr.html --> + <Listener className="org.apache.catalina.core.AprLifecycleListener" SSLEngine="on" /> + <!--Initialize Jasper prior to webapps are loaded. Documentation at /docs/jasper-howto.html --> + <Listener className="org.apache.catalina.core.JasperListener" /> + <!-- Prevent memory leaks due to use of particular java/javax APIs--> + <Listener className="org.apache.catalina.core.JreMemoryLeakPreventionListener" /> + <Listener className="org.apache.catalina.mbeans.GlobalResourcesLifecycleListener" /> + <Listener className="org.apache.catalina.core.ThreadLocalLeakPreventionListener" /> + + <!-- Global JNDI resources + Documentation at /docs/jndi-resources-howto.html + --> + <GlobalNamingResources> + <!-- Editable user database that can also be used by + UserDatabaseRealm to authenticate users + --> + <Resource name="UserDatabase" auth="Container" + type="org.apache.catalina.UserDatabase" + description="User database that can be updated and saved" + factory="org.apache.catalina.users.MemoryUserDatabaseFactory" + pathname="conf/tomcat-users.xml" /> + </GlobalNamingResources> + + <!-- A "Service" is a collection of one or more "Connectors" that share + a single "Container" Note: A "Service" is not itself a "Container", + so you may not define subcomponents such as "Valves" at this level. + Documentation at /docs/config/service.html + --> + <Service name="Catalina"> + + <!--The connectors can use a shared executor, you can define one or more named thread pools--> + <!-- + <Executor name="tomcatThreadPool" namePrefix="catalina-exec-" + maxThreads="150" minSpareThreads="4"/> + --> + + + <!-- A "Connector" represents an endpoint by which requests are received + and responses are returned. Documentation at : + Java HTTP Connector: /docs/config/http.html (blocking & non-blocking) + Java AJP Connector: /docs/config/ajp.html + APR (HTTP/AJP) Connector: /docs/apr.html + Define a non-SSL HTTP/1.1 Connector on port 9090 + --> + <Connector port="8080" protocol="HTTP/1.1" + connectionTimeout="20000" + redirectPort="8443" /> + <!-- A "Connector" using the shared thread pool--> + <!-- + <Connector executor="tomcatThreadPool" + port="9090" protocol="HTTP/1.1" + connectionTimeout="20000" + redirectPort="8443" /> + --> + <!-- Define a SSL HTTP/1.1 Connector on port 8443 + This connector uses the JSSE configuration, when using APR, the + connector should be using the OpenSSL style configuration + described in the APR documentation --> + <!-- + <Connector port="8443" protocol="HTTP/1.1" SSLEnabled="true" + maxThreads="150" scheme="https" secure="true" + clientAuth="false" sslProtocol="TLS" /> + --> + + <!-- Define an AJP 1.3 Connector on port 8009 --> + <Connector port="8009" protocol="AJP/1.3" redirectPort="8443" /> + + + <!-- An Engine represents the entry point (within Catalina) that processes + every request. The Engine implementation for Tomcat stand alone + analyzes the HTTP headers included with the request, and passes them + on to the appropriate Host (virtual host). + Documentation at /docs/config/engine.html --> + + <!-- You should set jvmRoute to support load-balancing via AJP ie : + <Engine name="Catalina" defaultHost="localhost" jvmRoute="jvm1"> + --> + <Engine name="Catalina" defaultHost="localhost"> + + <!--For clustering, please take a look at documentation at: + /docs/cluster-howto.html (simple how to) + /docs/config/cluster.html (reference documentation) --> + <!-- + <Cluster className="org.apache.catalina.ha.tcp.SimpleTcpCluster"/> + --> + + <!-- Use the LockOutRealm to prevent attempts to guess user passwords + via a brute-force attack --> + <Realm className="org.apache.catalina.realm.LockOutRealm"> + <!-- This Realm uses the UserDatabase configured in the global JNDI + resources under the key "UserDatabase". Any edits + that are performed against this UserDatabase are immediately + available for use by the Realm. --> + <Realm className="org.apache.catalina.realm.UserDatabaseRealm" + resourceName="UserDatabase"/> + </Realm> + + <Host name="localhost" appBase="webapps" + unpackWARs="true" autoDeploy="true"> + + <!-- SingleSignOn valve, share authentication between web applications + Documentation at: /docs/config/valve.html --> + <!-- + <Valve className="org.apache.catalina.authenticator.SingleSignOn" /> + --> + + <!-- Access log processes all example. + Documentation at: /docs/config/valve.html + Note: The pattern used is equivalent to using pattern="common" --> + <Valve className="org.apache.catalina.valves.AccessLogValve" directory="logs" + prefix="localhost_access_log." suffix=".txt" + pattern="%h %l %u %t "%r" %s %b" /> + + </Host> + </Engine> + </Service> +</Server> +
