def test_config():
    conf = config.add_group('aws', {
        'region': unicode,                        # Region to place the server, e.g. 'us-east-1'
        'access_key_id': unicode | required,      # Access Key from the AWS Command Console.
        'key_pair': unicode,                      # Name of the Key Pair to use.
        'security_group': unicode,                # The Security Group to use.
        'ami': unicode,                           # The name of the AMI to use.
        'zone': unicode,                          # The Zone to place the server in, e.g. 'us-east-1c'
        'type': unicode,                          # The Type to use, e.g. 'm1.small'
        'disk_size': int,                         # Disk size in gigabytes.
    })

    config.add('aws', {
        'secret_access_key': unicode | required,  # Secret Access Key and from the AWS Command Console.
    })

    config.load('tests/examples/aws.yaml')

    assert config.value.aws is conf

    small = conf.small
    assert small.key == 'small'
    assert small.region == 'us-east-1'
    assert small.access_key_id == 'FAKE$@!@%YWUTERHGFT'
    assert small.secret_access_key == 'fake328twigpojasdfoiweitjiogjaspdofjjflk'
    assert small.type == 'm1.small'

    micro = conf.micro
    assert small.key == 'small'
    assert micro.region == 'us-east-1'
    assert micro.access_key_id == 'FAKE$@!@%YWUTERHGFT'
    assert micro.secret_access_key == 'fake328twigpojasdfoiweitjiogjaspdofjjflk'
    assert micro.type == 't1.micro'
Beispiel #2
0
from fabric.api import env, cd
from fabric import state
from fabric.decorators import task


### Config ###
from mercantile.config import config, required, string_list

conf = config.add_group('projects', {
    'user': unicode | required,         # The username to use as the owner. (Required)
    'git': unicode,                     # Location of the git repository.
    'static': unicode,                  # Directory to alias the url: /static
    'mysql_user': unicode,              # Name of the mysql database user.
    'mysql_password': unicode,          # Password for the mysql database user.
    'mysql_name': unicode,              # Name of the mysql database.
    'data_transient': bool,             # Flag if the data can be killed and rebuilt without warning.
    'server': unicode,                  # The key of a server config.
    'django_settings': unicode,         # Marks this a django project with the given settings.
    'domains': string_list,             # A list of domain names to route to this.
    'wsgi': unicode,                    # Marks this a wsgi app with the given application location.
    'gems': string_list,                # Gems to install when creating the project.
})


def project_required(fn):
    def project_wrapper(*args, **kwargs):
        if not getattr(env, 'project', None):
            print "You must select a project first, e.g.\n> fab qa ..."
            return -1
        return fn(*args, **kwargs)
    project_wrapper.func_name = fn.func_name
Beispiel #3
0
from fabric.decorators import task
from fabric.tasks import execute
from fabric.api import env, cd, settings, sudo, run, put, hide, show
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 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
Beispiel #4
0
import posixpath

from fabric.api import env, cd, prefix
from fabric import state
from fabric.decorators import task


### Config ###
from mercantile.config import config, required, string_list

conf = config.add_group('projects', {
    'user': unicode | required,         # The username to use as the owner. (Required)
    'root': unicode,                    # Root to the directory of the project.
    'git': unicode,                     # Location of the git repository.
    'data_transient': bool,             # Flag if the data can be killed and rebuilt without warning.
    'server': unicode,                  # The key of a server config.
    'domains': string_list,             # A list of domain names to route to this.
    'wsgi': unicode,                    # Marks this a wsgi app with the given application location.
    'gems': string_list,                # Gems to install when creating the project.
})


def project_required(fn):
    def project_wrapper(*args, **kwargs):
        if not getattr(env, 'project', None):
            print "You must select a project first, e.g.\n> fab qa ..."
            return -1
        return fn(*args, **kwargs)
    project_wrapper.func_name = fn.func_name
    return project_wrapper
Beispiel #5
0
import time, sys
from fabric.decorators import task
from fabric.tasks import execute
from fabric.api import env, run, sudo, cd, hide, prefix, prompt, settings
from fabric.contrib.console import confirm
from fabric.contrib.files import append, sed


### Config ###
from mercantile.config import config, required
conf = config.add_group('aws', {
    'region': unicode,                        # Region to place the server, e.g. 'us-east-1'
    'access_key_id': unicode | required,      # Access Key from the AWS Command Console.
    'secret_access_key': unicode | required,  # Secret Access Key and from the AWS Command Console.
    'key_pair': unicode,                      # Name of the Key Pair to use.
    'security_group': unicode,                # The Security Group to use.
    'ami': unicode,                           # The name of the AMI to use.
    'zone': unicode,                          # The Zone to place the server in, e.g. 'us-east-1c'
    'type': unicode,                          # The Type to use, e.g. 'm1.small'
    'disk_size': int,                         # Disk size in gigabytes.
})


### Helpers ###
def activate(name):
    global conf
    conf = conf[name]

env.aws = None
def ec2_connection():
    """
Beispiel #6
0
from fabric.decorators import task
from fabric.tasks import execute
from fabric.api import env, cd, settings, sudo, run, put, hide, show
from fabric.contrib.files import append
from cStringIO import StringIO


### Mercantile ###
from mercantile.config import config, required, string_list

conf = config.add_group('users', {
    'name': unicode | required,         # Full name of the user.
    'email': unicode,                   # Email of the user.
    'supervisor': bool,                 # Give the user sudo on supervisor via sudoers.
    'sudo': bool,                       # Add the user to the sudoers.
    'public_key': unicode,              # Public key of the user.
    'private_key': unicode,             # Private key of the user.
    'authorized_keys': [ unicode ],     # List of authorized keys that can log in without a password.
})


### Helpers ###
def activate_user(username):
    env.user = conf[username]


### Tasks ###
@task
def build(username=None):
    if username is None:
        for username in env.server.users: