Skip to content

Instantly share code, notes, and snippets.

@garthk
garthk / cleanupdates.cmd
Created October 22, 2012 05:20
Clean up stale Windows Update downloads
@echo on
setlocal
set DAYS=31
set DOWNLOADS=C:\WINDOWS\SoftwareDistribution\Download
rem http://bit.ly/IttCwo
rem http://stackoverflow.com/a/51069/5700
net stop wuauserv
forfiles /p %DOWNLOADS% /s /d -%DAYS% /c "cmd /c if @isdir==FALSE (del @file) else (rd /s /q @file)"
net start wuauserv
@garthk
garthk / fails-ask-for-resources-with-POST.out
Created October 9, 2012 23:22
Trying to get information out of puppetdb directly (puppetdb 0.9)
$ curl -vH "Accept: application/json" 'http://localhost:8080/resources' --data-urlencode 'query=["not", ["=", "type", "Nonsense"]]'
* About to connect() to localhost port 8080 (#0)
* Trying ::1... Connection refused
* Trying 127.0.0.1... connected
* Connected to localhost (127.0.0.1) port 8080 (#0)
> POST /resources HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-pc-linux-gnu) libcurl/7.19.7 OpenSSL/0.9.8k zlib/1.2.3.3 libidn/1.15
> Host: localhost:8080
> Accept: application/json
> Content-Length: 78
@garthk
garthk / fixpup
Created October 9, 2012 00:57 — forked from haus/gist:3851012
Script: pin Puppet to 2.7.* on Ubuntu
#!/bin/sh
# Pin Ubuntu to use Puppet 2.7.* rather than Puppet 3.
# Assumes you're using the Puppet APT repo at apt.puppetlabs.com.
# Thanks to haus for the technique.
cat > /etc/apt/preferences.d/00-puppet.pref <<EOF
Package: puppet puppet-common puppetmaster puppetmaster-common
Pin: version 2.7*
Pin-Priority: 501
EOF
echo Release pinned.
@garthk
garthk / puppetlabs.pp
Created September 15, 2012 03:51
Use Puppet to ensure Ubuntu can get the latest Puppet
class puppetlabs {
# Install Puppet repository and call apt-get update
case $operatingsystem {
ubuntu: {
$key = "4BD6EC30"
exec { 'apt-key puppetlabs':
path => "/bin:/usr/bin",
unless => "apt-key list | grep '${key}' | grep -v expired",
command => "apt-key adv --keyserver keyserver.ubuntu.com --recv-keys ${key}",
}
@garthk
garthk / nsclient-try2.ini
Created September 7, 2012 07:10
NSClient++ configuration information for review
# Added logging detail in attempt to debug problem, to no avail.
; A list of modules.
[/modules]
CheckDisk=1
CheckSystem=1
CheckTaskSched=1
NSClientServer=0
NRPEServer=1
@garthk
garthk / init.pp
Created September 7, 2012 00:09
Could not evaluate: undefined method `alias' for #<Nagios::Base::Hostextinfo:0x7fe2d61693b8>
class nagios {
$targets = '/etc/nagios3/puppets.d'
}
@garthk
garthk / bouncy-muxdemux-ouch.js
Created August 4, 2012 02:02
Using bouncy and mux-demux to make a proxy server
var http = require('http'),
net = require('net'),
bouncy = require('bouncy'),
MuxDemux = require('mux-demux');
var mux_server_port = 8192;
var trampoline_port = 8193;
var target_server_port = 8194;
var mux;
@garthk
garthk / node-yes-simplistic.js
Created August 2, 2012 04:38
Node.js does not detect process.stdout pipe closing
// this terminates: yes | head
// this hangs: node node-yes-simple.js | head
// per mhart, this is entirely expected
while(true) {
process.stdout.write('{"yes": "yes"}\n');
}
@garthk
garthk / package.pp
Created May 30, 2012 00:38
Puppet class to pull in a package. Ubuntu-friendly, but non-toxic to other UNIX.
class NAMESPACE::package (
$package = $NAMESPACE::package::params::package,
$repository = $NAMESPACE::package::params::repository,
$repokey = $NAMESPACE::package::params::repokey,
$reponame = $NAMESPACE::package::params::reponame,
$keyserver = $NAMESPACE::package::params::keyserver
) inherits NAMESPACE::package::params {
package { $package:
ensure => installed,
}
@garthk
garthk / init.pp
Created May 29, 2012 00:55
err: Could not retrieve catalog from remote server: Error 400 on SERVER: Could not find parent resource type 'mongodb::package::params' of type hostclass in production at /etc/puppet/modules/mongodb/manifests/package.pp:1 on node X
# /etc/puppet/modules/mongodb/manifests/init.pp
class mongodb {
}