Bulk Node registration
From ControlTier
Information about the Nodes in your environment can be registered to the ControlTier server using a project.xml file and the node tag.
If you install the ControlTier client, nodes are registered to a project by ctl-project during project setup but this page describes how to use an XML file to declare many nodes inside one file and then use ProjectBuilder to load their definitions. The clients obtain this data from the server as resources.xml.
Contents |
Definition
Create a project.xml file and use the node tag to declare node metadata. Node tag attributes convey basic metadata described below:
| attribute | description | example value |
|---|---|---|
| type | node type | Node |
| name | node name | a name |
| description | node description | a character string |
| hostname | The hostname or IP address of the remote host to which you wish to connect. Can include port (eg hostname:port) if non-standard SSH port is required | a valid hostname |
| osArch | operating system architecture | (eg uname -p) |
| osFamily | operating system family | windows or unix |
| osName | operating system name | (eg uname -s) |
| osVersion | operating system version | (eg uname -r) |
| ctlBase | CTL framework instance directory | CT_BASE |
| ctlHome | CTL software installation root directory | CTL_HOME |
| ctlUsername | The username on the remote host to which you are connecting. | (eg ${framework.ssh.user} |
| ctlPassword | remote connection password | Unceccessary when using key-based authentication |
| tags | Filtering tags |
The example file called "nodes.xml" below defines two nodes: ubuntu and centos54-vm1. Each node declares its hostname value as its IP address and they both declare the use of a common ctlUsername value, "demo".
The hostname and ctlUsername values are used for SSH connections during command dispatch (analogous to saying ssh ctlUsername@hostname) . No ctlPassword values were declared which means key-based authentication will be used.
File listing: nodes.xml
<!DOCTYPE project PUBLIC "-//ControlTier Software Inc.//DTD Project Document 1.0//EN" "project.dtd"> <project> <node name="ubuntu" type="Node" description="an ubuntu host" hostname="172.16.167.211" osArch="i386" osFamily="unix" osName="Linux" osVersion="2.6.27-7-generic" ctlUsername="demo" tags="mac,development"/> <node name="centos54-vm1" type="Node" description="a centos host" hostname="172.16.167.129" osArch="i686" osFamily="unix" osName="Linux" osVersion="2.6.18-164.el5" ctlUsername="demo" tags="server,qa"/> </project>
Loading the definition
| Before you load the Node data, be sure the project has already been created. See Creating a project for instructions. |
On a host where the ControlTier client has been installed and setup, run ProjectBuilder's load-resources command and specify the XML file.
Here load-resources is used to load the "nodes.xml" file into the project called "demo":
ctl -p demo -m ProjectBuilder -c load-resources -- -filename nodes.xml . . Batch request performed successfully.
Successful completion will result with a "Batch request performed successfully." message.
Confirming access
With the hosts defined as Nodes in the project's resource model, it is important to confirm access for the command dispatcher. Do this by running a trivial command across all hosts via the ctl-exec command like so:
ctl-exec -p demo --keepgoing -I '.*' -- uname -a
Output from a successful run of the uname command would look similar to the messages below:
[alexh@strongbad ctl-exec][INFO] Darwin strongbad 10.5.0 Darwin Kernel Version 10.5.0: Fri Nov 5 23:20:39 PDT 2010; root:xnu-1504.9.17~1/RELEASE_I386 i386 [demo@ubuntu ctl-exec][INFO] Linux ubuntu 2.6.27-7-generic #1 SMP Fri Oct 24 06:42:44 UTC 2008 i686 GNU/Linux [demo@centos54-vm1 ctl-exec][INFO] Linux ubuntu 2.6.27-7-generic #1 SMP Fri Oct 24 06:42:44 UTC 2008 i686 GNU/Linux
Let's imagine the value specifying ctlUsername for the ubuntu Node was incorrect (e.g., a bogus "demox" login) . An incorrect ctlUsername value would cause an error during command dispatch.
Here's an example message indicating such an SSH related problem. In this case, a JSchException is thrown because the erroneous "demox" value was used in ubuntu's ctlUsername attribute.
[demox@ubuntu ctl-exec][ERROR] Failed execution for node: ubuntu: com.jcraft.jsch.JSchException: Auth cancel error: Execution failed on the following 1 nodes: [ubuntu] error: Execute this command to retry on the failed nodes: ctl-exec -K -p demo -I name=ubuntu -- uname -a
The Auth cancel message above shows that when connecting to the ubuntu Node an SSH authentication error occurred. It is possible to mimic the command dispatcher's SSH connection request to ubuntu like so:
ssh -I $(awk '/framework.ssh.keypath/ {print $3}' $CTL_BASE/etc/framework.properties) demox@ubuntu uname -a
The awk command parses the client configuration to lookup the path to the SSH identity file. Had the ctlUsername value been correct and an "Auth cancel" error still occurred it's probable that server's public key was not added to the target hosts user's authorized_keys file.
Querying
Use ctl-exec listing mode to print out the registered nodes.
Example
List the nodes defined in the "demo" project resource model:
$ ctl-exec -p demo
ubuntu centos54-vm1
| ||||||||||||||
| ||||||||||||||