This file contains 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
BEGIN { | |
STARTBLOCK="{" | |
CONDITION="REMOVEME" | |
ENDBLOCK="}" | |
} | |
{ | |
if ($0 ~ STARTBLOCK) { | |
block[nf=1] = $0 | |
flag=1 | |
} else if (flag==1) { |
This file contains 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 sys | |
from yaml import load, dump, error | |
try: | |
from yaml import CLoader as Loader, CDumper as Dumper | |
except ImportError: | |
from yaml import Loader, Dumper |
This file contains 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
awk -v BINIT="START PATTERN" -v BEND="END PATTERN" ' | |
{ | |
if ($0 ~ BINIT) { | |
F=1 | |
} | |
if ($0 ~ BEND) { | |
F=0 | |
} | |
if (F==1) { | |
print $0} |
This file contains 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 | |
YAML="${1}" | |
[ -f "${YAML}" ] || { echo "No such file as '${YAML}'"; exit 1; } | |
eyaml decrypt -e "${YAML}" | awk ' | |
{ | |
l=$0; | |
getline nl; |
This file contains 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
import subprocess, shlex | |
def cmd_execute(command): | |
cmd = shlex.split(command, posix = False) | |
try: | |
p = subprocess.Popen(cmd, stdout = subprocess.PIPE, stderr = subprocess.STDOUT) | |
preturn = p.wait() | |
stdout = '' | |
tmp_stdout = p.stdout.readline() | |
while tmp_stdout: |
This file contains 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
_terraform() { | |
local cmds cur colonprefixes; | |
COMPREPLY=(); | |
if [[ "${COMP_WORDS[$COMP_CWORD]}" =~ ^-target= ]]; then | |
cmds=$(grep -hE "^ *(module|resource)" *.tf | tr -d '"'| awk ' | |
$1 ~ /module/ {print "-target="$1"."$2}; | |
$1 ~ /resource/ { print "-target="$2"."$3} | |
') | |
else | |
cmds=$(terraform --help ${COMP_WORDS[1]} | awk ' |
This file contains 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 | |
declare -A COLORS | |
COLORS[RED]='\033[0;31m' | |
COLORS[GREEN]='\033[0;32m' | |
COLORS[NC]='\033[0m' | |
COLORS[WHITE]='\033[1m' | |
# Print a string using colors | |
# $1 The color |
This file contains 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 | |
TERRAFORM_DIR="TERRAFORM_DIRECTORY" | |
find ${TERRAFORM_DIR} -name "*.tfstate" | while read lfile; do | |
rfile="$(jq '.remote.config | select (.key != null) | "s3://" + .bucket + "/" + .key' ${lfile} -r)" | |
if [ -n "${rfile}" ]; then | |
if ! diff -q ${lfile} <(s3cmd --no-progress get ${rfile} -) > /dev/null; then | |
echo "${lfile} differs, syncing ..." | |
cd "$(dirname "${lfile}")/.." | |
terraform remote pull && \ |
This file contains 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
# -*- mode: ruby -*- | |
# vi: set ft=ruby : | |
$script = <<END | |
RUBY_VERSION="2.2.5" | |
sudo apt-get -y update | |
sudo apt-get -y install git nodejs | |
# Install ruby environment | |
if ! type rvm >/dev/null 2>&1; then | |
curl -sSL https://rvm.io/mpapis.asc | gpg --import - |
OlderNewer