Skip to content

Instantly share code, notes, and snippets.

View h0tw1r3's full-sized avatar
🏝️
Living the dream

Jeffrey Clark h0tw1r3

🏝️
Living the dream
View GitHub Profile
@h0tw1r3
h0tw1r3 / genkey.sh
Last active September 17, 2024 15:43
Generate GPG key for signing packages, export keys and generate public keyring
#!/bin/sh
set -eo nounset
export GNUPGHOME="$(mktemp -d)"
trap 'cleanup' EXIT
cleanup() { rm -Rf "$GNUPGHOME" ; }
export NAME_REAL="Signing Key"
@h0tw1r3
h0tw1r3 / disable_verification.py
Created September 6, 2024 00:13
python globally disable requests ssl verification
import requests
def disable_request_verification():
requests.urllib3.disable_warnings()
old_init = requests.Session.__init__
def new_init(self, *k, **kw):
old_init(self, *k, **kw)
self.verify = False
@h0tw1r3
h0tw1r3 / asyncsubprocess.py
Created September 3, 2024 04:38
python async subprocess example module with stdout and stderr support
#!/usr/bin/env python3
import collections
import asyncio
import sys
class AsyncSubProcess:
def __init__(self, program, *args, env={}, output=True, cwd=None):
self.proc = None
@h0tw1r3
h0tw1r3 / Dockerfile
Last active August 31, 2024 04:05
base alpine dockerfile with fips support
# syntax=docker/dockerfile:1.6
ARG BUILD_OS_TAG
FROM alpine:${BUILD_OS_TAG} as build
ARG BUILD_OS_TAG
RUN apk add --no-cache alpine-sdk doas \
&& echo 'permit nopass :wheel' >> /etc/doas.conf
RUN adduser -D build \
ifeq (${MAKELEVEL},0)
export SCRATCH := $(shell mktemp -d ./.tmp_XXXXXXXX)
$(info Launching clean up task for ${SCRATCH})
$(shell bash -c "set -m ; trap 'rm -rvf ${SCRATCH};' EXIT; lsof -p $$PPID +r 1;" </dev/null >/dev/null 2>/dev/null & disown)
endif
@h0tw1r3
h0tw1r3 / spec_described.rb
Last active February 4, 2024 16:27
Rake task for puppet modules to ensure spec describes cover the code
require 'rspec/core'
namespace :check do
desc "Check to ensure defined puppet code has been described in spec\n(defaults: coverage=100)"
task :spec_described, [:coverage] do |_task, args|
args.with_defaults(coverage: '100')
def pluralize(string)
string.end_with?('s') ? "#{string}es" : "#{string}s"
end
@h0tw1r3
h0tw1r3 / logback.pp
Created February 1, 2024 20:00
send puppetserver logs to syslog
augeas { 'puppetserver-logback-journal':
incl => '/etc/puppetlabs/puppetserver/logback.xml',
lens => 'Xml.lns',
changes => [
"defnode aref configuration/root/appender-ref[#attribute/ref='STDOUT'] ''",
"set \$aref/#attribute/ref 'STDOUT'",
]
}
@h0tw1r3
h0tw1r3 / ghostbuster.sh
Last active January 19, 2024 21:53
no requirements ghostbuster for puppet enterprise control-repo modules
#!/bin/bash
#####> BEGIN: script init
set -o pipefail -o errtrace -o errexit -o nounset -o functrace
__traperror() {
local el=${1:=??} ec=${2:=??} lc="$BASH_COMMAND"
printf "ERROR in %s : line %d error %d\\n [%s]\\n" "$0" "$el" "$ec" "$lc" 1>&2
exit "${2:=1}"
}
@h0tw1r3
h0tw1r3 / Gemfile
Created January 18, 2024 19:38
Puppet Testing Gemfile
source ENV['GEM_SOURCE'] || 'https://rubygems.org'
def location_for(place_or_version, fake_version = nil)
git_url_regex = %r{\A(?<url>(https?|git)[:@][^#]*)(#(?<branch>.*))?}
file_url_regex = %r{\Afile:\/\/(?<path>.*)}
if place_or_version && (git_url = place_or_version.match(git_url_regex))
[fake_version, { git: git_url[:url], branch: git_url[:branch], require: false }].compact
elsif place_or_version && (file_url = place_or_version.match(file_url_regex))
['>= 0', { path: File.expand_path(file_url[:path]), require: false }]
@h0tw1r3
h0tw1r3 / fakeprovide.pp
Created January 10, 2024 16:39
fakeprovide rpm resource type for puppet
# fake provide rpm dependencies
#
# requires stdlib module
#
# @param provide
# what to provide
# @param extras
# extra provides to add to package
#
# @example