pip install maestro
Either download the default fabfile or create your own:
from maestro.core import * from maestro import system as sys
You can then run
fab -l to see the available tasks.
For example, to run a memory report for a host named
fab -H dev.example.com sys.memory
[dev.example.com] Executing task 'sys.memory' [dev.example.com] total used free shared buffers cached [dev.example.com] Mem: 7948 4076 3871 0 1942 295
Maestro has the ability to use a cloud provider (currently EC2 and Rackspace) for a node list.
You can optionally specify a specific region to only show those nodes. By default, all regions will be used.
To see a list of available regions, run:
To use Amazon EC2, you must set the following environment variables:
To run an uptime report for all nodes in EC2:
fab nodes:ec2 sys.uptime
[22.214.171.124] 07:26:16 up 49 days, 12:34, 1 user, load average: 0.32, 0.05, 0.01 [126.96.36.199] 07:26:17 up 34 days, 13:15, 1 user, load average: 0.22, 0.10, 0.01 [188.8.131.52] 07:26:18 up 23 days, 15:25, 1 user, load average: 0.17, 0.06, 0.01
To run an uptime report for all nodes in EC2 us-east-1 region:
fab nodes:ec2,us-east-1 sys.uptime
[184.108.40.206] 07:26:16 up 49 days, 12:34, 1 user, load average: 0.32, 0.05, 0.01
To use Rackspace, you must set the following environment variables:
To run an uptime report for all nodes:
fab nodes:rackspace sys.uptime
[220.127.116.11] 00:16:37 up 2 min, 1 user, load average: 0.00, 0.00, 0.00
You can also filter nodes based upon the machine name (the
Name tag in EC2) using a regular expression:
fab nodes:ec2,filter=^puppet sys.uptime
[puppet.example.com] 23:17:19 up 50 days, 4:25, 1 user, load average: 0.00, 0.00, 0.00
You can put the environment variables in
key=value form in a file named
.maestrorc in your home directory. Maestro will automatically load it and use the values.
For example, create
~/.maestrorc with the following:
EC2_ACCESS_ID=123456789 EC2_SECRET_KEY=abcdefghijlkmnop RACKSPACE_ID=rackspaceuser RACKSPACE_KEY=800012345abcdefg12345
Using Maestro from a custom fabfile
To use Maestro from a custom
fabfile simply add the following to your fabfile:
from maestro.core import * from maestro import system as sys # optional -- ~/.maestrorc loader from maestro.utils import load_maestro_rc load_maestro_rc()
You should then be able to run
fab -l and see the Maestro tasks.
There is also experimental support for creating and deploying Python applications (more languages and frameworks will be included in the future).
** Note: this assumes you have the following packages installed (these are for debian/ubuntu):
** You will also need to install uWSGI:
sudo easy_install pip
sudo pip install uwsgi
sudo pip install virtualenv
Create an application
fab -H 10.1.2.3 py.create_app:myapp,"myapp.mydomain.com"
This will create the application directory, setup supervisor to run uWSGI, and create an nginx config.
Deploy an application
To deploy an application, make sure there is a
wsgi.py module in the root of the application. Here is an example for a Django app:
import os import django.core.handlers.wsgi os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings") application = django.core.handlers.wsgi.WSGIHandler()
fab -H 10.1.2.3 py.deploy:myapp,/path/to/myapp/source
You can also deploy using git:
fab -H 10.1.2.3 py.deploy:myapp,https://github.com/username/myapp
When deploying, Maestro will upload or pull the latest source, install packages for the virtualenv (from a
requirements.txt located in the root directory of your app), and restart the application.
Delete an application
fab -H 10.1.2.3 py.delete_app:myapp
Forking encouraged :) For bugs, features, etc. please use Github issues.