Skip to content

Instantly share code, notes, and snippets.

@op-ct
op-ct / sample_mocking_spec.rb
Created May 8, 2020 21:21 — forked from hlindberg/sample_mocking_spec.rb
An rspec sample showing some override and mocking of 4.x functions/function loading
require 'spec_helper'
# Example rspec_puppet function rspec test (i.e. subject is the function 'min')
# This works for other rspec subjects as well as a compiler is always involved.
# This kind of mocking can be required when it is not enough to simply override
# a function with another implementation (which can be done with a `let(:pre_condition) { 'function min($x, $y) { ... }'}`
#
# The main difficulty that this overcomes is the need to let the compiler initialize and
# create the context in which it will operate before making any mocks.
#
@op-ct
op-ct / include-pwd-gem-dir.rb
Created April 8, 2020 23:41
bolt-friendly gem include snippet
$LOAD_PATH.push *(Dir[File.expand_path('.gems/gems/*/lib',Dir.pwd)] )
@op-ct
op-ct / example.pp
Last active April 6, 2020 21:36
dying plan
```yaml
---
version: 2
groups:
- name: named_local_targets
targets: ['not_localhost']
config:
transport: local
```
@op-ct
op-ct / inventory.yaml
Created March 31, 2020 23:31
WIP: git repo-syncing bolt plan
---
version: 2
groups:
- name: repo_targets
targets: []
config:
transport: local
local:
tmpdir:
_plugin: env_var
@op-ct
op-ct / emoji-and-labels.mscgen.seq
Last active January 14, 2020 20:19
mscgen_js sequence diagram with emoji+labels (👳🏦🏭)
# Sequence diagram with emoji+labels using the MscGen language
#
# https://mscgen.js.org/
# https://mscgen.js.org/tutorial.html
msc {
hscale="0.7",
width="700";
"👳" [label="👳\ndude", linecolor="darkgreen", textcolor="darkgreen", arclinecolor="darkgreen", arctextcolor="darkgreen"],
@op-ct
op-ct / puppetdbdb.rb
Last active December 4, 2019 20:30
Query latest report metrics from PuppetDB
#!/opt/puppetlabs/puppet/bin/ruby
# -------------------------------------------------------------------
# Report the latest nodes whose catalogs that took over 300s to apply
#
# Setup:
#
# puppet-query --cert CERTNAME.cert.pem --key KEYFILE.key.pem 'reports[certname,status,catalog_uuid,receive_time,start_time,end_time,noop,noop_pending,environment,configuration_version,metrics] { latest_report? = true }' > latest_reports.json
#
# Usage:
#
@op-ct
op-ct / .octocatalog-diff.cfg.rb
Last active November 13, 2019 23:30
WIP: octocatalog-diff settings for local factsets
module OctocatalogDiff
class Config
def self.config
settings = {}
settings[:puppet_binary] = File.join( `bundle show puppet`.chomp, 'bin', 'puppet')
settings[:hiera_path_strip] = '/etc/puppetlabs/code/environments'
settings[:hiera_config] = 'hiera.yaml'
settings[:fact_file] = 'spec/factsets/sampled.facts.json'
settings[:from_env] = 'origin/master'
settings[:basedir] = Dir.pwd
@op-ct
op-ct / Vagrantfile
Created November 5, 2019 01:11
multi-machine Vagrantfile to test Puppet bolt
Vagrant.configure('2') do |c|
c.ssh.insert_key = false
c.vm.box = "centos/7"
c.vm.define 'target' do |v|
v.vm.network 'private_network', ip: '10.10.101.102'
end
c.vm.define 'bolt', primary: true do |v|
v.vm.network 'private_network', ip: '10.10.101.101'
@op-ct
op-ct / config.yaml
Last active September 17, 2019 19:40
xterm.js base-16 template
# Tested https://github.com/obahareth/base16-builder-ruby and WeTTY
default:
extension: .json
output: xtermjs
@op-ct
op-ct / virtualbox_create_vm.sh
Last active December 19, 2023 07:51 — forked from mitsuji/create_vm.sh
VirtualBox create vm shell script
#!/bin/sh
#
# adapted from https://gist.github.com/mitsuji/8397836
#
# For usage, run without arguments
#
VM_NAME=$1
DVD_PATH=${2:---}
OS_TYPE="${3:-${OS_TYPE:-RedHat_64}}"