Deploying Ftrack to AWSΒΆ

Deploying ftrack is fairly straight-forward, however the kinds of environments in which it is deployed are usually not under your control as a developer. To make things a little more convenient, here’s a fabric script that deploys ftrack to AWS in one line.

from fabric.api import *
from fabric.contrib.files import exists
from fabric.operations import prompt
from fabric.contrib.files import sed

import os
import shelve

prefs ="prefs")

def pref_prompt(key, prompt_text, default=""):
  if key in prefs:
    return prefs[key]
    prefs[key] = prompt(prompt_text, default=default)
    return prefs[key]

env.hosts = [pref_prompt(key='host', prompt_text='AWS Public DNS (IPv4):')]
ftrack_dl_link = pref_prompt(key='download_link', prompt_text='FTrack Download Link:', default='')
ftrack_repo = pref_prompt(key='ftrack_repo', prompt_text='ftrack repo (optional):', default=os.path.join(os.path.expanduser("~"), "dev/ftrack"))
env.key_filename = pref_prompt(key='pem', prompt_text='pem file:',default='~/.ssh/centos.pem')
env.user = pref_prompt(key='user', prompt_text='username (leave as is):', default='centos')
ftrack_deployment_script = pref_prompt(key='ftrack_deployment_script', prompt_text='ftrack deployment script (leave as is):', default="")

def setup():
  if not exists("ftrack.tar.gz"):
    run("curl '{0}' > ftrack.tar.gz".format(ftrack_dl_link))
  if not exists(""):
    run("curl -O {0}".format(ftrack_deployment_script))
  sudo("yum remove -y mariadb-libs.x86_64")
  sudo("ln -sf /usr/lib64/ /usr/lib64/")
  with settings(prompts={'Enter the path to the downloaded ftrack package: ': 'ftrack.tar.gz'}):
  if os.path.exists(ftrack_repo):
#  sudo("sed -i '8iftrack.server_url=http://%s' /opt/ftrack_config/ftrack.ini"
  print("Your host is now setup on: http://%s\nPlease remember to allow http connections in your security group.\nYou may login with u:root pw:12345"

def gen_license():
  with settings(hide('warnings', 'running', 'stdout', 'stderr'),warn_only=True):
    out = run("ifconfig -a | grep -m 1 ether | awk '{print $2}'")
  gen_license_script = os.path.join(ftrack_repo, "trunk/FTServer/")
  key = local("python {0} -m {1}".format(gen_license_script, out), capture=True).split("\n")[0]
  sed("/opt/ftrack_config/ftrack.ini", "<set-licensekey-in-gui>", key)

def stop():
  sudo("/etc/init.d/supervisord_local stop")

def start():
  sudo("/etc/init.d/supervisord_local start")

def restart():
  import time

def logs():
  run("tail -f /tmp/ftrack.log")

def ssh():
  local("ssh -i %s %s@%s"%(env.key_filename, env.user,

def clear_prefs():