Skip to content

Instantly share code, notes, and snippets.

@cocoy
cocoy / conditionals_part2.yml
Created May 9, 2012 08:59
ansible issue #341
---
# this is a demo of conditional executions using 'only_if', which can skip
# certain tasks on machines/platforms/etc where they do not apply.
- hosts: web-servers
user: ubuntu
sudo: True
vars:
favcolor: "red"
@cocoy
cocoy / sample.yml
Created April 26, 2012 06:54
sample.yml for ssh config
---
- hosts: web-servers
user: ubuntu
sudo: True
vars:
http_port: "8080"
tasks:
- name: write some_random_foo configuration
@cocoy
cocoy / gist:2425477
Created April 20, 2012 02:49
slurp returns file not found.
diff --git a/library/slurp b/library/slurp
index 8b80e5d..64bf2be 100755
--- a/library/slurp
+++ b/library/slurp
@@ -42,7 +42,7 @@ params = {}
for x in items:
(k, v) = x.split("=")
params[k] = v
-source = params['src']
+source = os.path.expanduser(params['src'])
@cocoy
cocoy / gist:2006803
Created March 9, 2012 14:45
Using git subtree to checkout a subdirectory
cd /tmp
git clone https://github.com/riptano/chef.git chef
cd chef
git subtree split -P cookbooks/cassandra/ -b cassandra
cd /tmp
mkdir cassandra
git init
git fetch ../chef cassandra
@cocoy
cocoy / gist:1932528
Created February 28, 2012 13:22
knife openstack server list
knife openstack server list
ERROR: Excon::Errors::NotFound: Expected(200) <=> Actual(404 Not Found)
request => {:connect_timeout=>60, :headers=>{"Content-Type"=>"application/x-www-form-urlencoded", "Host"=>"nova-api.trystack.org:5443", "Content-Length"=>209}, :instrumentor_name=>"excon", :mock=>false, :read_timeout=>60, :retry_limit=>4, :ssl_verify_peer=>false, :write_timeout=>60, :host=>"nova-api.trystack.org", :path=>"/v2.0/", :port=>"5443", :query=>nil, :scheme=>"https", :body=>"AWSAccessKeyId=xxxxxxxx&Action=DescribeInstances&SignatureMethod=HmacSHA256&SignatureVersion=2&Timestamp=2012-02-28T13%3A20%3A02Z&Version=2010-08-31&Signature=BMowmUh4435Xw4imsJLb6SeJtZ7lw3U3nVvvw9wQT2g%3D", :expects=>200, :idempotent=>true, :method=>"POST"}
response => #<Excon::Response:0x90146c8 @body="{\"itemNotFound\": {\"message\": \"Item not found.\", \"code\": 404, \"details\": \"Error Details...\"}}", @headers={"Date"=>"Tue, 28 Feb 2012 13:20:05 GMT", "Content-Type"=>"application/json; charset=UTF-8", "Content-Length"=>
@cocoy
cocoy / gist:1156322
Created August 19, 2011 08:19
s3 public policy
{
"Version":"2008-10-17",
"Id":"",
"Statement":[{
"Sid":"Stmt1313741300912",
"Effect":"Allow",
"Principal":{
"AWS":"*"
},
"Action":"s3:GetObject",
@cocoy
cocoy / gist:1066823
Created July 6, 2011 08:25
nginx log format get clientIP behind ELB.
log_format proxied_combined '$http_x_forwarded_for - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent"';
access_log logdir/access.log proxied_combined;
#!/bin/bash
#
# Filaneme: ebs_backup
#
VOLUMES=''
EBS_DIR=/nfs-raid
ISMOUNTED=$(df -la | grep -c $EBS_DIR)
if [ $ISMOUNTED -gt 0 ];then
@cocoy
cocoy / instance-to-ebs-ami.sh
Created June 10, 2011 05:38
instance-to-ebs-ami.sh
#!/bin/bash
# Run this script on the instance to be bundled
# tested with Canonical Ubuntu 9.10 base ami
EBS_DEVICE=${1:-'/dev/sdh'}
IMAGE_DIR=${2:-'/mnt/tmp'}
EBS_MOUNT_POINT=${3:-'/mnt/ebs'}
mkdir -p $EBS_MOUNT_POINT
mkfs.ext3 ${EBS_DEVICE} -L uec-rootfs
@cocoy
cocoy / gist:921226
Created April 15, 2011 06:15
Resize/Increase the Size of a File Based DomU Xen Filesystem
Backup the File based image firstly, making sure it is not mounted nor running as a xen domU.
dd if=/dev/zero of=file.img bs=1M conv=notrunc count=1 seek=2000
#This resizes the file.img to 2GB.
losetup /dev/loop1 file.img
#loop1 had to be used as xen was already running a different domU via loop0.
e2fsck -f /dev/loop1