Server Farmer has been designed to manage all kinds of servers, using only ssh connections (without using "agents"). It even can be installed on any type of server in fully unattended mode, provided that you have the hostname and matching ssh private key.

Cloud Farmer setup

Cloud Farmer is a separate tool, that can:

  • create new cloud instances in all leading cloud platforms
  • deploy Server Farmer on any server (cloud instance, dedicated server etc.) in unattended (fully automatic) mode

To start using Cloud Farmer, you first have to install Server Farmer and create a management server (see how to do it). After installing Server Farmer, install Cloud Farmer:


git clone https://github.com/serverfarmer/cloudfarmer /opt/cloud
vi /opt/cloud/credentials/variables.sh

# do this only for cloud providers that you want to use
/opt/cloud/setup.sh ec2
vi /opt/cloud/credentials/ec2.sh

/opt/cloud/setup.sh azure
vi /opt/cloud/credentials/azure.sh
              

As you see, after cloning the repository you have to edit a few files: variables.sh (which provides global configuration variables, like your NewRelic license, or SMTP relay credentials), and 1 file per each cloud platform that you want to use.

Note that each cloud provider has different way to pass access credentials:

  • Amazon EC2: execute "aws configure --profile myprofile" to configure api/secret key and then put only the profile name into /opt/cloud/credentials/ec2.sh file
  • Rackspace Cloud: you will be asked for the first access profile when you execute setup.sh script - make sure to put in the profile name instead of leaving it blank, then put the entered name into /opt/cloud/credentials/rackspace.sh file
  • Microsoft Azure and Google Compute Engine: you will be asked to connect to your cloud account (this will require browser interaction) when you execute setup.sh script
  • e24cloud.com: just put your api/secret keys into /opt/cloud/credentials/e24cloud.php file

Creating new cloud instances

Cloud Farmer comes equipped with cloud platform drivers, that allow you to list existing instances, create and register ssh keys, and create new instances for all major cloud platforms. Instance parameters vary between platforms, but in general:

  • all such parameters are stored in configuration files (per platform) inside /opt/cloud/credentials directory, and you can update/change them to suit your needs
  • if some parameter is not explicitly described in configuration files, then default values are used (for example, all instances are always created with default storage options for given instance type/size, eg. t2.micro instances at Amazon EC2 are always created with 8 GB EBS drives)

To create a new instance, simply execute this command:


                /opt/cloud/create.sh ec2 test_key1 m4.xlarge
              

Let's explain the arguments:

  • ec2 - is the provider name, one of: ec2, azure, gce, e24cloud or rackspace
  • test_key1 - is the name part of the temporary ssh key, that will be generated, registered and associated with the created instance (so you will be able to log in using this key)
  • m4.xlarge - is the optional instance size (if it's omitted, then default instance size is taken from the configuration file)

Installing Server Farmer in unattended mode

Cloud Farmer can deploy Server Farmer on any type of server, assuming that you have ssh access, and the private ssh key allowing access as root or ubuntu user:


                /opt/cloud/deploy.sh ec2-54-123-45-67.compute-1.amazonaws.com /etc/local/.ssh/id_ec2_test_key1
              

Let's explain the arguments:

  • ec2-54-123-45-67.compute-1.amazonaws.com - is the full hostname or IP address of previously created server
  • /etc/local/.ssh/id_ec2_test_key1 - is the full pathname to the ssh private key, that will be used during installation

The installation phase will take approximately 3-7 minutes, depending on chosen cloud platform, used region and instance size. When it finishes, you'll receive a confirmation email, sent to the address defined in SF_CONFIRM variable from variables.sh file, and the server will be automatically added to the server farm, and to the backup list (assuming that backup collector role is also installed on management server). Also, all console output from the installation phase will be redirected to the file in /opt/cloud/logs directory on your management server.