Skip to content

Instantly share code, notes, and snippets.

View ogerbron's full-sized avatar
πŸš΄β€β™‚οΈ

Olivier Gerbron ogerbron

πŸš΄β€β™‚οΈ
View GitHub Profile
@ogerbron
ogerbron / ansible_shell_git_accept_host_key.yml
Created October 2, 2019 12:26
A quick example of how to use an alternative git command with ansible and automatically accept the git host key, by overriding the GIT_SSH_COMMAND
- name: Use the GIT_SSH_COMMAND environment variable to automatically accept the host key
shell: git archive [email protected]:my-repo.git master my-file
# Can be used for bitbucket.org for example
environment:
GIT_SSH_COMMAND: "ssh -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no"
@ogerbron
ogerbron / get_ansible_vault_in_terraform.sh
Last active November 16, 2020 09:43
Quick bash script to decrypt a vaulted ansible variable into terraform
#!/bin/bash
# Exit if any of the intermediate steps fail
set -e
function check_deps() {
if test ! "$(which jq)"
then
>&2 echo "Cannot find jq"
exit 1
@ogerbron
ogerbron / Terraform-generate-existing-IAM-policies.sh
Last active April 18, 2019 13:28
Get All IAM custom policies and auto generate the terraform configuration
for policy in $(aws iam list-policies --scope Local | jq -r .Policies[].PolicyName | sort)
do
policy_output=$(aws iam list-policies --scope Local | jq -r --arg NAME $policy '.Policies[] | select(.PolicyName == $NAME)')
policy_arn=$(echo $policy_output | jq -r .Arn)
policy_description=$(aws iam get-policy --policy-arn $policy_arn | jq -r '.Policy.Description // ""')
policy_version=$(echo $policy_output | jq -r .DefaultVersionId)
policy_path=$(echo $policy_output | jq -r .Path)
echo "resource \"aws_iam_policy\" \"$policy\" {"
echo " name = \"$policy\""
@ogerbron
ogerbron / rundeck_clean_activites.sh
Last active January 21, 2019 10:49
Clean up old rundeck activities
#!/bin/bash
# jq and rd command must be installed
#Β https://github.com/rundeck/rundeck-cli
usage() {
cat <<"EOF"
USAGE:
rundeck_clean_activites.sh [OPTIONS]
@ogerbron
ogerbron / update-terraform.sh
Created December 31, 2018 09:04
Terraform script updater
#!/bin/bash
# Default install path is /usr/local/bin
# Override with update-terraform.sh /override/path/
INSTALL_DIR="${1:-/usr/local/bin}"
URL="https://releases.hashicorp.com/terraform"
VER="$(curl -sL $URL | egrep -v 'beta|alpha' | grep -Po "_(\d*\.?){3}" | sed 's/_//' | sort -V | tail -1)"
ZIP="terraform_${VER}_linux_amd64.zip"