Skip to content

Instantly share code, notes, and snippets.

View tsabat's full-sized avatar

Tim Sabat tsabat

View GitHub Profile
require 'json'
Vagrant::Config.run do |config|
config.vm.box = "12_10_chef"
config.vm.box_url = "http://cloud-images.ubuntu.com/raring/current/raring-server-cloudimg-vagrant-amd64-disk1.box"
config.vm.customize ["modifyvm", :id, "--memory", "1500"]
#if not RUBY_PLATFORM.downcase.include?("mswin")
#config.vm.customize ["modifyvm", :id, "--cpus",

Ok, so here's my laundry list. I'm going to use Chef terminology here, but this bleeds over to Docker, Salt, Puppet, etc.

Your stack creation product should force me to use best practices. I should specify the project type and you should do the following.

  • prompt me for my source code repo
  • set up apache/nginx/caching/db
  • run my project

It'd be great for this to work out of the box for major frameworks like rails, django, pyramid, express

#!/bin/bash -e verbose
grep "codepen_fstab_setup" /etc/fstab
if [ $? -eq 1 ]; then
echo "# codepen_fstab_setup" | tee -a /etc/fstab
echo "/dev/xvdf /cp xfs noatime 0 0" | tee -a /etc/fstab
echo "/cp/codepen /home/deploy/codepen none bind" | tee -a /etc/fstab
fi
if [ $? -eq 0 ]; then
@tsabat
tsabat / snapshot.py
Last active May 3, 2016 17:19
A python script to snapshot the volume attached to an instance.
#! /usr/bin/python
from boto import ec2;
import boto.utils
import argparse
def parsed_args():
parser = argparse.ArgumentParser()
parser.add_argument("-i", "--instance_id",
help="the instance id you want to snapshot. default: current instance id",
@tsabat
tsabat / prep_instance.py
Last active December 19, 2015 03:29
Given a tag, search for the most recent snapshot, create a volume and mount it.
#! /usr/bin/python
from boto import ec2
import boto.utils
import argparse, time, os, json
def parsed_args():
parser = argparse.ArgumentParser()
parser.add_argument("-g", "--instance_tags",
help='the tags you want to apply to your instance. default: {"Name","app", "Environment":"Production", "Role":"app"}',
@tsabat
tsabat / deploy_utils.rb
Last active April 13, 2016 16:46
A ruby script to get all instances with a given tags.
require 'aws-sdk'
require 'awesome_print'
class AwsUtil
def ec2_object
# deployer user, has read-only access
AWS::EC2.new(
access_key_id: "<your_key_here>",
secret_access_key: "<your_secret_here>",
@tsabat
tsabat / gist:5891043
Last active December 19, 2015 03:38
capistrano multistage script.
set :branch, "master"
# tagged:
# Role:app && Environment:'production'
# filtered:
# instance-state-name:running
aws_servers = AwsUtil.new.deployed_app_server_dns_names
role(:app) { aws_servers }
role (:web) { aws_servers }
@tsabat
tsabat / chef_userdata.sh
Last active December 19, 2015 03:38
The user data passed to codepen's launch config.
#!/bin/bash -ex
exec > >(tee /var/log/user-data.log|logger -t user-data -s 2>/dev/console) 2>&1
echo BEGIN
EC2_HOSTNAME=`ec2metadata --public-hostname`
EC2_HOST=`echo $EC2_HOSTNAME | cut -d. -f1`
EC2_HOST=$EC2_HOST.`echo $EC2_HOSTNAME | cut -d. -f2`
if [ -a /etc/chef/client.pem ]; then
rm /etc/chef/client.pem
@tsabat
tsabat / userdata.sh
Last active December 19, 2015 03:38
more AWS user data details
#!/bin/bash
# usage: userdata_run.sh EC2_HOSTNAME
grep "codepen_fstab_setup" /etc/fstab
if [ $? -eq 1 ]; then
echo "# codepen_fstab_setup" | tee -a /etc/fstab
echo "/dev/xvdf /cp xfs noatime 0 0" | tee -a /etc/fstab
echo "/cp/codepen /home/deploy/codepen none bind" | tee -a /etc/fstab
fi
@tsabat
tsabat / aws_create_launch_config.sh
Last active December 19, 2015 03:38
an aws launch config creation script
#!/bin/bash
LAUNCH_CONFIG_NAME="app-launch-config"
IMAGE_ID="ami-55198965"
INSTNCE_TYPE="c1.medium"
KEY="codepen_west"
GROUP="default"
USER_DATA_FILE="chef_userdata.sh"
MONITORING_ENABLED="--monitoring-enabled"