Deploying Packages to a Service
From ControlTier
- See a screencast
This page describes how to deploy one or more packages that have been loaded into the repository via the Service type.
See the Creating packages page for instructions on adding new packages.
Service's parent type Deployment" defines a set of commands used to manage the deployment cycle. Two commands in particular of note are:
- Packages-Install: This command dispatches the "Install" command to each configured package dependency
- Deploy: This command invokes Packages-Install.
It is likely that you are deploying packages to an application service so the "Service" type is more appropriate. Because Service is a subtype of Deployment it inherits the Packages-Install and Deploy commands. Service also overrides "Deploy" to ensure the service is restarted after package installation.
Contents |
Setup
These instructions use an example where the Apache Tomcat server software will be deployed.
The first step is to load a package to the repository. Follow the instructions to load the tomcat zip distribution as described in Creating packages#Upload_an_existing_file_as_a_package.
Use the find-resources command to ensure the apache-tomcat-5.5.26.zip package was indeed uploaded to the repository:
$ ctl -p demo -m ProjectBuilder -c find-resources -- -type zip | |--(zip) apache-tomcat-5.5.26.zip
To define the package dependencies two kinds of steps occur. Firstly, the resources are defined. Secondly, dependency relationships are established between the resources. You can define the resources either by XML or via the Workbench GUI.
XML configuration
Using XML configuration is probably the quickest and most succinct way carry out the two-step process of registering objects and assigning dependency relationships. The example below reflects the model described in the earlier graphic.
File listing: tomcat1.xml
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE project PUBLIC "-//ControlTier Software Inc.//DTD Project Document 1.0//EN"
"project.dtd">
<project>
<!--
**
** Describe the deployment:
**
-->
<deployment
type="Service"
name="tomcat1"
description="The Tomcat deployment."
installRoot="${env.CTIER_ROOT}/demo"
basedir="${env.CTIER_ROOT}/demo" >
<!--
**
** Define a child dependency on this tomcat zip:
**
-->
<resources>
<resource name="apache-tomcat-5.5.26.zip" type="zip" />
</resources>
<!--
**
** Define a parent dependency to the node where you are running this demo.
**
-->
<referrers replace="false">
<!--
** Change this line to one that matches your node name:
-->
<resource type="Node" name="centos2"/>
</referrers>
</deployment>
</project>
Notice the value for the "installRoot" attribute in the XML. This is specifying the directory where the apache zip will be extracted.
Load the XML file with the load-resources command:
ctl -m ProjectBuilder -c load-resources -- -filename tomcat1.xml Loading "/home/alexh/ctier/pkgs/tomcat1.xml" ... 1 file(s) have been successfully validated. Processing /home/alexh/ctier/pkgs/tomcat1.xml to /home/alexh/ctier/ctl/var/tmp/projectxml-324396149.xml Loading stylesheet /home/alexh/ctier/ctl/projects/demo/modules/ProjectBuilder/lib/load-resources/projectxml/project.xsl Mapping XML to properties ... Collecting object attributes ... Batching object attribute updates ... Batching resource and referrer updates ... Executing batch update ...
You can run another ProjectBuilder command to query the server to see if the new Service was defined. This time run find-resources:
$ ctl -p demo -m ProjectBuilder -c find-resources -- -type Service Deleting: /Users/alexh/ctier/ctl/var/sessions/find-resources/find.session ... |--(Service) tomcat1 ...
GUI configuration
GUI configuration via Workbench's web interface is practical when the individual objects are already registered. This means the packages have already been uploaded to the repository and the nodes exist in NodeManager (probably when the CTL installation occurred). Given those assumptions setup should really just include the creation of the tomcat1 Service resource and the dependency setup.
- Create Service resource. Navigate to the Service type, and create an object called "tomcat1". Fill in the form as described in the XML example, specifying description, basedir and install root directories.
- Assign deployment-to-package child dependencies. Locate the "Child Resources" link and press the Change button. Tick the checkboxes for theapache-tomcat-5.5.26.zip package.
- Assign node parent dependencies. Locate the "Parent Dependencies" link and press the Change button. Press the checkboxes for the desired nodes.
Run ctl-project
With the configuration completed, the next step is to ensure the tomcat1 object is installed on the needed machines. On the server, run the ctl-exec command to execute ctl-project utility:
ctl-exec -I ".*" -- ctl-project -p demo -a install . . . "Install" command running for resource: (Service) tomcat1
Ensure that you see "tomcat1" has been installed as shown in the message output above.
Execution
With the package in the repository and the tomcat1 Service registered you now ready to deploy the package.
Check dependencies
It's useful to look at how the "tomcat1" Service is configured. The "ctl-project" command should have ensured the object is now installed on the CTL node. Information about an object is available via the "Properties" command.
Run the Properties command without arguments:
$ ctl -p demo -t Service -r tomcat1 -c Properties
[MULTI_LINE]
# tomcat1 [Service] #
The Tomcat deployment.
## Attributes ##
* defaultAllowMultiplePackageMatches: "false"
* defaultDeploymentType: "Service"
* defaultFailIfPackageNotReplaced: "true"
* defaultPackageName: ".*"
* defaultPackageProximity: "1"
* defaultPackageType: "[^\.]*"
* errorNotificationRecipient: "${framework.admin.tolist}"
* service-isdown-executable: ""
* service-isdown-script: ""
* service-isup-executable: ""
* service-isup-script: ""
* service-start-executable: ""
* service-start-script: ""
* service-stop-executable: ""
* service-stop-script: ""
* successNotificationRecipient: "${framework.admin.tolist}"
## Dependencies ##
### Parent Dependencies ###
1. centos2 [Node]
### Child Dependencies ###
1. apache-tomcat-5.5.26.zip [zip]
* doc: "The Tomcat application server."
* name: "apache-tomcat-5.5.26.zip"
* order: "Package"
* package-arch: "noarch"
* package-base: "apache-tomcat-5.5.26"
* package-buildtime: "2008061570109"
* package-filename: "apache-tomcat-5.5.26.zip"
* package-filetype: "zip"
* package-install-rank: ""
* package-install-root: "${resource.deployment-basedir}"
* package-release: ""
* package-release-tag: ""
* package-repo-url: "http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/zip/zips/apache-tomcat-5.5.26.zip"
* package-restart: "false"
* package-vendor: ""
* package-version: "5.5.26"
* type: "zip"
- - -
[/MULTI_LINE]
Deleting: /home/alexh/ctier/ctl/projects/demo/resources/Service/tomcat1/var/resource.properties-801978448.tmp
You see general information, attribute values, and child-dependencies. You can see in the example output above that the apache-tomcat-5.5.26.zip [zip] object is a child dependency. This means the "Packages-Install" command will ensure to install the package.
Deploy
CLI
To deploy the packages to the local host run:
ctl -p demo -t Service -r tomcat1 -c Deploy begin workflow command (1/4) -> "Stop " ... begin workflow command (1/1) -> "assertServiceIsDown " ... end workflow command (1/1) -> "assertServiceIsDown " end workflow command (1/4) -> "Stop " begin workflow command (2/4) -> "Packages-Install " ... Start: "Install the configured package dependencies for the deployment." Beginning installation for packages: apache-tomcat-5.5.26.zip[zip] ... Dispatching command 'assertPackageIsVerified' to objects: apache-tomcat-5.5.26.zip[zip] ... starting: apache-tomcat-5.5.26.zip[zip]->assertPackageIsVerified ... Getting: http://strongbad:8080/jackrabbit/repository/controltier/projects/demo/publish/modules/zip-head.jar To: /home/alexh/ctier/ctl/var/tmp/downloads/demo/zip-head.jar Not modified - so not downloaded zip up to date Packages-Install invoking: apache-tomcat-5.5.26.zip[zip]->Install -installroot /demo/apache-tomcat-5.5.26 Start: "Install object and run the package installation cycle." commands: assertPackageIsInstalled begin workflow command (1/1) -> "assertPackageIsInstalled -installroot /demo/apache-tomcat-5.5.26" ... Executing ant file: /home/alexh/ctier/ctl/projects/demo/modules/Package/bin/is-installed.xml Running handler command: installPackage begin workflow command (1/5) -> "installDependencies -filename apache-tomcat-5.5.26.zip -installroot /demo/apache-tomcat-5.5.26 -url http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/zip/zips/apache-tomcat-5.5.26.zip" ... Dispatching command 'Install' to objects: ... end workflow command (1/5) -> "installDependencies -filename apache-tomcat-5.5.26.zip -installroot /demo/apache-tomcat-5.5.26 -url http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/zip/zips/apache-tomcat-5.5.26.zip" begin workflow command (2/5) -> "prepare -filename apache-tomcat-5.5.26.zip -installroot /demo/apache-tomcat-5.5.26 -url http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/zip/zips/apache-tomcat-5.5.26.zip" ... end workflow command (2/5) -> "prepare -filename apache-tomcat-5.5.26.zip -installroot /demo/apache-tomcat-5.5.26 -url http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/zip/zips/apache-tomcat-5.5.26.zip" begin workflow command (3/5) -> "get -filename apache-tomcat-5.5.26.zip -installroot /demo/apache-tomcat-5.5.26 -url http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/zip/zips/apache-tomcat-5.5.26.zip" ... Created dir: /demo/apache-tomcat-5.5.26 Getting: http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/zip/zips/apache-tomcat-5.5.26.zip To: /demo/apache-tomcat-5.5.26/apache-tomcat-5.5.26.zip end workflow command (3/5) -> "get -filename apache-tomcat-5.5.26.zip -installroot /demo/apache-tomcat-5.5.26 -url http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/zip/zips/apache-tomcat-5.5.26.zip" begin workflow command (4/5) -> "extract -filename apache-tomcat-5.5.26.zip -installroot /demo/apache-tomcat-5.5.26 -url http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/zip/zips/apache-tomcat-5.5.26.zip" ... Expanding: /demo/apache-tomcat-5.5.26/apache-tomcat-5.5.26.zip into /demo/apache-tomcat-5.5.26 end workflow command (4/5) -> "extract -filename apache-tomcat-5.5.26.zip -installroot /demo/apache-tomcat-5.5.26 -url http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/zip/zips/apache-tomcat-5.5.26.zip" begin workflow command (5/5) -> "finish -filename apache-tomcat-5.5.26.zip -installroot /demo/apache-tomcat-5.5.26 -url http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/zip/zips/apache-tomcat-5.5.26.zip" ... Deleting: /demo/apache-tomcat-5.5.26/apache-tomcat-5.5.26.zip end workflow command (5/5) -> "finish -filename apache-tomcat-5.5.26.zip -installroot /demo/apache-tomcat-5.5.26 -url http://strongbad:8080/jackrabbit/repository/controltier/projects/pkgs/demo/zip/zips/apache-tomcat-5.5.26.zip" end workflow command (1/1) -> "assertPackageIsInstalled -installroot /demo/apache-tomcat-5.5.26" [command.timer.default.Package.Install: 7.152 sec] Workflow completed. execution time: 7.152 sec Executing script: /home/alexh/ctier/ctl/projects/demo/modules/Package/bin/is-verified.xml ... Package is VERIFIED Completed: Installed packages: apache-tomcat-5.5.26.zip[zip] end workflow command (2/4) -> "Packages-Install " begin workflow command (3/4) -> "Configure " ... begin workflow command (1/1) -> "Docs-Generate " ... end workflow command (1/1) -> "Docs-Generate " end workflow command (3/4) -> "Configure " begin workflow command (4/4) -> "Start " ... begin workflow command (1/1) -> "assertServiceIsUp " ... end workflow command (1/1) -> "assertServiceIsUp " end workflow command (4/4) -> "Start "
...or to multiple hosts using node dispatching:
ctl -I ".*" -p demo -t Service -r tomcat1 -c Deploy . . .
GUI
You can execute the command shown above using JobCenter GUI. Go to the JobCenter webapp. Click the "Create a new job" button. Choose your project and then press the "Execute a Defined Command" radio button. Scroll down the list box and locate the "Service" type and then click the "tomcat1" object. This will load the commands list box. Scroll down and click the "Deploy" command.
Configure the node dispatch option and then press "Run". Of course, you can save this job to run at a later time, if desired.
Connecting deployment to startup and shutdown
You may have existing scripts to manage startup and shutdown that you would like to incorporate into the deployment process.
See the Custom service scripts page to configure your Service to call your scripts.
| ||||||||||||||