Skip to content

Instantly share code, notes, and snippets.

View albatrossflavour's full-sized avatar

Tony Green albatrossflavour

View GitHub Profile
call plug#begin()
Plug 'elzr/vim-json' " For metadata.json
Plug 'mrk21/yaml-vim' " For hieradata
"Plug 'neoclide/coc.nvim', {'do': { -> coc#util#install()}} " Language Server support
Plug 'rodjek/vim-puppet' " For Puppet syntax highlighting
Plug 'vim-ruby/vim-ruby' " For Facts, Ruby functions, and custom providers
Plug 'vimwiki/vimwiki'
Plug 'airblade/vim-gitgutter'
Plug 'ryanoasis/vim-devicons'
@albatrossflavour
albatrossflavour / auto_patch.pp
Created October 12, 2020 03:28
Example Puppet plan to patch nodes
plan profile::auto_patch_run (
String $patch_group,
Boolean $security_only = false,
Enum['always', 'never', 'patched', 'smart'] $reboot = 'patched',
){
# Query PuppetDB to find nodes that have the patch group,
# are not blocked and have patches to apply
$all_nodes = puppetdb_query("inventory[certname] { facts.pe_patch.patch_group = '${patch_group}'}")
$filtered_nodes = puppetdb_query("inventory[certname] { facts.pe_patch.patch_group = '${patch_group}' and facts.pe_patch.blocked = false and facts.pe_patch.package_update_count > 0}")
require "json"
Facter.add('vra') do
setcode do
data = {}
if Facter.value(:kernel) == 'windows'
json_file = 'C:\ProgramData\PuppetLabs\facter\facts.d\puppet_vra_facts.json'
else
@albatrossflavour
albatrossflavour / common.yaml
Last active November 29, 2019 01:00
VERY rough nagios profile that doesn't require a nagios module
---
profile::soe::monitoring::nagios::rules:
nagios_command:
process-service-perfdata:
ensure: present
command_line: '/usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /var/log/nagios/service-perfdata.out'
target: '/etc/nagios/objects/nagios_command.cfg'
profile::soe::monitoring::nagios::plugins:
- nagios-plugins-pgsql
- nagios-plugins-check-updates
@albatrossflavour
albatrossflavour / mco.md
Created July 13, 2017 21:52
moo cheat sheet

mco puppet runonce --batch 5 --batch-sleep 30 --nodes ./nodelist.txt

Keybase proof

I hereby claim:

  • I am albatrossflavour on github.
  • I am greeno (https://keybase.io/greeno) on keybase.
  • I have a public key whose fingerprint is 662B 5F77 3441 7754 E9AB 0F35 2033 7997 7D27 189A

To claim this, I am signing this object:

#!/bin/sh
human_readable()
{
awk -v sum="$1" ' BEGIN {hum[1024^3]="Gb"; hum[1024^2]="Mb"; hum[1024]="Kb"; for (x=1024^3; x>=1024; x/=1024) { if (sum>=x) { printf "%.2f %s\n",sum/x,hum[x]; break; } } if (sum<1024) print "1kb"; } '
}
human_readable $1