Exemple #1
0
from cStringIO import StringIO

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:
Exemple #2
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 ###
Exemple #3
0
from datetime import datetime
from fabric.api import env, run, sudo, cd, hide, prefix, prompt, settings
from fabric.contrib.files import append, sed
from fabric.decorators import task

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

config.add('projects', {
    'mysql_root_user': unicode | default("root"),       # Root user to create the database (optional)
    'mysql_root_password': unicode | default(None),     # Root password to create the database (optional)
    'mysql_host': unicode | default(None),              # Host, defaults to local
    'mysql_port': unicode | default(3306),              # Port, defaults to 
    'mysql_transient': unicode | default(False),        # Can this be reset without pause? i.e. the data here is not important.
    'mysql_user': unicode | default(None),              # Project/application specific user, not root
    'mysql_password': unicode | default(None),          # Project/application specific password, not the root password
    'mysql_name': unicode | default(None),              # Project/application specific database name
})

def args():
    args = [
        '--user=%s' % env.project.mysql_root_user,
        '--password=%s' % env.project.mysql_root_password,
    ]
    if env.project.mysql_host:
        args.extend([
            '--host=%s' % env.project.mysql_host,
            '--port=%s' % env.project.mysql_port,
        ])
    return " ".join(args)
Exemple #4
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
Exemple #5
0
from fabric.contrib.files import append
from cStringIO import StringIO

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 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