0

I will have to deploy some custom machines where software is mostly installed by hand, which means: tarball downloaded and decompressed into a single directory, python source packages installed into virtualenvs, and things like that (no, it can't be changed).

The main requirement is that going from fresh to deployed has to be rapid and automated, so ideally once I have the new machine, run a script that does it all.

It seems to me that this stuff is not easy to deploy using the standard puppet etc. tools. I was looking at fabric which seems to be more suitable for this scenario. What do people use/recommend?

Deer Hunter
  • 1,070
  • 7
  • 17
  • 25

2 Answers2

1

I'm using fabric to automate server configuration. You can easily write bunch of commands that setup nginx, supervisor, virtualenv, etc. I can post part of my fabfile:

@task
def setup_sys_installs():
    """
    Note
    ----
        You can always use 'sudo apt-get build-dep <python-package>' to
        install some prerequisites for packages like gevent or lxml.
    """

    print('=== SETUP LIBRARIES ====')
    sudo('apt-get -y update')
    sudo('apt-get -y install python-virtualenv python-pip python2.7 mercurial')
    # you need this to pip install any compilled library
    sudo('apt-get -y install python-dev build-essential')
    # you need this need this to pip install gevent
    sudo('apt-get -y install libevent-dev')
    # you need this need this to pip install psycopg2
    sudo ("apt-get -y install libpq-dev")
    # you need this need this to pip install lxml
    sudo('apt-get -y install libxml2-dev libxslt-dev')
    # you need this need this to pip install m2crypto
    sudo('apt-get -y install swig')


@task
def sync_virtualenv():
    with cd(env.PROJECT_DIR):
        cmd = "%s/bin/pip install -r requirements/production.txt" % (env.VENV,)
        sudo(cmd, user=env.VENV_USER)


@task
def setup_virtualenv():
    print('=== SETUP VIRTUALENV ====')
    with cd(env.HOME):
        sudo("virtualenv -p /usr/bin/python2.7 venv", user=env.VENV_USER)
    sync_virtualenv()

Give me a comment, if you interested in more details.

0

Learn how to package software and create your own repository. It's not hard at all and you don't need to invent another thing to automate deployments, but can simply use puppet to install your packages from your own yum or apt repository.

Dennis Kaarsemaker
  • 19,277
  • 2
  • 44
  • 70