Beispiel #1
0
from mercantile.config import config, required, string_list, contents_of_path, default_file, default


conf = config.add_group('servers', {
    'name': unicode | required,                         # Name of the server. (Required)
    'description': unicode,                             # Description of the server.
    'host': unicode,                                    # IP or host name for the server.
    'identity': unicode,                                # The path to a private key / identity file for root.
    'users': string_list,                               # A list of users to install
    'packages': string_list,                            # A list of packages to install
    'aws': unicode,                                     # The key of an aws config to use.
    'mysql_root_password': unicode,                     # Sets the root mysql password.
    'root_password': unicode,                           # Password for root, if available.
    'language': unicode | default("LANG=en_US.UTF-8"),  # English
    # Templates
    'motd.txt': unicode | default_file("motd.txt"),
})


### Helpers ###
env.server = None
def activate(name):
    global conf
    env.server = conf = conf[name]
    if conf.identity:
        env.key_filename = env.server.identity
    if conf.host:
        env.hosts = [env.server.host]
    if conf.aws:
        import aws
        aws.activate(env.server.aws)
Beispiel #2
0
from fabric.api import env, run, sudo, cd, hide, prefix, prompt, settings, show, local, lcd
from fabric.tasks import execute
from fabric.contrib.files import append, sed, exists
from fabric.decorators import task

from mercantile.config import config, default_file, default
from server import put_template

## Templates ##
config.add('servers', {
    'server_nginx.conf': unicode | default_file("server_nginx.conf"),
    'nginx.init': unicode | default_file("nginx.init"),
    'nginx_version': unicode | default("nginx-1.5.12.tar.gz"),
    'www_owner': unicode | default("www")
})

config.add('projects', {
    'nginx.conf': unicode | default_file("nginx.conf"),
    'supervisor.conf': unicode | default_file("supervisor.conf"),
    'uwsgi.conf': unicode | default_file("uwsgi.conf"),
    'wsgi.py': unicode | default_file("wsgi.py"),
    'manage.py': unicode | default_file("manage.py"),
})

### Helpers ###
def cd_src():
    return cd("/www/%s/src" % env.project.key)


### Tasks ###
@task
Beispiel #3
0
import posixpath

from fabric.api import env, run, sudo, cd, hide, prefix, prompt, settings, show, local, lcd
from fabric.tasks import execute
from fabric.contrib.files import append, sed, exists
from fabric.decorators import task

from mercantile.config import config, default_file, default
from server import put_template
from project import root, cd_src, prefix_env

## Templates ##
config.add('servers', {
    'server_nginx.conf': unicode | default_file("server_nginx.conf"),
    'nginx.init': unicode | default_file("nginx.init"),
    'nginx_src': unicode | default("http://nginx.org/download/nginx-1.7.4.tar.gz"),
    'uwsgi_src': unicode | default("http://projects.unbit.it/downloads/uwsgi-latest.tar.gz"),
    'www_owner': unicode | default("www"),
})

config.add('projects', {
    'nginx.conf': unicode | default_file("nginx.conf"),
    'supervisor.conf': unicode | default_file("supervisor.conf"),
    'uwsgi.conf': unicode | default_file("uwsgi.conf"),
    'is_django': bool | default(False),
    'static': unicode | default('/static'),
    'extra_requirements': unicode,
})


### Tasks ###
Beispiel #4
0
conf = config.add_group('servers', {
    'name': unicode | required,                         # Name of the server. (Required)
    'description': unicode,                             # Description of the server.
    'host': unicode,                                    # IP or host name for the server.
    'identity': unicode,                                # The path to a private key / identity file for root.
    'users': string_list,                               # A list of users to install
    'packages': string_list,                            # A list of additional packages to install
    'pip': string_list,                                 # A list of additional python packages to install
    'aws': unicode,                                     # The key of an aws config to use.
    'service_root': unicode | default('/srv'),          # Directory root to the services.
    'mysql_root_password': unicode,                     # Sets the root mysql password.
    'root_login': unicode | default('root'),            # Root login
    'root_password': unicode,                           # Password for root, if available.
    'language': unicode | default("LANG=en_US.UTF-8"),  # English
    'motd.txt': unicode | default_file("motd.txt"),     # MOTD Template
})


### Helpers ###
env.server = None
def activate(name):
    global conf
    env.server = conf = conf[name]
    if conf.identity:
        env.key_filename = env.server.identity
    if conf.host:
        env.hosts = [env.server.host]
    if conf.aws:
        import aws
        aws.activate(env.server.aws)