DeadSimpleOps
Stop worrying about ops, let it be Dead Simple.
Installation
Don't worry, it's dead simple:
pip install dead-simple-ops
Usage
To deploy an app, simply run
deploy <app> [--rev=REV] [--env=ENV]
To check its status, run
status <app> [--env=ENV]
To monitor the status of all your apps at a high-level, run
monitor-repos <org>
Configuration
DeadSimpleOps uses a dsops.yml
file to configure all of its targets. DeadSimpleOps will search for this file first in the current directory, then in ~/.dsops
, and finally in /etc/dsops
. Alternatively, a valid config file can be provided as an argument to any DeadSimpleOps command, ie. deploy MyCoolApp --conf=/apps/mycoolapp/dsops.yml
Deploy
A minimal deployment to Heroku could be defined as:
MyCoolApp:
deploy:
source: git@github.com:TheKevJames/my-cool-app.git
target: https://git.heroku.com/my-cool-app.git
You can easily configure multiple environments:
MyCoolApp:
deploy:
source: git@github.com:TheKevJames/my-cool-app.git
test:
source: git@github.com:TheKevJames/my-cool-app-with-tests.git
target: https://git.heroku.com/my-cool-app-test.git
stage:
target: https://git.heroku.com/my-cool-app-staging.git
prod:
target: https://git.heroku.com/my-cool-app.git
With the above config, we've defined three environments: test
, stage
, and prod
. stage
and prod
will both use the same default source, but test
will instead use an overwritten source. Each of the three environments have their own target. Note that deploy MyCoolApp
(with no environment specified) will not work in this case, as it has no defined target.
We can also run pre- and post-scripts before and after a deploy, respectively:
MyCoolApp:
deploy:
source: git@github.com:TheKevJames/my-cool-app.git
target: https://git.heroku.com/my-cool-app.git
before: ['echo "Beginning deploy..."', '/etc/my-cool-app/migrate']
after: 'echo "Completed deploy!'
before
and after
targets are optional, and may be either a single string or a sequence of strings. This string(s) will be treated as commands and executed in sequence. before
commands will be executed immediately after configuration validation but before any other action is taken; after
commands will be executed immediately after a successful deploy.
A configuration file may include any number of apps:
MyCoolApp:
deploy:
source: git@github.com:TheKevJames/my-cool-app.git
target: https://git.heroku.com/my-cool-app.git
MyEvenCoolerApp:
deploy:
source: git@github.com:TheKevJames/my-even-cooler-app.git
target: https://git.heroku.com/my-even-cooler-app.git
Status
We can define targets we wish to see the status of similarly to the configuration of the deploy task. eg. to check the status of a redis server, simply enter the command needed to access it:
MyCoolApp:
status:
redis: redis-cli
Or for a non-local server with some security:
MyCoolApp:
status:
redis: redis-cli -h thekev.in -p 6379 -a itsasecret
We can also monitor postgres instances:
MyCoolApp:
status:
postgres: PGPASSWORD="itsanothersecret" psql --host=localhost --port=5432 --user=me my_db
And rabbitMQ queues:
MyCoolApp:
status:
rabbitmq:
url: https://username:password@rabbitmq.thekev.in
queues: ['normal-messages', 'critical-errors', 'aardvarks']
As per all DeadSimpleOps tasks, we can set this per env as:
MyCoolApp:
status:
redis: redis-cli
stage:
redis: redis-cli -h staging.thekev.in -a itsasecret
prod:
redis: redis-cli -h production.thekev.in -a itsasecret
MonitorRepos
MonitorRepos' API is still (very!) subject to change.
Current caveats: all monitored repos must be on the same github org and share similar branch structures and they should have CircleCI integration. TODO: fix these caveats.
Note: you must have GITHUB_TOKEN
set with an API key which provides public_repo
(or repo
if you want to use MonitorRepos with private repositories).
You can monitor your repos with:
MyCoolGithubOrg:
monitor-repos:
repos:
- MyCoolApp
- MyEvenCoolerApp
- MyTerribleApp
branches:
- develop
- master
- staging
- production
base-branch: develop
This configuration will give you stats on the apps located at github.com/MyCoolGithubOrg/MyCoolApp
, etc: whether each of the four named branches are passing their tests, how many open issues and PRs exist, and how many commits behind develop
each of the other three branches are.