Skip to content

Instantly share code, notes, and snippets.

Dominic Cleal domcleal

View GitHub Profile
@domcleal
domcleal / access.aug
Created Apr 8, 2011
access.aug with @usergroup@@hostgroup support
View access.aug
(*
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
Stubbing in augeas spec
View augeas_spec_stub.patch
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
puppet-pacemaker ha_crm_property provider, using lazy_pip style
View crm.rb
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 Aug 10, 2011
reads the page size for a virtual memory address of a given pid
View pagesize.c
/* 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 Dec 4, 2011
Uploads radio station favourites to an Onkyo TX-NR509
View upload.sh
#!/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.
View 12050.pp
#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 Jan 21, 2012
Puppet bug #11968 reproducer
View 11968.pp
exec { "foo":
command => "/bin/echo foo",
}
file { "/tmp/test":
ensure => link,
replace => true,
target => "/tmp/foo",
force => true,
}
@domcleal
domcleal / gist:1654201
Created Jan 21, 2012
Puppet/Augeas quoting workaround with ERB templates (#7529)
View gist:1654201
quoting.pp:
$node = "foo"
augeas { "set-entry":
context => "/files/etc/sysconfig/network",
changes => [
"set INLINE[. = '\"$node\"'] '\"$node\"'",
],
}
augeas { "set-erb":
View test_zabbix_agent.aug
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 Jan 30, 2012
augrun.c test harness, testing puppet bug #12199
View run.tests
# 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
You can’t perform that action at this time.