Python Deployment Tool
Project description
Indexes
Introduction
Mordor is a tool helps you to deploy your python project.
Config
Config directory
- If you specify
-c
option, mordor uses the config directory you specified after-c
option - If you have environment variable
MORDOR_CONFIG_DIR
set, mordor uses it as config directory - Otherwise, mordor uses
~/.mordor
as config directory
mordor reads config from ~/.mordor/config.json
or if you specify -c
option to override it, for example if you have -c /home/stonezhong/testmordor/.mordor
then mordor will read config from /home/stonezhong/testmordor/.mordor/config.json
Config structure
Here is an example:
{
"hosts": {
"mordortest": {
"ssh_host" : "mordortest",
"env_home" : "/root/mordor",
"virtualenv": "/usr/bin/virtualenv",
"python3" : "/usr/bin/python3"
}
},
"deployments": {
"sample_beta": {
"name" : "sample",
"stage" : "beta",
"home_dir" : "/home/stonezhong/DATA_DISK/projects/mordor/sample",
"deploy_to" : [ "mordortest" ],
"use_python3" : true,
"config" : {
"foo.json": "copy"
}
}
}
}
- In
hosts
section, you need to list all your target machine which you want to deploy to.- You need to make sure you can ssh to each machine without entering password, you can config your
~/.ssh/config
if needed - If your target machine support python3, you need to specify python3 location
env_home
is the root path for mordor, normally you want to point it to a large disk, for example/mnt/mordor
ssh_host
is the name of the host when you do ssh, normally it should match what you have in your~/.ssh/config
file
- You need to make sure you can ssh to each machine without entering password, you can config your
- In
deployments
section, you list all the deployments you want to deployname
is the name of the application, if missing, then the deployment name becomes the application namestage
is the name of the stage, usually it is something likebeta
,prod
, etc, but it can be anything- The same application can have as many stages as it can, but each target can only deploy one stage. For example, you cannot deploy both beta and prod stage of the same app to the same target
deploy_to
is a list of the target's nameuse_python3
: set to true if your app need python3- the
config
section list all the config file you need to deploy to the target - when looking for config file xyz, mordor lookup the config in
<base_config_dir>/configs/<app_name>/<stage>/xyz
, then then fallbacks to<base_config_dir>/configs/<app_name>/xyz
- <base_config_dir> is
~/.mordor
by default, or you can use-c
option to change it.
- <base_config_dir> is
stage
: the stage of this deployment, if missing, then stage is ""
Sample commands
Init target host
Initialize target host
# initialize mordor on target host mordortest, using config file from /home/stonezhong/testmordor/.mordor
mordor -c /home/stonezhong/testmordor/.mordor -a init-host -o mordortest
Stage application to target
Stage application to target
# stage application sample to beta stage
# the application will be copied to the target machine
# configuration will be copied to the target machine
# python virtual environment will be created on target machine
mordor -c /home/stonezhong/testmordor/.mordor -a stage -p sample -s beta
Run a command on target
Run a command on target
# run command
# application is "sample", stage is "beta", command is "foo" with option "xyz abc"
mordor -c /home/stonezhong/testmordor/.mordor -a run -p sample -s beta -cmd foo -co "xyz abc"
Application Structure
You can look at the Sample
- You need to have a manifest.json file, you normally want to bump the version if you make changes to your application.
- You need to have a requirements.txt in your application root which tells list of packages you need to install
- Optional, if you want to support running remote command, you need to have a
dispatch.py
. When you runmordor -a run ...
, this python code will be invoked to handle the command
Command line options
mordor \
-c <mordor_config_base> \
-a <action> \
-o <target_name> \
-p <app_name> \
-s <stage> \
-cmd <your command here> \
-co <your command arguments here>
# -c, if missing , mordor looks for config in ~/.mordor
# -a, action, could be `init-host`, `stage` or `run`
# -o, specify the the target machine.
# for init-host, you must specify this
# for stage or run, if missing, then the scope is all the target for the stage
# -p, the application name
# -s, the stage name, if missing, the stage name is empty string
# -cmd, the command you want to run when your action is "run"
# -co, the command arguments when your action is "run"
Target host mordor file structure
<Mordor Home Directory>
|
+-- apps Home directory for all applications
| |
| +-- <application name> Home directory for an application
| |
| +-- <version 1> Directory for version 1 of application
| |
| +-- <version 2> Directory for version 2 of application
| |
| +-- current A symlink to the current version
|
+-- bin Some tools used by mordor
|
+-- configs Home directory for configs for all applications
| |
| +-- <application name> Config for an application
| |
| +-- config1 depends on your deployment's `config` settings
| |
| +-- config2
|
+-- logs Home directory for logs for all applications
| |
| +-- <application name> Logs for an application
|
+-- pids Directory for pid for each application
| |
| +-- <application name>.pid pid for the latest run of an application
|
+-- venvs Home for virtual envs for all application
| |
| +-- <application name>_<version> Virtual env for a given application with given version
| |
| +-- <application_name> A symlink points to the current version
|
+-- data
| |
| +-- <application name>
|
+-- temp Temporary directory
- stage command does not touch the data directory.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
mordor2-0.0.30.tar.gz
(9.0 kB
view details)
Built Distribution
File details
Details for the file mordor2-0.0.30.tar.gz
.
File metadata
- Download URL: mordor2-0.0.30.tar.gz
- Upload date:
- Size: 9.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3df911f0c748235cf219d908ae26dc81416f8a06c20850868ad675506a1fccb6 |
|
MD5 | cd922242ee03a4d7b56f73318be396bc |
|
BLAKE2b-256 | f790327db808fbcf3c352f8b49bee89941df2098638d3fb35874c1c2e04cbea2 |
Provenance
File details
Details for the file mordor2-0.0.30-py2.py3-none-any.whl
.
File metadata
- Download URL: mordor2-0.0.30-py2.py3-none-any.whl
- Upload date:
- Size: 11.7 kB
- Tags: Python 2, Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/50.3.0 requests-toolbelt/0.9.1 tqdm/4.49.0 CPython/3.6.9
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 843522ee1c079873f7b3177b8cca71140b67ad4fc1de1c28af19d51868fde06e |
|
MD5 | e83cc038500f0b464ad08a4e369d2362 |
|
BLAKE2b-256 | 90a5d332a3d9e2aa55a148ea41ffe3be22f0a1ca1aa4261500d342aaeeaaeacc |