Skip to content

Instantly share code, notes, and snippets.

View freedomfury's full-sized avatar

afigs freedomfury

View GitHub Profile
=====./__init__.py====
import os
import sys
import importlib
from invoke import Collection
ns = Collection()
mod_list = []
path = os.path.dirname(os.path.realpath(__file__))
bin = f"{os.path.dirname(path)}/bin"
Makefile
BASH:=$(shell which bash)
SHELL:=$(BASH)
MAKEFLAGS+= --warn-undefined-variables
MAKEFLAGS+= --no-builtin-rules
PWD:=$(shell pwd)
DOTENV:=$(PWD)/.env
.SHELLFLAGS:= -O inherit_errexit -eu -o pipefail -c
#!/bin/bash
set -e
CERTDIR="./certs"
mkdir -p "$CERTDIR/ca" "$CERTDIR/server" "$CERTDIR/client"
# Generate CA key and certificate
openssl genrsa -out "$CERTDIR/ca/key.pem" 4096
openssl req -new -x509 -days 825 -key "$CERTDIR/ca/key.pem" -out "$CERTDIR/ca/cert.pem" -subj "/CN=Custom Docker CA"
@freedomfury
freedomfury / docker-entrypoint.sh
Created July 28, 2025 08:58
docker-entrypoint.sh
#!/bin/sh
set -eu
_tls_ensure_private() {
local f="$1"; shift
[ -s "$f" ] || openssl genrsa -out "$f" 4096
}
_tls_san() {
{
ip -oneline address | awk '{ gsub(/\/.+$/, "", $4); print "IP:" $4 }'
---
stages:
- setup
- build
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
PY_VENV_DIR: "$CI_PROJECT_DIR/.venv"
cache:
@freedomfury
freedomfury / molecule.yml
Created February 3, 2023 14:04
molecule podman systemd
---
dependency:
name: galaxy
driver:
name: podman
platforms:
- name: c01-alma8
image: almalinux/8-init
pre_build_image: true
{
"name": "updateOSSoftware",
"action": "aws:runCommand",
"maxAttempts": 3,
"timeoutSeconds": 3600,
# Example molecule-vagrant configuration
---
dependency:
name: galaxy
driver:
name: vagrant
provider:
name: virtualbox
platforms:
- name: instance

Puppet Node Purging via API

When you're decomissioning a machine that has been managed by Puppet you may want to programatically clean up the node. There are two parts to this:

  • revoking and deleting the certificate of the node in Puppet's CA
  • deactivating the node in PuppetDB

The following should work for Puppet 4.x and Puppet DB 4.x (including Puppet Enterprise 2016.4.x, 2017.1.x, 2017.2.x).

I've used certificate based auth, and the examples are being run from the puppet master so make use of existing certificates for authentication. When run remotely the cacert, certificate and corresponding private key for authentication will need to be present.