Skip to content

Instantly share code, notes, and snippets.

External facts

External facts provide a way to use arbitrary powershell scripts as facts, or set facts statically with data structured as INIFILE, JSON or YAML. If you’ve ever wanted to write a custom fact in Powershell, this is how.

Facts location

To add external facts to your Puppet modules, just place them in MODULEPATH/MODULENAME/facts.d/. at the same level as you would place manifests, files or templates directories.

They will be automatically distributed with pluginsync during the puppet run.

@msutter
msutter / gist:e580a1b48a8551128217225fe4a8568b
Created January 8, 2018 14:59 — forked from akomakom/jenkins-groovy-system-script.groovy
A jenkins script to clean up workspaces on slaves. On all slaves with less than X free GB, this script removes /slaves/workspace/* if slave is idle. If not idle, it removes /full/job/workspace/path for each job that isn't currently running.
/**
Jenkins System Groovy script to clean up workspaces on all slaves.
Check if a slave has < X GB of free space, perform cleanup if it's less.
If slave is idle, wipe out everything in the workspace directory as well any extra configured directories.
If slave is busy, wipe out individual job workspace directories for jobs that aren't running.
Either way, remove custom workspaces also if they aren't in use.
**/
import hudson.model.*;
@msutter
msutter / cleanupUnusedWorkspaceInSlaves.groovy
Created January 8, 2018 15:41 — forked from ceilfors/cleanupUnusedWorkspaceInSlaves.groovy
When you delete jobs in Jenkins, the corresponding workspaces in the build slaves won't be deleted automatically. This Jenkins script will go to each slave and check if the jobs are already deleted in Jenkins master and delete the workspace.
import com.cloudbees.hudson.plugins.folder.Folder
import hudson.FilePath
import jenkins.model.Jenkins
def boolean isFolder(String name) {
def item = Jenkins.instance.getItemByFullName(name)
return item instanceof Folder
}
def deleteUnusedWorkspace(FilePath root, String path) {

File Manipulation Approaches

Full configurations

Static content

  • Software/script => have you considered packaging it?
  • binary/large data file => add metadata (git + vcsrepo type, maybe even git-annex or git-lfs?)
  • Puppet >= 3.7:
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
[System.Net.ServicePointManager]::SecurityProtocol = [System.Net.SecurityProtocolType]::Tls12;
@msutter
msutter / GNUPG_agent_forwarding.md
Last active February 27, 2020 10:26 — forked from TimJDFletcher/GNUPG_agent_forwarding.md
GnuPG agent forwarding

Forward GnuPG agent from macOS to Linux

On the remote machine

Run gpg once as your to create the directory structure

gpg --list-keys

For remote systemd based hosts

@msutter
msutter / gist:d376e79a6d899aafe30dff95ec97c0ac
Last active January 2, 2023 09:22
Macbook pro 2017 OSX version 13.1 Bluetooth Audio Stutter fix
# This are the command line commands to change the bluetooth settings in case of audio stuttering
# Changes are based on the nice video made by Simon McCabe on youtube where he is using the bluetooth explorer app
# https://www.youtube.com/watch?v=OVRbLRRz5TU
# The settings are reversible but proceed at your own risk.
#
# My defaults are
# sudo defaults read com.apple.BluetoothAudioAgent
# {
# "Apple Bitpool Max (editable)" = 64;
# "Apple Bitpool Min (editable)" = 50;