Skip to content

Instantly share code, notes, and snippets.

View logicminds's full-sized avatar

Corey Osman logicminds

View GitHub Profile
@logicminds
logicminds / puppet pre-commit
Created June 3, 2013 18:01
This is my git pre commit hook that would work for linux and windows systems
#!/bin/bash
against=$1
FILES=`git diff --cached --name-only --diff-filter=ACM`
# validate json files
for file in $FILES
do
# validate json files
if [[ $file == *.json ]]; then
@logicminds
logicminds / testajax.html
Created June 20, 2013 07:29
This is a test to find out if we can get foreman data via an ajax call in the browser. However, I believe this is failing due to : https://developer.mozilla.org/en-US/docs/HTTP/Access_control_CORS?redirectlocale=en-US&redirectslug=HTTP_access_control
<html>
<head>
<script>
var xmlhttp = null;
var jsondata = null;
function getFactData(hostname, factname, handler)
{
var foreman="http://foreman/api";
var factpath="fact_values?search=host=" + hostname + "+and+fact=" + factname;
var url = foreman + "/" + factpath;
@logicminds
logicminds / gist:6575668
Created September 16, 2013 01:04
bmclib test failure
localhost:bmclib cosman$ rake spec
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S rspec spec/unit/provider/bmc/ipmitool_spec.rb spec/unit/provider/bmcuser/ipmitool_spec.rb spec/unit/type/bmc_spec.rb spec/unit/type/bmcuser_spec.rb --color
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/sync.rb:58:in `Fail': Thread(#<Thread:0x10c00d360 run>) not locked. (Sync_m::Err::UnknownLocker)
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/sync.rb:64:in `Fail'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/sync.rb:184:in `sync_unlock'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/sync.rb:232:in `synchronize'
from /Library/Ruby/Gems/1.8/gems/puppet-3.3.0/lib/puppet/settings.rb:977:in `find_value'
from /Library/Ruby/Gems/1.8/gems/puppet-3.3.0/lib/puppet/settings.rb:1139:in `each_source'
from /Library/Ruby/Gems/1.8/gems/puppet-3.3.0/lib/puppet/settings.rb:1135:in `each'
from /Libra
@logicminds
logicminds / gist:6575704
Created September 16, 2013 01:12
puppet 3.2.4 load errors
rake spec
/System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/bin/ruby -S rspec spec/unit/provider/bmc/ipmitool_spec.rb spec/unit/provider/bmcuser/ipmitool_spec.rb spec/unit/type/bmc_spec.rb spec/unit/type/bmcuser_spec.rb --color
/Library/Ruby/Gems/1.8/gems/puppet-3.2.4/lib/puppet/util/autoload.rb:68:in `load_file': Could not autoload puppet/type/bmc: Could not autoload puppet/provider/bmc/ipmitool: Could not autoload puppet/provider/bmc/ipmitool: Could not autoload puppet/provider/bmc/ipmitool: Could not autoload puppet/provider/bmc/ipmitool: Could not autoload puppet/provider/bmc/ipmitool: Could not autoload puppet/provider/bmc/ipmitool: Could not autoload puppet/provider/bmc/ipmitool: Could not autoload puppet/provider/bmc/ipmitool: Could not autoload puppet/provider/bmc/ipmitool: Could not autoload puppet/provider/bmc/ipmitool: Could not autoload puppet/provider/bmc/ipmitool: Could not autoload puppet/provider/bmc/ipmitool: Could not autoload puppet/provider/bmc/ipmitool: Could not autoload puppet
@logicminds
logicminds / gist:6733062
Created September 27, 2013 18:31
Simple key=value facts similar to how puppet uses facts.d
if File.exists?File.expand_path('~/.env_config')
File.open(File.expand_path('~/.env_config'), "r") do |file|
file.each_line do | line|
fact = line.split('=')
if fact.count > 1
Facter.add(fact.first.strip) do
setcode do
fact.last.strip
end
end
#!/usr/bin/env bash
# first create the file with puppet just like sensu does
puppet apply --verbose -e 'file{"/tmp/testfile.txt": ensure => present, content => "foobar"}'
# now try to write to the file from ruby code (aka. the provide) just like puppet
cat > /tmp/providertest.rb << 'EOF'
#!/usr/bin/env ruby
@logicminds
logicminds / gist:4357821679592bfaef1e
Created May 1, 2014 15:27
puppet provider issue
#!/usr/bin/env bash
# first create the file with puppet just like sensu does
puppet apply --verbose -e 'file{"/tmp/testfile.txt": ensure => present, content => "foobar"}'
# now try to write to the file from ruby code (aka. the provide) just like puppet
cat > /tmp/providertest.rb << 'EOF'
#!/usr/bin/env ruby
@logicminds
logicminds / gist:9d73b1a9cdb8f37f8556
Created September 26, 2014 16:37
puppet function for troubleshooting
require 'json'
require 'puppet/parser/functions'
module Puppet::Parser::Functions
newfunction(:dump_args, :type => :statement,:doc => <<-EOS
dump_args - prints the args to STDOUT in Pretty JSON format.
Useful for debugging purposes only.
EOS
#!/usr/bin/env ruby
# Author: Corey Osman
# Date: 10/29/14
# Purpose: converts the puppetfile to a .fixtures file yaml format
#
# State: works on my machine, but needs further development to support the full Puppetfile DSL and .fixtures DSL
# Usage: from the module directory ensure you have a Puppetfile.
# because destruction of any .fixtures file could be deadly you must set the WIPE_FIXTURES env varialble to true.
# $ WIPE_FIXTURES=true ruby puppetfile_to_fixtures.rb
require 'beaker-rspec/spec_helper'
require 'beaker-rspec/helpers/serverspec'
require 'beaker-rspec'
require 'beaker'
RSpec.configure do |c|
# Project root
proj_root = File.expand_path(File.join(File.dirname(__FILE__), '..'))