Chapter 1.5 : Installing Tlaloc on your network

Follows are the guidelines, and steps to setup Tlaloc for effective node management on your network.

Setup your source repository

Download the Tlaloc tarzipped package, unpack it in a temporary folder if needs be, and move the entire package to your source server(s).

The way I normally do it is by setting up a user dedicated to the sources (assuming you're setting up on a Unix server), user which then becomes dedicated to serving the Tlaloc repository files AND executables through scp and rsync. We attempt to avoid using protocoles such as FTP because they are less secure on the wire (and a bitch to handle firewall-wise).

So... adduser -m /home/tlaloc tlaloc
tar xvzf Tlaloc-vX.X.tgz -C /home/tlaloc/

Following this, you should have a Tlaloc/Cluster_Runner/ directory structure

You need to create a "repository" for storage of module configs and particular node configs.

cd /home/tlaloc
mkdir Repository

You can secure the Repository against rogue users by chowning it to the tlaloc user (or whatever other user you would use for this).

chown -R tlaloc.tlaloc /home/tlaloc/Repository
chmod 700 /home/tlaloc/Repository

This might be a hassle if you don't like sudoing to manually make changes to the Repository, you can always share it at the group-level with your sysadmin users.

chown -R tlaloc.staff /home/tlaloc/Repository
chmod 770 /home/tlaloc/Repository

Pushing/Pulling the Cluster Runner package to a Node

Under Tlaloc/Cluster_Runner/ you will find a set of scripts helpful in pushing the base installation to remote nodes, namely my favorite is rsync_to_node.sh which takes as 1 argument the scp destination such as "tlaloc@target_node:Tlaloc"

Note: You can install the Tlaloc package on as many servers or remote nodes. We have to make a distinction between the Tlaloc package and the repository, one does NOT depend on the other.

rsync_to_node.sh user@node_ip:Tlaloc

At this point your nodes are ready to run.


Executing on a Node

For manually executing the Node script, access the node to which you published the Cluster_Runner package;

ssh user@node_ip
cd Tlaloc/Cluster_Runner

If you are unsure if the minimal requirements were installed, a helper install script is included for different OSes and versions, which will auto-magically be chosen from the uname unix utility results.

You can just run the Install.sh script, it will normally install rsync and php, and make a symbolic link to the installed `php` as /usr/local/bin/php

sh ./Install.sh

Invoking a Cluster_Runner execution

This is the "regular" execution of the Node's recipe, usually run at boot time (if running a diskless node or barebone Amazon images), or on a regular basis (as a firewire/config rewriting method).

The most basic invocation basically executes your script. Before going into the details of how, why, where and when, let's just stick to the basics;

php ./Node_Setup.php

Writing a small test script

And, to get you going, a simple small script;

#!/usr/local/bin/php
<?php

$LOGLEVEL=4;	// set the LOGLEVEL for verbosity; 0=strict minimum, 5=everything
$Automated_Agent_PrivKey="./ssh/tlalockeys";	// the private SSH key used by the agent to talk to the repository over scp/ssh/sftp

/*
 * Default basic tests to determine the Node OS, Version, Name and Platform-type
 *	usually; these should work on all systems, it was also a design decision to make this part of user scripts so you,
 *  as a programmer/sysadmin, can adjust these to your likings. They are used as Global variables throughout the Tlaloc classes.
 */
$Node_OS=trim(`uname -s`);
$Node_OSVersion=trim(`uname -r`);
$Node_Name=trim(`hostname`);
$Node_Platform=trim(`uname -p`);

/*
 * The Repository location(s). We use 2 different repositories in this script, one for files
 * and another for the OS Packages. Also note that these are Arrays, so you can load as many
 * repositories as you want, but they should be replicated, the system will not scan all repositories
 * to find your sources, rather it will stick to the first available.
 * Security note; the file repository should probably be kept on an SSH-able platform for security.
 * On Amazon, S3, your security is dependent on the authentication and particular Amazon setup you have.
 */
$File_Repositories=array("repo_user@10.10.10.100:Tlaloc/");
$Package_Repositories=array("ftp://repo_user:mypassword@10.10.10.100/$Node_OSVersion/packages/$Node_Platform/");

/*
 * Load up the Tlaloc engine, it will automatically select the appropriate
 * OS/Platform classes that fit the localhost.
 */
require 'Tlaloc.php';

/*
 * Instantiate the different Tlaloc objects
 */
$File=new Tlaloc_File($File_Repositories,$Automated_Agent_PrivKey,array("*.old","*.LCK"));
$Package=new Package($Package_Repositories);
$User=new User();
$Service = new Service($File);


/*
 * Actual custom scripting ...
 */

// Add group wheel to sudoers
$File->AddLine("/etc/sudoers","%wheel  ALL=(ALL) SETENV: ALL");

/**
 * Update the aliases mailer table
 *
 */
$File->AddLine("/etc/mail/aliases","root: $SysAdmin_EmailAddress");
if ( ! $File->Run_Process("newaliases",true,false,null,true) ) {
	print "An error occurred while recompiling the mailer-daemon local Aliases table\n";
}