This document describes the functionality provided by the Command Plugin.
Refer to the Deployit Reference Manual for background information on Deployit and deployment concepts.
As a system administrator, the need occasionally arises to execute adhoc scripts or OS commands on remote systems. The process usually entails having to manually login to each system, copy any required resources to said system and finally executing scripts/commands to process the resources or configure the remote system. The process is acceptable for a single system, but tends not to scale when performing the tasks on entire server farms. The manual intensive process becomes tedious and error prone. The Command Plugin helps with these tedious processes and significantly reduces the chances of errors.
A system administrator could also use the Command Plugin to reuse existing deployment scripts with Deployit, before choosing to move the deployment logic to a more reusable, easily maintainable plugin form.
A Command encapsulates an OS specific command, as one would enter at the command prompt of a native OS command shell. The OS command is captured in the Command's commandLine property; e.g. 'echo hello >> /tmp/hello.txt'. The Command also has the capability of uploading any dependent files to the target system and make those available to the commandLine with the use of a placeholder; e.g. 'cat ${uploadedHello.txt} >> /tmp/hello.txt'.
An undo Command has the same characteristics as a Command, except that it reverses the effect of the original Command it is associated with. An undo Command usually runs when the associated Command is undeployed or upgraded.
The order in which the Command is run in relation to other commands. The order allows for the chaining of commands to create a logical sequence of events. For example, an install tomcat command would execute before an install web application command, while a start tomcat command would be the last in the sequence.
This plugin requires:
Please refer to Packaging Manual for more details about the DAR packaging format.
Sample DAR MANIFEST.MF entries defining a package that can (un)provision a tomcat server using an install and uninstall script
Manifest-Version: 1.0
Deployit-Package-Format-Version: 1.3
CI-Application: CommandPluginSample
CI-Version: 1.0
Name: install-tc-command
CI-type: cmd.Command
CI-order: 50
CI-commandLine: /bin/sh ${install-tc.sh} ${tomcat.zip}
CI-undoCommand: uninstall-tc-command
CI-dependencies-EntryValue-1: install-tc.sh
CI-dependencies-EntryValue-2: tomcat.zip
CI-name: install-tc-command
Name: uninstall-tc-command
CI-type: cmd.Command
CI-order: 45
CI-commandLine: /bin/sh ${uninstall-tc.sh}
CI-dependencies-EntryValue-1: uninstall-tc.sh
CI-name: uninstall-tc-command
Name: tomcat-6.0.32.zip
CI-name: tomcat.zip
CI-type: file.File
Name: install-tc.sh
CI-type: file.File
CI-name: install-tc.sh
Name: uninstall-tc.sh
CI-type: file.File
CI-name: uninstall-tc.sh
The following table describes which deployable / container combinations are possible. Note that the CIs can only be targeted to containers derived from Host.
| Deployables | Containers | Generated Deployed |
|---|---|---|
| cmd.Command | overthere.Host | cmd.DeployedCommand |
The following table describes the effect a deployed has on its container.
| Deployed | Create | Destroy | Modify |
|---|---|---|---|
| cmd.DeployedCommand |
|
|
|
For illustration purposes, we take a simplistic view of installing Tomcat. In reality however, your installation of Tomcat would take on a far more comprehensive form.
Tomcat is distributed as a zip. For this example, we create an installation script to unzip the distribution on the host. The uninstall script simply shuts down a running Tomcat and deletes the installation directory.
Create the installation script (install-tc.sh)
#!/bin/sh
set -e
if [ -e "/apache-tomcat-6.0.32" ]
then
echo "/apache-tomcat-6.0.32 already exists. remove to continue."
exit 1
fi
unzip $1 -d /
chmod +x /apache-tomcat-6.0.32/bin/*.sh
Create the uninstall script (uninstall-tc.sh)
#!/bin/sh
set -e
/apache-tomcat-6.0.32/bin/shutdown.sh
rm -rf /apache-tomcat-6.0.32
MANIFEST snippet defining the command to trigger the execution of the install script for the initial deployment
The following command will be executed at order 50 in the generated step list. '/bin/sh' is used on the host to execute the install script which takes a single parameter, the absolute path to the tomcat.zip on the host. When the command is undeployed, uninstall-tc-command will be executed.
Name: install-tc-command
CI-type: cmd.Command
CI-order: 50
CI-commandLine: /bin/sh ${install-tc.sh} ${tomcat.zip}
CI-undoCommand: uninstall-tc-command
CI-dependencies-EntryValue-1: install-tc.sh
CI-dependencies-EntryValue-2: tomcat.zip
CI-name: install-tc-command
MANIFEST snippet defining the undo command to trigger the execution of the uninstall script for the undeploy
The undo command will be executed at order 45 in the generated step list. Note that it has a lower order than the install-tc-command. This ensures that the undo command will always run before the install-tc-command during an upgrade.
Name: uninstall-tc-command
CI-type: cmd.Command
CI-order: 45
CI-commandLine: /bin/sh ${uninstall-tc.sh}
CI-dependencies-EntryValue-1: uninstall-tc.sh
CI-name: uninstall-tc-command
See the Usage in Deployment Packages section for the complete MANIFEST.MF
| CI | Description |
|---|---|
| cmd.Command | Command specification that is executed on a host |
| CI | Description |
|---|---|
| cmd.DeployedCommand | Command deployed to a Host |
| CI | Description |
|---|---|
| overthere.CifsHost | A machine that can be connected to using either WinRM or Telnet and can perform file manipulation via the CIFS protocol |
| overthere.LocalHost | The machine on which the Deployit Server is running on |
| overthere.SshHost | A machine that can be connected to using ssh |
| overthere.SshJumpstation | A machine that can be used to create a tunneled connection to the destination host |
| CI | Description |
|---|---|
| overthere.Host | A machine that runs middleware, on which scripts can be executed, etc |
| overthere.HostContainer | |
| overthere.Jumpstation | Base class for jumpstations |
| Hierarchy | udm.BaseDeployable >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Taggable, udm.Deployable, udm.ConfigurationItem |
Command specification that is executed on a host
| Hierarchy | udm.BaseDeployed >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Deployed, udm.ConfigurationItem |
Command deployed to a Host
| Hierarchy | overthere.Host >> udm.BaseContainer >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Taggable, udm.ConfigurationItem, udm.Container, overthere.HostContainer |
A machine that can be connected to using either WinRM or Telnet and can perform file manipulation via the CIFS protocol.
| Control Tasks |
|---|
| checkConnection Check connection |
| Hierarchy | udm.BaseContainer >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Taggable, udm.ConfigurationItem, udm.Container, overthere.HostContainer |
A machine that runs middleware, on which scripts can be executed, etc.
| Control Tasks |
|---|
| checkConnection Check connection |
null
| Hierarchy | overthere.Host >> udm.BaseContainer >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Taggable, udm.ConfigurationItem, udm.Container, overthere.HostContainer |
Base class for jumpstations
| Control Tasks |
|---|
| checkConnection Check connection |
| Hierarchy | overthere.Host >> udm.BaseContainer >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Taggable, udm.ConfigurationItem, udm.Container, overthere.HostContainer |
The machine on which the Deployit Server is running on.
| Control Tasks |
|---|
| checkConnection Check connection |
| Hierarchy | overthere.Host >> udm.BaseContainer >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Taggable, udm.ConfigurationItem, udm.Container, overthere.HostContainer |
A machine that can be connected to using ssh.
| Control Tasks |
|---|
| checkConnection Check connection |
| Hierarchy | overthere.Jumpstation >> overthere.Host >> udm.BaseContainer >> udm.BaseConfigurationItem |
|---|---|
| Interfaces | udm.Taggable, udm.ConfigurationItem, udm.Container, overthere.HostContainer |
A machine that can be used to create a tunneled connection to the destination host.
| Control Tasks |
|---|
| checkConnection Check connection |