Skip to content

Instantly share code, notes, and snippets.

View jkordish's full-sized avatar

Joseph Kordish jkordish

  • Trellix
  • San Antonio
  • 14:05 (UTC -05:00)
View GitHub Profile

[Verifying my cryptographic key:openpgp4fpr:F6702B8967ACA8FCC9A1EDCBE64F44FCA8569544]

@jkordish
jkordish / cloud-init.sh
Last active January 16, 2019 10:55
consul cluster --- cloud-init.sh agent discovery
# not really needed anymore as consul supports the ability to filter our ec2 instances now
#create initial consul server config sans server IPs
cat<<EOF > /tmp/consul_config.json
{
"datacenter": "${dc}",
"retry_join": [
]
}
EOF
@jkordish
jkordish / hosts.ctmpl
Last active June 13, 2017 20:17
consul-template for generating /etc/hosts from service catalog
# consul-template generated
127.0.0.1 localhost {{with node}}{{.Node.Node}}{{end}}
{{with node}}{{.Node.Address}} {{.Node.Node}}{{end}}
::1 localhost
# hosts by service
{{range services}}}# {{.Name}}{{$Name :=.Name}}{{range $index, $service := service .Name "any" }}
{{.Address}} {{.Node}} {{$Name}}0{{$index | add 1}}
{{end}}{{end}}
@jkordish
jkordish / filter ec2 instances
Created May 9, 2016 16:55
filter ec2 instances
aws ec2 describe-instances --filter "Name=tag:Name,Values=blah*" --output text --query "Reservations[].Instances[].Tags[?Key=='Name'].Value"
@jkordish
jkordish / haproxy-ha.conf
Last active February 23, 2016 04:19
Make shift HAproxy HA Monitor Upstart for Ubuntu 12.04 and 14.04
# haproxy HA monitor
description "monitor the haproxy EIP for HA"
start on runlevel [2345]
stop on runlevel [!2345]
console log
limit nofile 65535 65535
respawn
@jkordish
jkordish / creds
Last active February 22, 2017 14:20
Shellscript to provide all the required AWS Credentials for instances. Handy for sourcing into scripts.
#!/bin/bash -e
# /etc/profile.d/creds.sh
iam_role=$(/usr/bin/curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/)
export AWS_ACCOUNT_ID=$(/usr/bin/curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | /usr/bin/jq -r .accountId)
export AWS_DEFAULT_REGION=$(/usr/bin/curl -s http://169.254.169.254/latest/dynamic/instance-identity/document | /usr/bin/jq -r .region)
export AWS_ACCESS_KEY_ID=$(/usr/bin/curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/$iam_role | /usr/bin/jq -r .AccessKeyId)
export AWS_SECRET_ACCESS_KEY=$(/usr/bin/curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/$iam_role | /usr/bin/jq -r .SecretAccessKey)
export AWS_SECURITY_TOKEN=$(/usr/bin/curl -s http://169.254.169.254/latest/meta-data/iam/security-credentials/$iam_role | /usr/bin/jq -r .Token)
export AWS_SESSION_TOKEN=$AWS_SECURITY_TOKEN
@jkordish
jkordish / gist:eb1df72433feb209eb3a
Last active April 4, 2016 17:32
Add resource to bucket policy
# Add an ARN to existing statement
policy=$(aws s3api get-bucket-policy --bucket <bucket> --query Policy --output text | jq '.Statement[0].Principal.AWS |= [.][]+ ["<resource arn>"]')
# push changes
aws s3api put-bucket-policy --bucket <bucket> --policy "${policy}"
###
# Merge statement lists from remote to your local (policy.json)
policy=$(aws s3api get-bucket-policy --bucket <bucket> --query Policy --output text | jq ".Statement |= .+ $(jq .Statement policy.json)")
hostA$ tar c mydir | lzop | socat - tcp-listen:1234
hostB$ socat tcp:hostA:1234 | lzop -d | tar x
@jkordish
jkordish / multirust_ansible_install.yaml
Created November 30, 2015 00:20
quick ansiblized multirust install
- name: get multirust
get_url:
url: https://raw.githubusercontent.com/brson/multirust/master/blastoff.sh
dest: /tmp/blastoff.sh
mode: 0755
- name: install multirust
become: yes
become_user: "{{lookup('env', 'USER')}}"
become_method: sudo
@jkordish
jkordish / random.awk.txt
Last active December 15, 2015 22:20
random awk so i don't forget
pre-start script
set -e
MEM=$(awk '/^MemFree/ {free=$2 * 1024 - 1610612736}; END \
{ if ( free > 4294967296 ) print 4294967296; \
else if ( free < 134217728 ) print 134217728; \
else print free }' /proc/meminfo)
CPU=$(awk '/^processor/ { n++ }; END { if ( n > 2) print n-2; else print n+0}' /proc/cpuinfo)
sed -i "s/^chunkMemQueueBytes.*/chunkMemQueueBytes\ =\ $MEM/" /opt/tap-cbs/config.txt
sed -i "s/^nDigesters.*/nDigesters\ =\ $CPU/" /opt/tap-cbs/config.txt