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 | |
# This script uses traps to create try/catch/finally functionality in shell scripts. | |
# | |
# OUTPUT: | |
# | |
# Hello! We're reporting live from script | |
# ./try_catch2.sh: line 23: badcommand: command not found | |
# ./try_catch2.sh: line 23: exiting with status 127 | |
# It's the end of the line |
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 | |
# Errors are thrown if Terraform is given the name of an existing security group. | |
# One solution is to find the existing security group and delete it. (That will fail if any instances are associated.) | |
# This installs jq, finds security group id, deletes security group. | |
# | |
security_group_name=your_sg | |
# 1. Install jq | |
curl -L "https://github.com/stedolan/jq/releases/download/jq-1.5/jq-linux64" -o jq.dms && chmod +x jq.dms |
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 | |
org=$1 | |
name=${2:-$USER} | |
echo "Usage: $0 [organization] [name]" | |
create_date=$(date +'%Y%m%d') | |
if [ -n "${org}" ] ; then org="$org " ; fi |
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
$uuid = 'some-name-or-urn:8754258d-506d-e094-d51d-e0a0d891fe08' #16 octets, 10-15 are the node | |
$node = $(echo $uuid | cut -d':' -f 2 | cut -d'-' -f 5) | |
echo $node |
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 | |
# Many things want UTC time as input, so here it is. As 14 days ago. Like for a query to AWS spot instance history: | |
# aws ec2 describe-spot-price-history --instance-types t2.micro --start-time $(date -v-14d -u '+%FT%TZ') --product-description "Linux/UNIX" | |
# | |
# Output (of command below, not the aws cli command): | |
# 2018-02-13T15:24:46Z | |
# | |
date -v-14d -u '+%FT%TZ' |
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 locals (in a .tf file) | |
locals { | |
name_prefix = "terrafirm" | |
full_build_id = format("notcb:%s", uuid()) #128-bit rfc 4122 v4 UUID | |
build_id = "${substr(element(split(":",local.full_build_id),1), 0, 8)}${substr(element(split(":",local.full_build_id),1), 9, 4)}" | |
resource_name = "${local.name_prefix}-${local.build_id}" | |
} | |
# terraform template declaration (in a .tf file) | |
data "template_file" "lx_userdata" { |
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
pip install --index-url="https://pypi.org/simple" --upgrade virtualenv | |
sudo yum groupinstall -y development | |
sudo yum install -y zlib-dev openssl-devel sqlite-devel bzip2-devel | |
sudo yum install xz-libs | |
wget http://www.python.org/ftp/python/2.7.14/Python-2.7.14.tar.xz | |
xz -d Python-2.7.14.tar.xz | |
tar -xvf Python-2.7.14.tar |
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
# Hashicorp documentation is a bit out of date so it took a minute to figure this out... | |
# 1. Install go | |
https://golang.org/dl/ | |
# 2. Make a go workspace | |
$ mkdir ~/go # or wherever you want | |
$ export GOPATH=~/go # could add to .bash_profile | |
$ export PATH=$GOPATH:$PATH |
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
<powershell> | |
$Admin = [adsi]("WinNT://./Administrator, user") | |
$Admin.psbase.invoke("SetPassword", "<password>") | |
</powershell> |
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
2018-03-22T15:09:41.743Z [DEBUG] plugin.terraform: file-provisioner (internal) 2018/03/22 15:09:41 Uploading file to 'C:\scripts\check_build.ps1' | |
2018-03-22T15:09:42.378Z [DEBUG] plugin.terraform: remote-exec-provisioner (internal) 2018/03/22 15:09:42 connecting to remote shell using WinRM | |
2018-03-22T15:09:42.408Z [DEBUG] plugin.terraform: remote-exec-provisioner (internal) 2018/03/22 15:09:42 Uploading file to 'C:/Temp/terraform_1217694552.cmd' | |
2018-03-22T15:09:43.054Z [DEBUG] plugin.terraform: remote-exec-provisioner (internal) 2018/03/22 15:09:43 starting remote command: C:/Temp/terraform_1217694552.cmd | |
2018-03-22T15:10:52.390Z [DEBUG] plugin.terraform: remote-exec-provisioner (internal) 2018/03/22 15:10:52 Uploading file to 'C:/Temp/terraform_1217694552.cmd' | |
2018/03/22 15:10:53 [DEBUG] plugin: waiting for all plugin processes to complete... | |
2018-03-22T15:10:53.201Z [DEBUG] plugin.terraform: remote-exec-provisioner (internal) 2018/03/22 15:10:53 [ERR] plugin: plugin server: accept unix /tmp/plugin522209802 |