Skip to content

Instantly share code, notes, and snippets.

@domcleal
domcleal / access.aug
Created April 8, 2011 22:54
access.aug with @usergroup@@HoStGroup support
(*
Module: Access
Parses /etc/security/access.conf
Author: Lorenzo Dalrio <lorenzo.dalrio@gmail.com>
About: Reference
Some examples of valid entries can be found in access.conf or "man access.conf"
About: License
@domcleal
domcleal / augeas_spec_stub.patch
Created May 18, 2011 21:48
Stubbing in augeas spec
diff --git a/spec/unit/provider/augeas/augeas_spec.rb b/spec/unit/provider/augeas/augeas_spec.rb
index 693e33e..b8aade2 100755
--- a/spec/unit/provider/augeas/augeas_spec.rb
+++ b/spec/unit/provider/augeas/augeas_spec.rb
@@ -373,8 +373,7 @@ describe provider_class do
augeas_stub = stub("augeas")
augeas_stub.expects("set").with("/augeas/save", "newfile")
augeas_stub.expects("save").returns(true)
- augeas_stub.expects("get").with("/augeas/events/saved").returns([])
- augeas_stub.expects("match").with("/augeas/events/saved").returns([])
@domcleal
domcleal / crm.rb
Created May 28, 2011 16:08
puppet-pacemaker ha_crm_property provider, using lazy_pip style
require 'rexml/document'
Puppet::Type.type(:ha_crm_property).provide(:crm) do
def create
lazy_crm_attribute "-t", "crm_config", "-n", resource[:name], "-v", resource[:value]
end
def destroy
lazy_crm_attribute "-t", "crm_config", "-n", resource[:name], "-D"
end
@domcleal
domcleal / pagesize.c
Created August 10, 2011 08:04
reads the page size for a virtual memory address of a given pid
/* pagesize: reads the page size for a virtual memory address of a given pid */
#include <errno.h>
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <unistd.h>
int main(int argc, char** argv) {
if (argc != 3) {
@domcleal
domcleal / upload.sh
Created December 4, 2011 11:08
Uploads radio station favourites to an Onkyo TX-NR509
#!/bin/bash
#
# Uploads a list of radio stations into an Onkyo receiver's web page
# Tested with a TX-NR509.
#
# Supply the list as "NAME=URL" lines on stdin.
#
# Copyright (c) 2011 Dominic Cleal <dominic@computerkb.co.uk>
# Released under the MIT licence.
#include b # works
include c # 'broken', shows warning
define a($x) {
exec { "A-$x":
command => "/bin/echo $x",
}
if $require {
Exec["A-$x"] { require +> $require }
@domcleal
domcleal / 11968.pp
Created January 21, 2012 17:35
Puppet bug #11968 reproducer
exec { "foo":
command => "/bin/echo foo",
}
file { "/tmp/test":
ensure => link,
replace => true,
target => "/tmp/foo",
force => true,
}
@domcleal
domcleal / gist:1654201
Created January 21, 2012 21:59
Puppet/Augeas quoting workaround with ERB templates (#7529)
quoting.pp:
$node = "foo"
augeas { "set-entry":
context => "/files/etc/sysconfig/network",
changes => [
"set INLINE[. = '\"$node\"'] '\"$node\"'",
],
}
augeas { "set-erb":
module Test_zabbix_agent =
let example = "###########################################################
# PUPPET MANAGED #
# Do not edit this file on a server node unless you #
# are willing to have your changes overwritten by #
# Puppet. If you really want to change the contents #
# repository and check it out on the puppet server. #
###########################################################
# This is config file for zabbix_agentd
@domcleal
domcleal / run.tests
Created January 30, 2012 09:46
augrun.c test harness, testing puppet bug #12199
# Tests for aug_srun
# Blank lines and lines starting with '#' are ignored. This file is
# processed by test-run.c
#
# The syntax for a test specification is
# test NAME RESULT ERRCODE
# COMMANDS
# prints
# OUTPUT