My favorites | Sign in
Project Home Downloads Wiki Issues Source
Search
for
UsingTheCloudToolsMavenPlugin  
Using the Cloud Tools Maven plugin
Featured
Updated Feb 4, 2010 by chris.e....@gmail.com

Using the Cloud Tools Maven Plugin

Cloud Tools provides a Maven plugin for deploying and managing web applications on Amazon EC2 and running load tests.

The plug-in lets you manage one or more named clusters. The information about each cluster is stored in an XML file in your ~/.cloudtools directory. By default, the Maven plugin manages a cluster called maven-cluster but you can specify a cluster name using the cloudtools.cluster.name property.

You can use this plugin even if you are not building your application with maven. See here for instructions.

Configuration

To use the plugin there are three things that you must do

  1. Create an AwsPropertiesFile
  2. Configure the plugin in your application's pom.xml

Here is an example configuration of the plugin in your web application's pom.xml

<repositories>
   <repository>
      <id>pia-repository</id>
      <url>http://www.pojosinaction.com/repository</url>
   </repository>
</repositories>

<pluginRepositories>
   <pluginRepository>
      <id>pia-repository</id>
      <url>http://www.pojosinaction.com/repository</url>
      <snapshots>
      <enabled>true</enabled>
      </snapshots>
   </pluginRepository>
</pluginRepositories>

<build>

  <plugins>

     <plugin>
                <groupId>net.chrisrichardson</groupId>
                <artifactId>cloudtools-maven-plugin</artifactId>
                <configuration>
                    <awsPropertiesFile>${cloudtools.plugin.awsPropertiesFile}</awsPropertiesFile>
                    <schemaName>ptrack</schemaName>
                    <schemaUsers>
                        <param>
                            ptrack:ptrack
                        </param>
                    </schemaUsers>
                    <sqlScripts>
                        <param>script1.sql</param>
                        <param>script2.sql</param>
                    </sqlScripts>
                    <catalinaOptsBuilder>
                        {builder, databasePrivateDnsName, slaves ->
                            builder.arg("-server")
                            builder.arg("-Xmx1000m")
                            builder.prop("com.sun.management.jmxremote")
                            builder.prop("com.sun.management.jmxremote.port", 8091)
                            builder.prop("com.sun.management.jmxremote.authenticate", false)
                            builder.prop("com.sun.management.jmxremote.ssl", false)
                            builder.prop("ptrack.application.environment", "ec2") 
                            builder.prop("jdbc.db.server", databasePrivateDnsName)}
                    </catalinaOptsBuilder>
                </configuration>
            </plugin>

  </plugins>

</build>

The plugin configuration creates a ClusterSpec that is used by EC2Deploy to manage the cluster.

Maven Goals

There are the following goals:

GoalDescriptionRequired properties
cloudtools:deployDeploy the application on EC2 (note mvn package must have been run)
cloudtools:redeployRedeploy the application (note mvn package must have been run)
cloudtools:jmeterRun a jmeter load testcloudtools.jmxTestFile, cloudtools.threadCount
cloudtools:stopTerminate the instances
cloudtools:dbsavesave a database snapshot in S3cloudtools.s3.path
cloudtools:dbrestorerestore the database from S3cloudtools.s3.path
cloudtools:clonecreates a copy of the clustercloudtools.new.cluster.name
cloudtools:describedescribes the cluster
cloudtools:listlists the available clusters
cloudtools:stopshutdown the cluster

In addition, there are some features for using Amazon EBS.

Comment by h...@deplabs.com, Oct 30, 2008

use clusterName element in project/build/plugins/plugin(cloudtools-maven-plugin)/configuration/ to specify the cluster definition file to use. (keeps different projects from overwriting the maven-cluster.xml file.

Comment by nowuk...@gmail.com, Dec 9, 2008

I am new to Maven and tried to follow instructions in this page and assumed that the plugin will just be automatically installed. It did not. I had to check it out from SVN, build it and it got added to local repository. Some instruction would help for us newbies. :-D

Also, it is not clear to me where to define everything, if I am using Maven plugin. For example, bucket name. Am I supposed to edit EC2Deploy and hard code these values into the template/config files somewhere or can I just do this in cluster spec file. A sample file with all possible options would make it clearer.

Finally, I hacked some files out of the example, e.g. .sql files, just to try it and when I run 'mvn cloudtools:deploy' it fails because ptrack.foo table is not being created.

INFO? ------------------------------------------------------------------------ ERROR? FATAL ERROR INFO? ------------------------------------------------------------------------ INFO? net.chrisrichardson.ec2deployer.core.ProcessExecutionException?: Command <ssh on ec2-174-129-135-250.compute-1.amazonaws.com: mysql ptrack < /tmp/tmp-ptrack-dml/script1.sql> execution failed with an exitValue of 1 INFO? ------------------------------------------------------------------------

I did the in-file search in the project for 'CREATE TABLE ...' statement and I do not see one. Also--and I am assuming here--the rest of the project fails since the DB scripts fail. I mean, even if the DB setup failed, I would assume that Apache would be running and responding, which does not seem to be the case.

I guess, I am back to my question: Am I supposed to rebuild EC2Deploy and hard code my configuration or is it all to be specified in clusterSpec file and pom.xml?

Comment by nowuk...@gmail.com, Dec 9, 2008

Also, nowhere does it tell me that I have to have a bucket that already exists. The first time I run deploy it throws errors, because bucket does not exist. The follow-up runs do not throw error, because there is a bucket created. I am sure I am missing something.

Comment by project member chris.e....@gmail.com, Dec 16, 2008

I just noticed your comments.

1. The plugin should be downloaded automatically. You should not need to build it.

2. Some temporary bucket names are currently hardwired into EC2deploy. if they don't it creates them automatically (and prints out an exception).

3. Everything should be configured in pom.xml / aws.properties.

Please send email to the group for more timely answers.

Chris

Comment by aforas...@gmail.com, Aug 2, 2010

Hi Group, My task is to write a script; which will auto deploy the .war deployed in another region of EC2, It should be geniric also..can any one guide how to proceed?.

Region1 ( war file already deployed) ------Script-----> Region2 needs copying and deployment.

thanks, Ashish

Comment by raghuvar...@gmail.com, Nov 24, 2010

Hi when I try to run mvn cloudtools:deploy I am getting following error ERROR? net.chrisrichardson.cloudtools.maven.plugins.DeployMojo#execute?() caused a linkage error (java.lang.NoClassDefFoundError?) and may be out-of-date.

Can any one tell help me how to solve this. Thanks in advance, Raghu Varma.


Sign in to add a comment
Powered by Google Project Hosting