Skip to content

Instantly share code, notes, and snippets.

View jonathanhle's full-sized avatar

Jonathan Le jonathanhle

View GitHub Profile
@jonathanhle
jonathanhle / gist:1fea2935737451721ae1
Created April 25, 2015 23:49
Rebase babun after installing packages, when you get memory conflicts
1) Exit babun.
2) cmd /c %SYSTEMDRIVE%\Users\%USERNAME%\.babun\cygwin\bin\dash.exe -c '/usr/bin/rebaseall -v'
@jonathanhle
jonathanhle / ansible-playbook.bat
Created May 8, 2015 06:04
ansible-playbook.bat shim for Babun
@echo off
REM This is the default Babun install location.
set CYGWIN=%USERPROFILE%\.babun\cygwin
REM This is the default Babun shell, changed to bash if you need to
set SH=%CYGWIN%\bin\zsh.exe
REM You'll need to adjust the sed command below in order for this shim to work for your installation.
REM Below the Babun install directory was C:\Users\Admin\.babun\ for the "Admin" user; if your user is FooUsername, change "Admin" to "FooUsername" in the sed commands
@jonathanhle
jonathanhle / gist:4917f6a7cdfb3c5493f3
Created October 20, 2015 16:45
Cheaply AWKing the AWS elb logs at the command line
cat *elasticloadbalancing*.log | awk '{print $4 " " $8 " " $9 " " $1 " " $2 " " $3 " " $5 " " $6 " " $7 " " substr($0, index($0,$11))}' | awk '$2 != "200"' | awk '$2 != "204"' | awk '$2 != "302"' | awk '$2 != "304"'
@jonathanhle
jonathanhle / gist:379c8e183f9f2ef71e4a
Created March 8, 2016 18:54
AWS CLI Get SG Names in a List
aws ec2 describe-security-groups --query 'SecurityGroups[*].{Name:GroupName}' --output text
@jonathanhle
jonathanhle / gist:741e7c0c86cfa51fb81cef9970a6ddd9
Created March 31, 2016 18:04
Sometimes you have to use the ansible raw module, sigh.
SG=JenkinsSG && ansible security_group_${SG} -m raw --args='export TempCurrentAnsibleRole=$(source /etc/default/ec2-metadata && source /etc/default/manage-authorized-keys && aws ec2 describe-tags --filter "Name=key,Values=AnsibleRole" "Name=resource-id,Values=$EC2_INSTANCE_ID" --output text) && export CurrentAnsibleRole=$(echo ${TempCurrentAnsibleRole} | cut -d " " -f 5-) && echo $CurrentAnsibleRole && CurrentServerRole=$(cat /etc/default/server-role | cut -c 20-) && echo $CurrentServerRole && if [ "${CurrentAnsibleRole}" == "${CurrentServerRole}" ]; then echo "AnsibleRole and ServerRole Match"; else echo "No Match" && exit 1; fi'
@jonathanhle
jonathanhle / gist:d1ebbb816c3b261c7d3aaad929b3b4bc
Created April 29, 2016 21:22
Use ansible to get the current AWS CLI versions across your systems, using the SG inventory groupings
#get the AWS cli version from the servers in Ansible in an SG
SG=securityGroupNameofSomeSort && ansible security_group_${SG} -m shell -a 'currentAwsCliVersion=$(aws --version 2>&1 | cut -c 9-) && INSTANCE_ID=$(wget -qO- http://instance-data/latest/meta-data/instance-id) && echo $currentAwsCliVersion $INSTANCE_ID' | grep -v SUCCESS >> /tmp/jonathan_current_ver_aws_cli.txt
#get just the first and last columns, to loop through.
cat /tmp/jonathan_current_ver_aws_cli.txt | awk '{print $1 " " $NF}' >> tmp.txt && mv tmp.txt /tmp/jonathan_current_ver_aws_cli.txt
#loop though things and get the <<CLI_VERSION>> <<AWS Instance ID>> <<AWS Name tag>>
IFS='
'
for i in $( cat /tmp/jonathan_current_ver_aws_cli.txt )
@jonathanhle
jonathanhle / gist:9cbdfdf575e62e56f5abfe8353d030d5
Created May 24, 2016 21:17
Ansible Exclude Pattern with ec2.py inventory
ansible 'security_group_sshonly:!tag_aws_autoscaling_groupName_gumgum' -m shell -a 'uptime' --list-hosts
@jonathanhle
jonathanhle / gist:7f324fef26b758f7ea100256793eeaa9
Created November 4, 2016 04:29
Pritunl Ubuntu 14.04 Client Install
#!/usr/bin/env bash
echo "deb http://repo.pritunl.com/stable/apt trusty main" > /etc/apt/sources.list.d/pritunl.list
apt-key adv --keyserver hkp://keyserver.ubuntu.com --recv 7568D9BB55FF9E5287D586017AE645C0CF8E292A
apt-get update -y
apt-get install pritunl-client-gtk -y
@jonathanhle
jonathanhle / AWS.js
Created December 10, 2016 00:05 — forked from zircote/AWS.js
Google Script for Excel and AWS instance pricing + Reserved Instances
/**=
* User: zircote
* Date: 16/10/2013
* Time: 08:59
*/
var SERVICE_HOST = 'http://aws.amazon.com'
var data_sources = {
"linux-od": {

📂 repo_root/

📄 Jenkinsfile (has no file extension, references tasks in xx_BUILD_STEP folders below)

📂 01_BUILD/
    📄  _build.sh
        Dockerfile.build
    (optional - add more files for BUILD stage here)

📂 02_UNIT_TESTS/