Skip to content

Instantly share code, notes, and snippets.

Avatar

Adam Ward atward

  • Melbourne, Australia
View GitHub Profile
@atward
atward / gist:ca414f25627ceddc62de77532e8270f2
Created Jul 11, 2018
Jenkins scan config & generate stages
View gist:ca414f25627ceddc62de77532e8270f2
def jobs = ["JobA", "JobB", "JobC"]
def parallelStagesMap = jobs.collectEntries {
["${it}" : generateStage(it)]
}
def generateStage(job) {
return {
stage("stage: ${job}") {
View keybase.md

Keybase proof

I hereby claim:

  • I am atward on github.
  • I am atward (https://keybase.io/atward) on keybase.
  • I have a public key whose fingerprint is DCF7 1D93 BE2C E24D CC64 62AD 5795 E6B4 8B33 50F2

To claim this, I am signing this object:

View cloud-init_chef-zero.yaml
#cloud-init
# https://docs.chef.io/packages.html#enterprise-linux
# vendor chef-repo to /var/lib/chef with cookbooks in /var/lib/chef/cookbooks
yum_repos:
chef-stable:
name: chef-stable
baseurl: https://packages.chef.io/stable-yum/el/7/\$basearch/
enabled: true
failovermethod: priority
@atward
atward / github_get
Created Mar 5, 2019
Script to download asset file from tag release using GitHub API v3
View github_get
#!/usr/bin/env bash
# Script to download asset file from tag release using GitHub API v3.
# See: http://stackoverflow.com/a/35688093/55075
# Check dependencies.
set -e
type curl grep sed tr >&2
# Validate settings.
[ "$GITHUB_API_TOKEN" ] || { echo "Error: Please define GITHUB_API_TOKEN variable." >&2; exit 1; }
@atward
atward / safeget.py
Created May 1, 2019 — forked from WTFox/safeget.py
Perfect for handling nested dictionaries where values might not exist.
View safeget.py
def safeget(dct, *keys):
dct = dict(dct)
for key in keys:
try:
dct = dct[key]
except (KeyError, AttributeError, TypeError) as e:
return None
return dct
@atward
atward / fix_terragrunt_state.py
Created May 1, 2019
Attempts to fix inconsistencies with terragrunt local tfstate, s3 backend state and dynamodb lock state
View fix_terragrunt_state.py
#!/usr/bin/env python3
import os
import json
from pprint import pprint
import boto3
View .git-prompt-colors.sh
# theme based off https://github.com/magicmonty/bash-git-prompt/blob/a2182bb646987ebca978a655a5deb18bcc65dbe1/themes/Single_line_Solarized.bgptheme
define_helpers() {
:
}
# Get git relative path
function prompt_callback {
if [[ -e "$repo" ]]; then
GitBaseName="${repo##*/}"
@atward
atward / example-dev-memcache.tf
Created Mar 12, 2021
Example Terraform GCP org with Memcache in service project
View example-dev-memcache.tf
# add memcache (Memorystore) example to development
resource "google_memcache_instance" "cache_dev" {
provider = google-beta
project = google_project.development.project_id
name = "cache-dev"
region = var.region
authorized_network = google_service_networking_connection.private_service_connection.network
node_config {
cpu_count = 1
@atward
atward / example-gcp-lb-http2.tf
Last active Apr 1, 2021
Example Terraform GCP Global HTTP LB with HTTP/2 backend instance group
View example-gcp-lb-http2.tf
module "http_lb" {
source = "GoogleCloudPlatform/lb-http/google"
version = "~> 4.5"
project = var.project_id
name = "demo"
http_forward = false
ssl = true
private_key = tls_private_key.example.private_key_pem
@atward
atward / source_tfvars.sh
Last active Jul 13, 2021
Rudimentary parsing of terraform tfvars in bash
View source_tfvars.sh
#!/bin/bash
# source: https://gist.github.com/atward/7a2eb1b4a78fbaebe585
# here be dragons: this is as dangerous as it looks
## terraform variable defaults
# takes *.tf and assigns env=default (if any)
# - map not supported (obvious reasons)
# - Tested on Darwin sed(1) only
function source_tfdefaults() {
eval "$(