Last active
August 29, 2015 14:04
-
-
Save ereyes01/b36fb77013af85d338f8 to your computer and use it in GitHub Desktop.
Containable - More Detailed Python Mockup
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
A simple script that deploys the website deployment module to an EC2 server. | |
""" | |
import containable | |
import my_website | |
website_blueprint = my_website.MyWebsite(nginx_config_path="/work/my-nginx.conf", | |
git_url="http://github.com/me/website.git") | |
box = containable.Box(cores=1, ram="1GB", volume="8GB") | |
box.create(containable.AWS_EC2, api_key="my-api-key", | |
ssh_key="/my/ssh/key") | |
box.deploy(website_blueprint) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This is a deployment for a simple web server with a web site using the Python binding. | |
The MyWebsite class encapsulates the deployment steps of the site and server. You | |
can import this in more complicated deployments, parameterize as you need, and scale | |
to as many servers as you like. | |
""" | |
import containable | |
class MyWebsite(containable.Deployment): | |
def __init__(self, nginx_config_path=None, git_url=None): | |
with open(nginx_config_path) as config_file: | |
config_contents = config_file.read() | |
self.nginx_config = containable.File(path="/etc/nginx/sites-available/my-website", | |
contents=config_contents) | |
self.site_enabled = containable.Symlink(path="/etc/nginx/sites-enabled/my-website", | |
target=self.nginx_config.path) | |
self.site_repo = containable.GitRepo(git_url, path="/opt/site", head="origin/master") | |
def deploy(self, box): | |
box.install_package("nginx") | |
box.deploy([self.site_repo, self.nginx_config, self.site_enabled]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment