Skip to content

Instantly share code, notes, and snippets.

View provision_gcp
#!/usr/env/bash env
set -ex
# define our roles to be applied to our folders
declare -a folder_roles=(
"roles/resourcemanager.folderAdmin"
"roles/bigquery.admin"
"roles/cloudfunctions.admin"
"roles/cloudkms.admin"
"roles/cloudsql.admin"
View .envrc source
# PROD ORG
export TF_VAR_org_id=25xxxxxxxx
#-- BILLING INFO --
export TF_VAR_billing_account=01xxxxxxxx65FBF-xxxxx
#-- PROJECT_NAME --
export TF_ADMIN=us-gcp-xxxxxxxxxxxstg-1
#-- SERVICE_ACC_NAME --
View strap_gcp_metadata
#!/usr/bin/env bash
# -- debug
set -xe
if ! [ -x "$(command -v puppet)" ]; then
# -- write hostname correctly
hostname $(curl --silent "http://metadata.google.internal/computeMetadata/v1/instance/attributes/hostname" -H "Metadata-Flavor: Google")
# -- delcare configs
str=$'[main]\ndns=none'
View gist:8436479a2be586ed53873214cd78ab31
# copy pub keys to the remote hosts
for host in ubuntu1 centos1 dnsmasq1;
do
ssh-copy-id -i $HOME/.ssh/id_rsa.pub ${host}
done
View sample_vimrc
set nocompatible " be iMproved, required
filetype off " required
set exrc
set encoding=UTF-8
set rtp+=~/.vim/bundle/Vundle.vim
call vundle#begin()
" ==== plugin manager
View api_download
#!/usr/bin/env bash
set -e
source config
sleep 10
export PIVNET_TOKEN="$token"
export LOCAL_FILE_NAME=pcfdev-v0.30.0+PCF1.11.0-linux.zip
export DOWNLOAD_URL=https://network.pivotal.io/api/v2/products/pcfdev/releases/88478/product_files/125612/download
#export OPSMGR_HOST=localhost
export OPSMGR_USER="$useraccount"
export OPSMGR_PASSWORD="$password"
@simbalinux
simbalinux / install_vagrant
Last active Oct 29, 2018
Centos7 Vagrant && VirtualBox-5.2
View install_vagrant
#!/usr/bin/env bash
# enable debug mode
set -x
# 1. deploy new install of Centos 7 minimal
# 2. ensure that "secure boot" is disabled otherwise you get the following error: (see below)
#######
# vboxdrv.sh: failed: modprobe vboxdrv failed. Please use 'dmesg' to find out why.
# update & upgrade system
yum -y update && yum -y upgrade
View swapoff
#!/usr/bin/env bash
# turn off swap
swapoff -a
sed -i '/ swap / s/^/#/' /etc/fstab
# reboot
@simbalinux
simbalinux / jq_array
Last active Sep 23, 2018
parsing json using jq and bash arrays
View jq_array
#!/usr/bin/env bash
## use this to parse json and extract what you need and place in BASH as array with unique elements, if you need this to be a single "string" remove the \n in the print statement below.
echo '
{
"devDependencies": {
"babel-cli": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-plugin-lodash": "^3.3.4",
"eslint": "^5.4.0",
@simbalinux
simbalinux / check_keys
Last active Sep 23, 2018
Verify ssh keys exist || create new ones without password
View check_keys
#!/usr/bin/env bash
# check if ssh keys exist else create keys with no password automatically no prompting, ideal for shell scripts and automation
if [ -f $HOME/.ssh/id_rsa ]; then
echo rsa key installed
else
ssh-keygen -f /root/.ssh/id_rsa -t rsa -N ''
fi