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 | |
#ASSUMES KeyPairs are stored in ~/.ssh | |
# Also make sure to install jq and have in your path to run below | |
# JQ: https://stedolan.github.io/jq/ | |
AWS_BIN="/usr/local/bin/aws" | |
AWS_PROFILE="omar-dev" | |
KP_DIR="~/.ssh" |
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
$script:ComputerName = [Environment]::getenvironmentvariable("COMPUTERNAME") | |
$script:BootTime = [Environment]::getenvironmentvariable("AWS_BootTime", "Machine") | |
$script:LaunchTime = [Environment]::getenvironmentvariable("AWS_LaunchTime", "Machine") | |
$script:DeployTime = [Environment]::getenvironmentvariable("AWS_DeployTime", "Machine") | |
$script:EnvName = [Environment]::getenvironmentvariable("AWS_EbEnvironmentName", "Machine") | |
$script:EbAppName = [Environment]::getenvironmentvariable("AWS_EbApplicationName", "Machine") | |
$script:CDN_STATUS = [Environment]::getenvironmentvariable("CDN_STATUS", "Machine") |
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 | |
# SUDOERS /etc/sudoers.d/lbbackup | |
# Cmnd_Alias LS_HARDWARE = /usr/bin/lshw | |
# Cmnd_Alias MOUNT_UDF = /bin/mount -oloop\,rw * | |
# Cmnd_Alias UNMOUNT_UDF = /bin/umount /data/TEMP_UDF_DIR/MOUNT_UDF | |
# Cmnd_Alias BURN_UDF = /usr/bin/growisofs | |
# Cmnd_Alias CHOWN_MOUNT = /bin/chown -R lbbackup\:lbbackup /data/TEMP_UDF_DIR/MOUNT_UDF | |
# lbbackup ALL=(ALL) NOPASSWD: LS_HARDWARE, MOUNT_UDF, UNMOUNT_UDF, BURN_UDF, CHOWN_MOUNT |
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
; pardon syntax - clojure newb | |
; Custom subject | |
(def email | |
(mailer | |
{ | |
:from "[email protected]" | |
:host "localhost" | |
:subject (fn [events] (apply str "RIEMANN DETECTION: " (get-in (first events) [:host]) " TRIGGERED [" (get-in (first events) [:service]) " STATE]: " (get-in (first events) [:state]))) | |
} |
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
unbuffer tail -f /var/log/log.log | egrep --line-buffered "DEPLOY_SUMMARY" | xargs -I {} /usr/bin/curl -XPOST -H "content-type:application/json" -d '{"content":"{}","external_user_name": "Deploy"}' https://api.flowdock.com/v1/messages/chat/xxxxx |
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
# ON SERVER: | |
1. install chef-server | |
2. intialize new chef instance `sudo chef-server-ctl reconfigure` |
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
# REMEMBER TO USE VISUDO - you can potentially lock yourself out if sudoers file has parse error | |
# change visudo editor to VIM | |
Defaults editor=/usr/bin/vim | |
# example of /etc/sudoers.d/lbbackup | |
Cmnd_Alias LS_HARDWARE = /usr/bin/lshw | |
Cmnd_Alias MOUNT_UDF = /bin/mount -oloop\,rw * | |
Cmnd_Alias UNMOUNT_UDF = /bin/umount /data/TEMP_UDF_DIR/MOUNT_UDF |
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
select key/value | |
aws --profile xxx --output json ec2 describe-instances --instance-ids i-xxxxxx | jq -r '.Reservations[].Instances[].Tags[] | select(.Key | contains("computername")) | .Value' |
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
# email using aws ses | |
function send-email () | |
{ | |
email_message="/tmp/email_message" | |
email_cleanup="/tmp/email_cleanup" | |
email_destination="/tmp/email_destination" | |
# we need to clean up our logs so we can send via json; remove new line and quotes | |
# and I don't understand the bash issue with running cat | sed in the $email_message declaration. Fun TODO to understand why? | |
cat $LOG_FILE | sed ':a;N;$!ba;s/\n/\\n/g' | tr -d '"' > $email_cleanup |
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
sed ':a;N;$!ba;s/\n/\\n/g' |