Skip to content

Instantly share code, notes, and snippets.

View hlindberg's full-sized avatar

Henrik Lindberg hlindberg

  • Bebalon Ltd
  • Għarb, Gozo, Malta
  • X @hel
View GitHub Profile
@hlindberg
hlindberg / gist:c300d021fee43f13779a7d5217e20820
Created November 19, 2016 15:24
example puppet nested naming equivalence and non nested names
a::x {
define b {}
}
should be written (as the 100% equivalent):
class a::x{
}
define a::x::b {
@hlindberg
hlindberg / abc_metric.rb
Created October 19, 2016 19:01
Start of ABC metric for Puppet
# AbcMetric sample - obviously in the wrong name space...
module Puppet::Pops
module Validation
class AbcMetric
attr_reader :assignment_count
def initialize()
@@abc_visitor ||= Visitor.new(nil, "abc", 0, 0)
@assignment_count = 0
@hlindberg
hlindberg / master-agent-from-source.md
Last active May 20, 2016 22:16
How to run puppet agent-t and master from source on same machine for tracing/debugging

Run Agent and Master from source on same machine

bundle exec puppet master --no-daemonize --certname localhost --dns_alt_names localhost --verbose
bundle exec puppet agent -t --certname localhost --server localhost

To re-set the CSR process for an agent:

@hlindberg
hlindberg / blog.pp
Created May 6, 2016 03:23
digging out data in style with puppet 4.5.0
$data = {
persons => {
'Henrik' => {
mother => 'Anna-Greta',
father => 'Bengt',
},
'Anna-Greta' => {
mother => 'Margareta',
father => 'Harald',
children => ['Henrik', 'Annika']
$limited_sudo = hiera('staff::allowed::sudo', undef)
if ( $limited_sudo ) {
$allowed_sudo = $limited_sudo.reduce( false ) |$allowed_sudo, $entry[ {
$team = $entry[1]
case [$allowed_sudo, $team, $username in hiera($team)] {
[ false, /::team::/, true] : {
warning ("Allowing sudo")
warning ("1: true")
true
}
@hlindberg
hlindberg / mismatch.svg
Created February 15, 2016 19:12
A type mismatch svg generated from a dot file
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#! /usr/bin/env ruby
require 'spec_helper'
require 'puppet'
describe "Puppet::DataProviders::HieraInterpolate" do
context "when there are empty interpolations %{} in data" do
let(:scope) { {} }
let(:lookup_invocation) {
@hlindberg
hlindberg / honedew_load_balancer.md
Created November 19, 2015 21:08
Honeydew Actor Load Balancer

Load Balancer Example (puppetized)

The first part - ChangeRequest is a generic actor that holds on to a set of values of type T (given when actor is instantiated), and emits the changed set whenever it changes.

type AddRemove = Enum['add', 'remove']
type ChangeRequest[T] = Struct[{'kind' => AddRemove, 'value' => T }]
---
packaging_url: 'git://github.com/puppetlabs/packaging.git --branch=master'
packaging_repo: 'packaging'
default_cow: 'base-squeeze-i386.cow'
cows: 'base-CumulusLinux-2.2-amd64.cow base-lucid-i386.cow base-precise-i386.cow base-squeeze-i386.cow base-trusty-i386.cow base-wheezy-i386.cow'
pbuild_conf: '/etc/pbuilderrc'
packager: 'puppet'
gpg_name: 'info@puppetlabs.com'
gpg_key: '4BD6EC30'
sign_tar: FALSE
@hlindberg
hlindberg / gist:ef417f3fb8778740f2a2
Last active August 29, 2015 14:24
Load balancer in Honeydew - $ for variables, no $ for queues

Load Balancer Example (puppetized)

The first part - ChangeRequest is a generic plan that holds on to a set of values of type T (given when plan is instantiated), and emits the changed set whenever it changes.

type AddRemove = Enum['add', 'remove']
type ChangeRequest[T] = Struct[{'kind' => AddRemove, 'value' => T }]