Commit 188e1d3d53735f2038b4c7019c489e111c286d75
1 parent
4b2544b2
Exists in
master
and in
39 other branches
Fabric is now configurable.
Showing
2 changed files
with
18 additions
and
20 deletions
Show diff stats
.gitignore
fabfile.py
| @@ -3,17 +3,15 @@ | @@ -3,17 +3,15 @@ | ||
| 3 | import os | 3 | import os |
| 4 | 4 | ||
| 5 | from fabric import colors | 5 | from fabric import colors |
| 6 | +from fabric.utils import error | ||
| 6 | from fabric.decorators import task | 7 | from fabric.decorators import task |
| 7 | from fabric.api import env, run, sudo, local | 8 | from fabric.api import env, run, sudo, local |
| 8 | from fabric.contrib.files import exists | 9 | from fabric.contrib.files import exists |
| 9 | from fabric.context_managers import prefix, cd, settings, shell_env | 10 | from fabric.context_managers import prefix, cd, settings, shell_env |
| 10 | 11 | ||
| 11 | 12 | ||
| 12 | -### Start of config | ||
| 13 | - | ||
| 14 | APP_USER = APP_NAME = VENV_NAME = 'colab' | 13 | APP_USER = APP_NAME = VENV_NAME = 'colab' |
| 15 | -REPO_URL = 'To be defined' | ||
| 16 | - | 14 | +REPO_URL = 'git@github.com:colab-community/colab.git' |
| 17 | 15 | ||
| 18 | environments = { | 16 | environments = { |
| 19 | 'dev': { | 17 | 'dev': { |
| @@ -23,23 +21,9 @@ environments = { | @@ -23,23 +21,9 @@ environments = { | ||
| 23 | 'is_vagrant': True, | 21 | 'is_vagrant': True, |
| 24 | 'superuser': 'vagrant', | 22 | 'superuser': 'vagrant', |
| 25 | }, | 23 | }, |
| 26 | - 'qa': { | ||
| 27 | - 'hosts': [], | ||
| 28 | - 'port': 22, | ||
| 29 | - 'is_vagrant': False, | ||
| 30 | - 'superuser': 'root', | ||
| 31 | - }, | ||
| 32 | - 'prod': { | ||
| 33 | - 'hosts': [], | ||
| 34 | - 'port': 22, | ||
| 35 | - 'is_vagrant': False, | ||
| 36 | - 'superuser': 'root', | ||
| 37 | - }, | ||
| 38 | } | 24 | } |
| 39 | DEFAULT_ENVIRONMENT = 'dev' | 25 | DEFAULT_ENVIRONMENT = 'dev' |
| 40 | 26 | ||
| 41 | -### End of config | ||
| 42 | - | ||
| 43 | env.user = APP_USER | 27 | env.user = APP_USER |
| 44 | env.use_shell = False | 28 | env.use_shell = False |
| 45 | 29 | ||
| @@ -52,11 +36,24 @@ SETTINGS_PATH = os.path.join(MANAGE_PATH, APP_NAME) | @@ -52,11 +36,24 @@ SETTINGS_PATH = os.path.join(MANAGE_PATH, APP_NAME) | ||
| 52 | 36 | ||
| 53 | 37 | ||
| 54 | @task | 38 | @task |
| 55 | -def environment(name): | 39 | +def environment(name=DEFAULT_ENVIRONMENT): |
| 56 | """Set the environment where the tasks will be executed""" | 40 | """Set the environment where the tasks will be executed""" |
| 41 | + global REPO_URL | ||
| 42 | + | ||
| 43 | + try: | ||
| 44 | + import project_cfg | ||
| 45 | + except ImportError: | ||
| 46 | + pass | ||
| 47 | + else: | ||
| 48 | + REPO_URL = project_cfg.repository_url | ||
| 49 | + environments.update(project_cfg.environments) | ||
| 50 | + | ||
| 51 | + if name not in environments: | ||
| 52 | + error(colors.red('Environment `{}` does not exist.'.format(name))) | ||
| 53 | + | ||
| 57 | env.update(environments[name]) | 54 | env.update(environments[name]) |
| 58 | env.environment = name | 55 | env.environment = name |
| 59 | -environment(DEFAULT_ENVIRONMENT) | 56 | +environment() |
| 60 | 57 | ||
| 61 | 58 | ||
| 62 | def aptget_install(pkg): | 59 | def aptget_install(pkg): |