This example illustrates how the SSH plugin can be used to install a 64 bit Java Virtual Machine.(JVM) on Linux (specifically the Linux variants Centos and Red Hat) from a archive binary file (.GZ).
Three steps are required to use the plugin:
..And finally Pineapple should be invoked to execute the module to install the JVM at the targeted resources.
For information about how to define resource, credentials and modules, refer to the plugin usage page.
This example named ssh-004-install-jvm-linux64, including all configuration files, is included in the default configuration which is created by Pineapple, so there is no need to create it by hand.
A resource defines a entity in a IT environment which is manageable by Pineapple through some protocol. In this example, the entity is a Linux OS and the used protocol is SSH. One resource is defined for each Linux host where the JVM should be installed.
In this example we will use the linux-vagrant environment defined as part of the default configuration. The environment defines a network with three hosts:
To enable SSH usage for these hosts, three resources are defined within the linux-vagrant environment in the resources file located at ${user.home}/.pineapple/conf/resources.xml:
<?xml version="1.0" encoding="UTF-8"?> <configuration xmlns="http://pineapple.dev.java.net/ns/environment_1_0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pineapple.dev.java.net/ns/environment_1_0 http://pineapple.dev.java.net/ns/environment_1_0.xsd"> <environments> <environment description="Vagrant multi-machine Linux environment" id="linux-vagrant"> <resources> <resource plugin-id="com.alpha.pineapple.plugin.ssh" credential-id-ref="ssh-node1" id="ssh-node1" > <property value="192.168.34.10" key="host"/> <property value="22" key="port"/> <property value="1000" key="timeout"/> </resource> <resource plugin-id="com.alpha.pineapple.plugin.ssh" credential-id-ref="ssh-node2" id="ssh-node2" > <property value="192.168.34.11" key="host"/> <property value="22" key="port"/> <property value="1000" key="timeout"/> </resource> <resource plugin-id="com.alpha.pineapple.plugin.ssh" credential-id-ref="ssh-node3" id="ssh-node3" > <property value="192.168.34.12" key="host"/> <property value="22" key="port"/> <property value="1000" key="timeout"/> </resource> </resources> </environment> </environments> </configuration>
Each resource is defined with a different ID and IP address. All other properties are identical. The role of the attribute plugin-id is to bind the resource definition to the plugin code at runtime which implements the SSH plugin.
Since SSH requires authentication, each resource defines a reference to a credential. A credential defines the user name and password used for authentication when a SSH session is created to a host.
Three credentials are created within the linux-vagrant environment to support authentication. The credentials are defined in the credentials file located at ${user.home}/.pineapple/conf/credentials.xml:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <configuration xmlns="http://pineapple.dev.java.net/ns/environment_1_0"> <environments> <environment description="Vagrant multi-machine Linux environment" id="linux-vagrant"> <credentials> <credential password="vagrant" user="vagrant" id="ssh-node1"/> <credential password="vagrant" user="vagrant" id="ssh-node2"/> <credential password="vagrant" user="vagrant" id="ssh-node3"/> </credentials> </environment> </environments> </configuration>
A module defines input to Pineapple and consists in its minimal form of a single XML file containing a model:
The module is located at ${user.home}/.pineapple/modules/ssh-004-install-jvm-linux64 and it has the structure:
ssh-004-install-jvm-linux64 | +--- models | +--- linux-vagrant.xml +--- bin +--- jdk-7u25-linux-x64.tar.gz.DOMWNLOAD.ME
Download the Java SE JDK version 7u25 (update to a newer if you please) in the Linux x64 flavor as a .GZ file, e.g. jdk-7u25-linux-x64.tar.gz and place it in the ${user.home}/.pineapple/modules/ssh-004-install-jvm-linux64/bin directory.
In the models directory, a model file named linux-vagrant is defined with the content:
<?xml version="1.0" encoding="UTF-8"?> <mmd:models xmlns:mmd="http://pineapple.dev.java.net/ns/module_model_1_0" xmlns:shp="http://pineapple.dev.java.net/ns/plugin/ssh_1_0"> <mmd:model target-resource="regex:ssh-node.*"> <mmd:content> <shp:ssh> <shp:copy-to source="modulepath:bin/jdk-7u25-linux-x64.gz" destination="/tmp/jdk-7u25-linux-x64.gz"/> <shp:execute command="sudo chmod +x /tmp/jdk-7u25-linux-x64.gz" /> <shp:execute command="sudo tar -zxvf /tmp/jdk-7u25-linux-x64.gz -C /u01/app/oracle/product/fmw > /tmp/.log 2>&1 &" /> <shp:execute command="sudo chown -R weblogic:oinstall /u01/app/oracle/product/fmw/jdk1.7.0_25" /> </shp:ssh> </mmd:content> </mmd:model> </mmd:models>
Two schema are used in the model file. The http://pineapple.dev.java.net/ns/module_model_1_0 is used to define the namespace mmd which defines the general infrastructure for models. The http://pineapple.dev.java.net/ns/plugin/ssh_1_0 schema is used to define the namespace shp which is used to define the model for the SSH plugin. Since multiple schemas are used to define the model file, the elements are qualified.
The target-resource attribute defines a reference to the resource which is targeted when the model executed. In this case, the value regex:ssh-node.* defines a regular expression for targeting multiple resources, e.g. all the resources starting with ssh-node.
The main part of the model consists of four commands, which performs the installation steps:
The execute commands in the model is executed using sudo. The requirement for sudo depends on the privileges of the user used by the SSH plugin to connect to a given host. The users was defined in credentials file in the previous section.
Please notice: The environment variable JAVA_HOME isn't set as a result of the installation.