Skip to content

Instantly share code, notes, and snippets.

View garlandkr's full-sized avatar
🎯
Focusing

Ken Garland garlandkr

🎯
Focusing
View GitHub Profile
@garlandkr
garlandkr / .gitconfig
Last active August 29, 2015 14:08 — forked from pksunkara/config
[user]
name = Pavan Kumar Sunkara
email = [email protected]
[core]
editor = vim
whitespace = fix,-indent-with-non-tab,trailing-space,cr-at-eol
excludesfile = ~/.gitignore
[sendemail]
smtpencryption = tls
smtpserver = smtp.gmail.com
@garlandkr
garlandkr / cw_get_loadavg.py
Created October 16, 2014 20:34
Get load_avg from Cloudwatch
import boto
import datetime
cw = boto.connect_cloudwatch()
instance_id = boto.utils.get_instance_metadata()['instance-id']
now = datetime.datetime.utcnow()
start_time = now - datetime.timedelta(days=1)
namespace = "System"
@garlandkr
garlandkr / write_ec2_hosts.py
Last active August 29, 2015 14:07
Write EC2 hosts to ssh_config
"""
First generate the hosts.yaml file using the ec2.py inventory script.
./inventory/ec2.py --refresh-cache > hosts.yaml
"""
import os
import yaml
user = "ec2-user"
---
# Deploys a new version of foo
- name: Deploy new version of foo
hosts: tag_type_appserver:&tag_stage_prod
user: ubuntu
sudo: true
gather_facts: false
serial: 1
vars_prompt:
#!/bin/bash
#==============
# Start
#==============
init() {
sudo apt-get update
sudo apt-get -y dist-upgrade
@garlandkr
garlandkr / ami-clean.sh
Last active May 31, 2024 10:38
Clean-up an Amazon EC2 instance before creating an AMI
#!/bin/bash
# Run this script with:
# bash <(curl -s https://gist.github.com/garlandkr/e80674b49270b0199fa6/raw/ami-clean.sh
function print_green {
echo -e "\e[32m${1}\e[0m"
}
print_green 'Clean Yum'
"""
Requeriments:
$ sudo pip install boto dnspython
Edit ~/.boto to use your AWS credentials
"""
import time
import sys
ansible-playbook -i inventory create-ec2-instance.yml --limit dev-web-server-78a -vv
Traceback (most recent call last):
File "/usr/local/bin/ansible-playbook", line 309, in <module>
sys.exit(main(sys.argv[1:]))
File "/usr/local/bin/ansible-playbook", line 150, in main
inventory = ansible.inventory.Inventory(options.inventory, vault_password=vault_pass)
File "/usr/local/lib/python2.7/site-packages/ansible/inventory/__init__.py", line 100, in __init__
self.parser = InventoryDirectory(filename=host_list)
File "/usr/local/lib/python2.7/site-packages/ansible/inventory/dir.py", line 58, in __init__
parser = InventoryParser(filename=fullpath)
# This will cause full debug output to go to the console
import boto
boto.set_stream_logger('foo')
ec2 = boto.connect_ec2(debug=2)