Skip to content

Instantly share code, notes, and snippets.

View chhibber's full-sized avatar

Sono Chhibber chhibber

View GitHub Profile
@chhibber
chhibber / getawssecrets.py
Created July 3, 2018 03:18
Sceptre Get Secrets from Secrets Manager
import boto3
from botocore.exceptions import ClientError
from sceptre.resolvers import Resolver
import json
def get_secret(secret_name, secret_key, region):
endpoint_url = "https://secretsmanager." + region + ".amazonaws.com"
region_name = region
@chhibber
chhibber / Prune-Merged-Branches.md
Created July 28, 2017 15:51
Prune Merged Branches
  1. Prune branches
  2. Get all branches that have been merged into master
  3. Remove master from the list (grep is for an exact match anchoring with ^ and $
  4. Feed the list of merged branches to xargs and delete them (lower case -d will only delete merged branches)
git fetch -p && git branch --merged master | grep -v '^ *master$' | xargs git branch -d

alias delete-merged-branches="git fetch -p && git branch --merged master | grep -v '^ *master$' | xargs git branch -d"
@chhibber
chhibber / AWS-add-volume-to-jenkins-ec2-agent.md
Created January 27, 2017 14:54
Mounting a larger workspace an EC2 slave system on boot

What your block devices look like before mapping:

ubuntu@cpu:~$ lsblk
NAME    MAJ:MIN RM  SIZE RO TYPE MOUNTPOINT
xvda    202:0    0  100G  0 disk 
└─xvda1 202:1    0  100G  0 part /
ubuntu@cpu:~$ 
@chhibber
chhibber / gist:8414234
Created January 14, 2014 06:55
Salt: top.sls example
base:
"*":
- baseRequirements
- baseRequirements.vim
- baseRequirements.limits
- baseRequirements.rpmrepo-treasuredata.sls
- fluentd
- sysctl
- system.set_hostname
- FOOBARApp.tag
@chhibber
chhibber / gist:8414223
Created January 14, 2014 06:53
State File: New Relic
Newrelic - install repo:
cmd.run:
- name: rpm -Uvh http://download.newrelic.com/pub/newrelic/el5/i386/newrelic-repo-5-3.noarch.rpm
- unless: rpm -qa | grep newrelic-repo
newrelic-sysmond:
pkg:
- installed
- require:
- cmd: Newrelic - install repo
@chhibber
chhibber / gist:8414206
Created January 14, 2014 06:51
Salt State File for Nginx
nginx:
pkg:
- installed
service.running:
- pkg: nginx
- watch:
- pkg: nginx
- file: /etc/nginx/nginx.conf
- file: /etc/nginx/mime.types
- file: /etc/nginx/sites-enabled/FOOBAR
@chhibber
chhibber / gist:8414192
Created January 14, 2014 06:49
Salt: Unicorn state file and init script
File: init.sls
------------------------------------------
/etc/init.d/unicorn:
file.managed:
- order: 1
- mode: 774
- template: jinja
- ENV: {{ grains['environment'] }}
- source: salt://unicorn/unicorn_init
@chhibber
chhibber / gist:8414154
Created January 14, 2014 06:43
AWS Example - NAT Monitor Puled together code from a few different locations to make this
#!/usr/bin/env python
# vim:set sr et ts=4 sw=4 ft=python fenc=utf-8: // See Vim, :help 'modeline'
"""
"""
import sys
import os
import traceback
@chhibber
chhibber / gist:8414119
Created January 14, 2014 06:39
AWS Bootstrapping Cloudformation
#!/usr/bin/python
# __author__ = 'sono'
import boto
import boto.cloudformation
import boto.rds
import json
import yaml
import os
@chhibber
chhibber / gist:8414078
Created January 14, 2014 06:35
AWS - NAT Bootstrap Example
#!/bin/bash -
#===============================================================================
# vim: softtabstop=4 shiftwidth=4 expandtab fenc=utf-8 spell spelllang=en
#===============================================================================
set -x
SALT_BOOTSTRAP_SCRIPT="salt-bootstrap.sh"
SALT_BOOTSTRAP_DOWNLOAD="http://bootstrap.saltstack.org"
exec 2>&1 > /tmp/awsbootstrap.log