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'
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
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 ###
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)