Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env ruby
require 'json'
def dig(hash, keys)
keys.reduce(hash) {|h, k| i = h[k]; i ? i : break }
end
def to_csv(json, fields)
fields.map{|f| json[f] }.join(',')
sellout:puppet justin$ git diff spec/
diff --git a/spec/unit/transaction_spec.rb b/spec/unit/transaction_spec.rb
index 0316c8b..4a20a2b 100644
--- a/spec/unit/transaction_spec.rb
+++ b/spec/unit/transaction_spec.rb
@@ -2,6 +2,7 @@
require 'spec_helper'
require 'matchers/include_in_order'
require 'puppet_spec/compiler'
+require 'pry'
#!/usr/bin/env ruby
require 'csv'
inputfile = ARGV[0]
intermediate = {
'node' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'filemeta plugins' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'filemeta pluginfacts' => {'KOs' => 0, 'values' => [], 'ok' => 0},
'catalog' => {'KOs' => 0, 'values' => [], 'ok' => 0},
@justinstoller
justinstoller / clean.rb
Last active December 13, 2017 00:10
Misc when using the Puppet Profiler
#!/usr/bin/env ruby
def clean_profile_line(line)
if line =~ /.*\[(\d+)\] (\d(\.\d\d?)*) (.*): took (\d*\.?\d*) seconds/
request_id = $1
step_and_maybe_substeps = $2
# unused artifact of the regex, named here for documentation purposes
maybe_substeps = $3
step_name = $4
@justinstoller
justinstoller / example.txt
Last active February 12, 2019 00:27
profiling server responding to catalog request in repl
sellout:puppetserverspike justin$ lein with-profile +yk9k irb
Using 1G min heap since not set via PUPPETSERVER_HEAP_SIZE environment variable or user.puppetserver-heap-size in ~/.lein/profiles.clj file. Set to at least 5G for best performance during test runs.
Using 2G max heap since not set via PUPPETSERVER_HEAP_SIZE environment variable or user.puppetserver-heap-size in ~/.lein/profiles.clj file. Set to at least 5G for best performance during test runs.
[YourKit Java Profiler 2017.02-b66] Log file: /Users/justin/.yjp/log/main-78581.log
irb(main):001:0> load './puppet_server_helper.rb'
WARN: Unresolved specs during Gem::Specification.reset:
gettext (>= 3.0.2)
WARN: Clearing out unresolved specs.
Please report a bug if this causes problems.
@justinstoller
justinstoller / gist:f57e64b78ed568c52c08ef12a170dec3
Last active November 10, 2017 17:04
dependency cycle with pdb
Seeing this failure when tring to install PDB via the module on Debian 9:
cy21od14dqt4842.delivery.puppetlabs.net (debian9-64-1) executed in 4.38 seconds
RuntimeError: PuppetAcceptance::DSL::Helpers.with_puppet_running_on failed (check backtrace for location) because: Host 'cy21od14dqt4842.delivery.puppetlabs.net' exited with 1 running:
puppet agent --test --server cy21od14dqt4842.delivery.puppetlabs.net
Last 10 lines of output were:
Notice: /File[/opt/puppetlabs/puppet/cache/lib/puppet_x]/ensure: created
Notice: /File[/opt/puppetlabs/puppet/cache/lib/puppet_x/apt_key]/ensure: created
Notice: /File[/opt/puppetlabs/puppet/cache/lib/puppet_x/apt_key/patch_openuri.rb]/ensure: defined content as '{md5}951bad007a3b5db035be069c1d1c9c09'
legacy_opts = {
:default_action => 'gem_install',
:version => (ENV['PUPPET_VERSION'] || '3.8.1'),
}
aio_opts = {
:default_action => 'gem_install',
:version => (ENV['PUPPET_AGENT_VERSION'] || '1.1.0'),
}
require 'spec_helper_acceptance'
describe 'a basic test' do
it 'does very little' do
puppet_run = apply_manifest("notify {'Hello Bar': }", :catch_failures => true)
expect(puppet_run.stdout).to include('Hello Bar')
end
end
require 'spec_helper_acceptance'
describe 'just to make the setup code run' do
it { true }
end
@justinstoller
justinstoller / jenkins-slave.sh
Created July 18, 2014 19:57
basic init script
#!/bin/sh
#
# /etc/init.d/jenkins-slave
# init script for Jenkins Slave Swarm Client.
#
# chkconfig: 2345 90 60
# description: Jenkins Slave Swarm Client
#
RETVAL=0