Skip to content

Instantly share code, notes, and snippets.

View raphink's full-sized avatar
🐝
eBPF everything!

Raphaël Pinson raphink

🐝
eBPF everything!
View GitHub Profile
@raphink
raphink / test-save
Created January 18, 2012 11:36
test-save
r = aug_match(aug, "/augeas/files/etc/yum.repos.d/new.repo/path", NULL);
CuAssertIntEquals(tc, 0, r);
r = aug_set(aug, "/files/etc/yum.repos.d/new.repo/newrepo/baseurl",
"http://foo.com/");
CuAssertIntEquals(tc, 0, r);
r = aug_save(aug);
CuAssertIntEquals(tc, 0, r);
@raphink
raphink / gist:2488967
Created April 25, 2012 11:04
onlyif not honored in Exec
exec {'Avoid multiple mcollectived':
path => '/usr/bin:/usr/sbin:/bin',
command => 'pkill -f mcollectived',
onlyif => 'test `pgrep -f mcollectived | wc -l` -gt 1',
notify => Service['mcollective'],
}
@raphink
raphink / mco
Created April 26, 2012 06:39
Simple bash completion for mcollective
_mco()
{
local cur cmd agents
COMPREPLY=()
cur=${COMP_WORDS[COMP_CWORD]}
prev=${COMP_WORDS[COMP_CWORD-1]}
cmd=${COMP_WORDS[0]}
if [ $COMP_CWORD -eq 1 ]; then
@raphink
raphink / gist:2503538
Created April 26, 2012 22:01
Bulk finding bugs in Augeas lenses
$ mco augeas match /augeas//error -t 10 | grep '/augeas' | sort | uniq -c | sort -nr
32 /augeas/files/etc/nagios3/resource.cfg/error = parse_failed
31 /augeas/files/etc/nagios3/commands.cfg/error = parse_failed
26 /augeas/files/etc/modprobe.d/aliases.conf/error = parse_failed
22 /augeas/files/etc/default/dhcpcd/error = parse_failed
16 /augeas/files/etc/nagios3/cgi.cfg/error = parse_failed
6 /augeas/files/etc/apt/preferences/error = parse_failed
5 /augeas/files/etc/apt/apt.conf.d/01proxy/error = parse_failed
1 /augeas/files/etc/postgresql/9.0/main/pg_hba.conf/error = parse_failed
1 /augeas/files/etc/default/varnish/error = parse_failed
@raphink
raphink / healthcheck-mco.sh
Created May 4, 2012 05:22
Healthcheck script for mcollective
#!/bin/bash
NODESDIR="${1:-${HOME}/puppetmaster/manifests/nodes}"
ret=0
mcofqdn=$(mco facts fqdn | sed -n 's@found@ found@p') # circumvent bug in mco
morethanonce=$(grep ' [0-9]*[^1] times' <<<"$mcofqdn")
[[ -n $morethanonce ]] \
@raphink
raphink / healthcheck.rb
Created May 4, 2012 10:54
Healthcheck application for mcollective
class MCollective::Application::Healthcheck<MCollective::Application
description "Compare nodes in puppet and mcollective"
usage "Usage: healthcheck [OPTIONS]"
option :nodesdir,
:description => "The directory where .pp node files are stored",
:arguments => ["--nodesdir <NODESDIR>"]
@raphink
raphink / public_ip.rb
Created May 7, 2012 10:45
Public IP fact
Facter.add("public_ip") do
setcode do
Facter::Util::Resolution.exec('/usr/bin/curl -s http://ifconfig.me/ip')
end
end
class foo::config {
resource {'baz':
param => somevalue
}
}
class foo::master {
include foo::config
}
@raphink
raphink / chambery.json
Created May 25, 2012 10:23
Chambery in nominatim
[
{
"icon" : "http://nominatim.openstreetmap.org/images/mapicons/poi_boundary_administrative.p.20.png",
"boundingbox" : [
"45.3524627685547",
"45.9385185241699",
"5.62203693389893",
"6.298264503479"
],
"licence" : "Data Copyright OpenStreetMap Contributors, Some Rights Reserved. CC-BY-SA 2.0.",
$ augcheck test.xml Xml
Test result: /tmp/augcheck.C6ia30/parse_file.aug:3.0-.47:
{ "str"
{ "#attribute"
{ "name" = "masterUrl" }
}
{ "#text" = "http://MY_SOLR_MASTER:8085/solr/files3/replication" }
}