Skip to content

Instantly share code, notes, and snippets.

View mrajani's full-sized avatar

Mahesh Rajani mrajani

  • San Francisco Bay Area
  • 07:32 (UTC -07:00)
View GitHub Profile
@mrajani
mrajani / hc-vault.sh
Last active September 27, 2020 19:45
Setting up HC Vault
#!/bin/bash
# Fill in bash commands
# https://github.com/sethvargo/vault-secrets-gen
sudo systemctl start vault.service
sudo -u vault vault operator init \
-address=https://localhost:8200 \
-key-shares=5 \
-key-threshold=3 \
#!/bin/bash
git clone https://github.com/magicmonty/bash-git-prompt.git ~/.bash-git-prompt --depth=1
cat <<EOF >> ~/.bashrc
if [ -f "$HOME/.bash-git-prompt/gitprompt.sh" ]; then
GIT_PROMPT_ONLY_IN_REPO=1
source $HOME/.bash-git-prompt/gitprompt.sh
fi
EOF
#!/bin/bash
wget https://raw.githubusercontent.com/git/git/master/contrib/completion/git-prompt.sh -O ~/.git-prompt.sh
source ~/.git-prompt.sh
GIT_PS1_SHOWDIRTYSTATE=1
GIT_PS1_SHOWUNTRACKEDFILES=1
GIT_PS1_SHOWUPSTREAM="auto"
PS1='${debian_chroot:+($debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]$(__git_ps1 " (%s)") \$'
#!/bin/bash
# https://github.com/99designs/aws-vault/issues/356
profile=sandbox
aws-vault add --backend=file --add-config ${profile}
aws-vault exec --server --assume-role-ttl=1h --session-ttl=12h ${profile} -- bash
$User = "00000000-0000-0000-0000-000000000000"
$Password = ConvertTo-SecureString "00000000-0000-0000-0000-000000000000" -AsPlainText -Force
$Credential = New-Object -TypeName System.Management.Automation.PSCredential -ArgumentList $User, $Password
Connect-AzAccount -ServicePrincipal -Credential $Credential -Tenant "00000000-0000-0000-0000-000000000000"
## Need to sort this
New-AzAutomationCredential -AutomationAccountName "TF-Azure-Account" `
-Name "TF-Azure-Credential" -Value $Credential `
-ResourceGroupName "TF-Azure-Group"
#!/bin/bash
az ad sp create-for-rbac --role="Contributor" --scopes="/subscriptions/${SUBSCRIPTION_ID}"
az login --service-principal -u $TF_VAR_client_id -p $TF_VAR_client_secret -t $TF_VAR_tenant_id
az login --service-principal -u $ARM_CLIENT_ID -p $ARM_CLIENT_SECRET -t $ARM_TENANT_ID
az account list-locations -o table
az account show --query "{subscriptionId:id, tenantId:tenantId}"
@mrajani
mrajani / myip.tf
Created July 28, 2020 05:18
Use http provider and jsondecode
data "http" "my_ip" {
url = "http://ifconfig.me"
}
data "http" "tfver" {
url = "https://checkpoint-api.hashicorp.com/v1/check/terraform"
}
output "my_ip" {
@mrajani
mrajani / app.tf
Created July 25, 2020 00:53 — forked from joatmon08/app.tf
Terraform Example for Azure App Gateway & App Service
locals {
app_services = [
{
kind = "Linux"
sku = {
tier = "Standard"
size = "S1"
}
},
{
@mrajani
mrajani / pedantically_commented_playbook.yml
Created October 2, 2019 15:46 — forked from phred/pedantically_commented_playbook.yml
Insanely complete Ansible playbook, showing off all the options
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.
@mrajani
mrajani / find_docker_versions.sh
Last active October 1, 2019 20:11
find various versions of docker in distro
yum list -q docker-ce --showduplicates| tail -n +2| awk '{print $2}'| sort -nr| head -1
yum list -q docker-ce --showduplicates| sort -r| awk '{print $2}'| grep 18| head -1| sed -e 's/.*:\(.*\)-.*/\1/g'