Skip to content

Instantly share code, notes, and snippets.

View ahpook's full-sized avatar

Eric Sorenson ahpook

View GitHub Profile
ls -l /puppet/environments
lrwxrwxrwx 1 root issre 46 Jun 14 22:25 ic -> /puppet/checkouts/ic/tags/12.58.1
lrwxrwxrwx 1 root issre 46 Jun 14 22:25 ic_qa -> /puppet/checkouts/ic/tags/12.59.0
lrwxrwxrwx 1 root issre 39 Jun 14 17:09 ic_trunk -> /puppet/checkouts/ic/trunk
## /etc/puppet/puppet.conf
[master]
modulepath = /puppet/environments/$environment/modules
manifest = /puppet/environments/$environment/manifests/site.pp
file { "whatever":
ensure => present,
require => $operatingsystem ? {
linux => Package["needthis"],
solaris => Package["somethingelse"],
default => undef,
}
}
@ahpook
ahpook / gunnar.zsh
Created August 28, 2012 04:48
working on shell scripts with gunnar
#!/bin/zsh
say "hi gunnar"
say "how are you today?"
echo -n "your answer? "
read feeling_answer
say "i am glad that you are $feeling_answer"
say "do you want food?"
echo -n "your answer? "
read food_answer
@ahpook
ahpook / gist:4127992
Created November 21, 2012 21:40
How can I troubleshoot problems with Puppet's SSL layer?

I feel your pain. SSL is tough and is probably the number one stumbling block for new users getting Puppet working in their environment. Hopefully this answer helps reduce frustration and get you up and running. The good news is, once it's set up right, you won't have to fiddle with it any more.

First, make sure the problem you're having is actually an SSL problem. Almost all of the SSL-related error messages on the client start with the string SSL_connect and then the error raised up by the underlying crypto libraries. General networking errors will not have this string, so normal network troubleshooting methodology applies; specifically, Connection refused - connect(2) means a TCP connection attempt got a RST packet indicating a firewall or puppet master not running, and getaddrinfo: nodename nor servname provided, or not known means the server's hostname (the value of puppet agent --configprint server) was not resolvable in DNS/hosts.

Next, assuming you do have an SSL_connect style error, it

@ahpook
ahpook / kitty_lengths.lua
Created December 27, 2012 22:42
kitty_lengths.lua
cats = {4, 10, 11, 12, 8, 15, 9, 12}
i = 1
sum = 0
while i <= #cats do
sum = sum + cats[i]
i = i + 1
end
print("Total kitty length is:", sum, "there are", #cats, "cats, so the average kitty length is", sum / #cats)
@ahpook
ahpook / data_in_modules.md
Created February 8, 2013 14:11
Data in modules summary

Data in Modules Summary

Problem Statement

Currently, module authors use a 'params class pattern' to provide defaults for the parameters their classes accept. A module for managing a database service mydb, for example, will provide a class mydb::params, which contains parameter assignments like $mydb::params::tcp_port, $mydb::params::install_dir, etc. These assignments can use the puppet DSL for conditional logic so that the install_directory follows different OS' filesystem conventions appropriately. The parameter values are then used in the module's other classes, either in the prototype for the class or directly in the manifest:

class mydb::packages (

$tcp_port = $mydb::params::tcp_port,

@ahpook
ahpook / gist:5802688
Created June 18, 2013 04:31
range bug
eric@cipater ...stdlib/lib/puppet/parser/functions]% puppet apply --modulepath=/Users/eric/Sandbox/fosdem/puppet/modules -e '$t = range("/d1","/d14")
notice "t is $t"
'
Warning: Could not retrieve fact fqdn
Notice: Scope(Class[main]): t is /d1/d2/d3/d4/d5/d6/d7/d8/d9/e0/e1/e2/e3/e4/e5/e6/e7/e8/e9/f0/f1/f2/f3/f4/f5/f6/f7/f8/f9/g0/g1/g2/g3/g4/g5/g6/g7/g8/g9/h0/h1/h2/h3/h4/h5/h6/h7/h8/h9/i0/i1/i2/i3/i4/i5/i6/i7/i8/i9/j0/j1/j2/j3/j4/j5/j6/j7/j8/j9/k0/k1/k2/k3/k4/k5/k6/k7/k8/k9/l0/l1/l2/l3/l4/l5/l6/l7/l8/l9/m0/m1/m2/m3/m4/m5/m6/m7/m8/m9/n0/n1/n2/n3/n4/n5/n6/n7/n8/n9/o0/o1/o2/o3/o4/o5/o6/o7/o8/o9/p0/p1/p2/p3/p4/p5/p6/p7/p8/p9/q0/q1/q2/q3/q4/q5/q6/q7/q8/q9/r0/r1/r2/r3/r4/r5/r6/r7/r8/r9/s0/s1/s2/s3/s4/s5/s6/s7/s8/s9/t0/t1/t2/t3/t4/t5/t6/t7/t8/t9/u0/u1/u2/u3/u4/u5/u6/u7/u8/u9/v0/v1/v2/v3/v4/v5/v6/v7/v8/v9/w0/w1/w2/w3/w4/w5/w6/w7/w8/w9/x0/x1/x2/x3/x4/x5/x6/x7/x8/x9/y0/y1/y2/y3/y4/y5/y6/y7/y8/y9/z0/z1/z2/z3/z4/z5/z6/z7/z8/z9/aa0/aa1/aa2/aa3/aa4/aa5/aa6/aa7/aa8/aa9/ab0/ab1/ab2/ab3/ab4/ab5/ab6/ab7/ab8/ab9/ac0/ac1/ac2/ac3/
@ahpook
ahpook / triage.pp
Last active December 18, 2015 22:19
Triage T-shirt code
define triage::worker ( $ensure = 'present' ) {
notify { $title: }
}
define food() { }
define drink() { }
food { 'pizza': }
drink { ['coffee', 'beer']: }
@ahpook
ahpook / future_loop.pp
Last active December 19, 2015 02:09
Future loop
$array = [ "a", "b", "c" ]
$array.each |$x| {
$var = inline_template("instance var: <% @x %> lookupvar: <%= scope.lookupvar('x') %>")
notify { "Loop $x": message => "$var" }
}
@ahpook
ahpook / puzzle4.js
Created July 9, 2013 06:26
Solution to http://bitsquest.bitbucket.org/index.html#4 , even though it's not necessary to use the variable (you can just go up and right till you hit the right wall, then down)
var beenTop = false;
this.on("start", function() {
this.thrusters.left(true);
});
this.on('sensor:top', function(contact) {
this.thrusters.bottom(false);
beenTop = true;
});