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
function retry-ssh() { | |
ssh $@ | |
while [ $? -ne 0 ]; do | |
sleep 3; | |
ssh $@; | |
done | |
} | |
function ansiblify() { | |
echo $1 | tr '.-' '_' |
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
#!/usr/bin/env python | |
# Registers all instance IPs as weighted records on route53 ( and deletes the ones that aren't part of the ASG anymore ) | |
# Example 1: will create/update/delete records for the "myservice.example.com" with currently registered ASG instances | |
# ./update_route53.py from_asg "my-asg" "myservice" "example.com" | |
# Example 2: will create/update/delete records to match the specified list of ips | |
# ./update_route53.py sync_records my-asg myservice example.com -i 200.200.200.201 200.200.200.202 | |
import argh | |
import boto | |
import boto.route53 |
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
#!/bin/bash | |
if [ -z $1 ]; then | |
echo "Usage: $0 <ip address>" | |
exit 1; | |
fi; | |
IP_ADDR=$1 | |
while true; do |
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
#!/bin/bash | |
# just a quick-and-dirty solution to update the peers configuration of haproxy upon ASG changes | |
# instance-id becomes the peer name ( need to use -L<instance_id> on the haproxy command line) | |
# port 7777 is used for p2p communication | |
# call this script on crontab and redirect the output to > /etc/haproxy/peers.cfg then include that file into your haproxy config | |
instance_id=$(curl http://169.254.169.254/latest/meta-data/instance-id) | |
region=$(curl http://169.254.169.254/latest/meta-data/placement/availability-zone/) | |
region=${region:0:${#region}-1} |
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
#!/usr/bin/env python | |
# Reads fdupes(-r -1) output and create relative symbolic links for each duplicate | |
# usage: fdupes -r1 . | ./lndupes.py | |
import os | |
from os.path import dirname, relpath, basename, join | |
import sys | |
lines = sys.stdin.readlines() |
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
#!/usr/bin/env python | |
import argh, os, sys | |
from docker import Client | |
from os.path import dirname, basename | |
def get_containers(cli): | |
container_ids = [ c['Id'] for c in cli.containers() ] | |
containers = [ cli.inspect_container(cid) for cid in container_ids ] |
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
- hosts: localhost | |
connection: local | |
gather_facts: false | |
vars: | |
region: us-east-1 | |
version: 1.0 | |
repository: ansible-deploy-test | |
server_type: todo | |
subnet_id: subnet-f7e20b80 |
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
#!/bin/bash | |
#Vault password is 1 | |
echo "Converting vault to yaml format:" | |
ansible-vault decrypt --output - vault | python ./convert_vault.py > new-vault.yml | |
echo "Decrypting a variable from the converted vault" | |
ansible localhost -i localhost, -e @new-vault.yml -m debug -a 'var=secret' --ask-vault-pas |
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
function worktree_add() { | |
## Run this function in the top level directory of a git repo | |
## to create a worktree directory from a new or existing branch | |
if [ -d ./.git ]; then | |
git rev-parse --verify "$1" | |
if [ $? -eq 0 ]; then | |
echo "Creating a worktree ../$1 from existing branch $1" | |
git worktree add "../$1" "$1" | |
else | |
echo "Creating a worktree ../$1 from a new branch $1" |
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
#!/bin/bash | |
#fix ssh-agent when attaching to a tmux session | |
fixssh() { | |
eval $(tmux show-env \ | |
|sed -n 's/^\(SSH_[^=]*\)=\(.*\)/export \1="\2"/p') | |
} |