Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@MikaelSmith
MikaelSmith / restart_k8s.sh
Last active November 18, 2021 18:48
reset kubernetes IP address (with containerd, weave, openebs, minio)
#! /bin/bash
set -e
# PT_* are passed into the environment by Bolt.
# shellcheck disable=SC2154
KOTSADM_PASSWORD="${PT_kotsadm_password}"
# shellcheck disable=SC2154
if [ "${PT_force_ip_reset}" = 'true' ]; then
FORCE_IP_RESET=1
@MikaelSmith
MikaelSmith / Makefile
Last active January 30, 2021 06:42
make packaging with patterns
charts/%: charts/%/*
touch -r $@/$$(ls -Lt $@ | head -n1) $@
%-${ver}.tgz: charts/%
helm package $<
apiVersion: apps/v1
kind: StatefulSet
metadata:
labels:
app.kubernetes.io/name: cd4pe-postgres
name: postgres
namespace: cd4pe
spec:
replicas: 1
selector:
const Express = require('express');
const Session = require('express-session');
const BodyParser = require('body-parser');
const Keycloak = require('keycloak-connect');
const Cors = require('cors');
const hostname = '127.0.0.1';
const port = 3000;
var app = Express();
@MikaelSmith
MikaelSmith / github.rb
Last active March 25, 2020 18:36
Collect candidates for Puppet-owned gems published to rubygems.org
#!/usr/bin/env ruby
require 'octokit'
token = ENV['GITHUB_TOKEN']
if token.nil? || token.empty?
puts "GITHUB_TOKEN required for authentication"
exit 1
end
client = Octokit::Client.new(access_token: token)
@MikaelSmith
MikaelSmith / goodreads.rb
Last active June 11, 2019 23:56
Wash External Plugin Example
#!/usr/bin/env ruby
# A script for exploring your Goodreads library with Wash
#
# Requirements:
# - `gem install oauth nokogiri --user-install`
# Note that BitBar runs without shell setup, so it will likely use the system ruby.
# - A developer key/secret from https://www.goodreads.com/api/keys
# stored in GOODREADS_KEY, GOODREADS_SECRET environment variables.
require 'json'
@MikaelSmith
MikaelSmith / active.1m.sh
Last active July 12, 2019 22:31
Wash / BitBar Examples
#!/usr/bin/env wash
# Count all and all running EC2 instances
running=`find aws -action exec -meta .State.Name running 2>/dev/null | wc -l | xargs`
total=`find aws -action exec -meta .State.Name -exists 2>/dev/null | wc -l | xargs`
echo EC2 $running / $total
# Count S3 buckets
buckets=`find aws -maxdepth 4 -path '*/resources/s3/*' 2>/dev/null | wc -l | xargs`
echo S3 $buckets
mod 'puppetlabs-stdlib'
mod 'pltraining-dirtree'
mod 'puppetlabs-inifile'
mod 'puppet-archive'
mod 'puppetlabs-java_ks'
mod 'puppet-rundeck'
@MikaelSmith
MikaelSmith / swarm.pp
Last active November 12, 2018 18:57
Install and bootstrap Docker Swarm using Bolt + the Puppet Docker module
plan examples::swarm(TargetSpec $managers, TargetSpec $workers) {
$hosts = [$managers, $workers]
$hosts.apply_prep
apply($hosts) {
include 'docker'
}
# Initialize the swarm on a single manager.
$targets = get_targets($managers)
$master = $targets[0]
@MikaelSmith
MikaelSmith / transform.pp
Last active April 1, 2022 11:14
Transforming hash in Puppet
$data = [
{
"certname" => "server1",
"parameters" => {
"port" => 1234,
"job" => "job1"
}
},
{
"certname" => "server2",