A library for interfacing with Stackato and for automatically updating stackato instances. This is specifically built for Mozilla and Stackato and might not be relevant to you.
This is very much a work in progress.
To install:
pip install tardy
Tardy is a Python library with a command line interface.
-f
or--file
: points to a JSON file that contains configuration. Optional, if not specified usestardy.json
-d
or--dump
: dumps the contents of the Tardy configuration (which is just a JSON file) that contains a list of all the instances created by Tardy.-t
or--test
: doesn't actually execute commands, just prints.-g
or--git
: used when you aren't running Tardy from the source of the project. It will create a.tardy.repos
directory and check the source out into that directory. This is used when you have one project that requires two or three other projects.-l
or--last
: prints out the uuid of the last stackato instance created for that project.-a
or--action
: one ofupdate
,delete
,create
,restart
. Will do:create
: creates an instance and stores into the Tardy configuration.update
: creates a new instance, maps the urls over to it, then deletes the old one. Doing so changes the name of the instance each time.restart
: stops and starts each stackato instance.delete
: deletes each stackato instance.
-q
or--quiet
: less output onto the console.
For each stackato instance you want to create, you will need a configuration file:
{ "stackato": { "name": "zippy", "pre": [ "cp lib/config/local-dist.js lib/config/local.js" ], "git": { "repo": "https://github.com/mozilla/zippy.git" } }, "git": { "name": "zippy", "repo": "https://github.com/mozilla/zippy.git" } }
stackato
: config for stackatopre
: a list of commands to run prior to upload to stackato, each command is passed the env variables as dictionary for python strings. The variableURL
is also passed, this is the stackato URL instance.git
: the git repo of this instance.
git
: config for gitrepo
: the git repo of this instance.
Examples
Creating an integration test between two services
In this case we have a repo that contains integration tests between two other repos. This will create a unique instance of each repo on stackato and then run the integration tests. Since the instances are unique, multiple people can run this at once:
# Create a zippy instance. tardy -f zippy.json -a create -g # Find the last instance of zippy so solitude can find it. zippy=`tardy -f zippy.json --last` echo 'Last instance of zippy is at:' $zippy export ZIPPY=$zippy # Create a solitude instance, pointing to zippy. tardy -f solitude.json -a create -g # Now run the zippy solitude integration tests. solitude=`tardy -f solitude.json --last` echo 'Last instance of solitude is at:' $solitude python zippy-basic.py --url=https://solitude-$solitude.paas.allizom.org # Get rid of our solitude and zippy instances tardy -f solitude.json -a delete -g tardy -f zippy.json -a delete -g
For more see https://github.com/andymckay/solitude-zippy
Updating stackato when unit tests pass
In this case we are checking out a repo and running unit tests on a repo. This will occur on each github commit. If the tests pass then it will update the instance on stackato:
source /opt/rh/python27/enable set -e cd $WORKSPACE VENV=$WORKSPACE/venv if [ ! -d "$VENV/bin" ]; then echo "No virtualenv found. Making one..." virtualenv $VENV --system-site-packages --python=python source $VENV/bin/activate pip install --upgrade pip fi source $VENV/bin/activate pip install --upgrade tardy # In this case the jenkins user has stackato credentials to hit the server. tardy -f tardy.json -a upgrade
Example output:
[master] hello $ tardy -a update -q hello: Updating Command: stackato apps --json hello: New app id: hello hello: Old app id: tardy-update-hello Command: stackato apps --json Command: stackato map tardy-update-hello original-hello.paas.allizom.org Command: stackato push hello --as=hello --no-prompt --no-start Command: stackato start hello --no-prompt --no-tail Command: stackato map hello hello.paas.allizom.org Command: stackato unmap tardy-update-hello hello.paas.allizom.org Command: stackato apps --json Command: stackato delete tardy-update-hello hello: Note: the app has been renamed to hello [master] hello $ tardy -a update -q hello: Updating Command: stackato apps --json hello: New application id is: tardy-update-hello hello: Old application id is: hello Command: stackato apps --json Command: stackato map hello original-hello.paas.allizom.org Command: stackato push hello --as=tardy-update-hello --no-prompt --no-start Command: stackato start tardy-update-hello --no-prompt --no-tail Command: stackato map tardy-update-hello hello.paas.allizom.org Command: stackato unmap hello hello.paas.allizom.org Command: stackato apps --json Command: stackato unmap tardy-update-hello tardy-update-hello.paas.allizom.org Command: stackato delete hello hello: Note: the app has been renamed to tardy-update-hello
For more see https://github.com/mozilla/zippy