This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# BLOWS UP | |
require 'socket' | |
Puppet::Parser::Functions.newfunction(:mastername, :type => :rvalue ) do | |
Socket.gethostname.chomp | |
end | |
[root@classroom test]# puppet apply -e 'notice(mastername())' | |
Error: wrong number of arguments (1 for 0) at line 1 on node classroom.puppetlabs.vm | |
Wrapped exception: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is a quick example to show how something like ruby blocks might be implemented in another language | |
// psuedo code follows, don't get hung up on syntax | |
class Array { | |
std::vector<int> array; | |
Array (std::vector in) { | |
self.array = in; | |
} | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# hackyfix ze puppets to run on mavericks | |
cd /usr/lib/ruby/site_ruby/2.0.0 | |
for i in "facter hiera hiera_puppet.rb puppet.rb puppetx.rb facter.rb hiera.rb puppet puppetx semver.rb" | |
do | |
sudo ln -s ../1.8/${i} ${i} | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'yaml' | |
require 'syslog' | |
require 'net/https' | |
FOREMAN = 'http://foreman.server.org' | |
MASTER = 'puppet.master.org' | |
RAKEAPI = "ssh #{MASTER} /opt/puppet/bin/rake -f /opt/puppet/share/puppet-dashboard/Rakefile RAILS_ENV=production node:add['%name',,'%classes']" | |
GITROOT = '/var/repos' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'rubygems' | |
require 'sinatra/base' | |
require 'webrick' | |
#require 'webrick/https' | |
#require 'openssl' | |
require 'resolv' | |
require 'json' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# webhooks Manage webhooks service | |
# | |
# chkconfig: 2345 55 25 | |
# description: Stupidsimple webhooks implementation. | |
# | |
# This is a pretty cruddy init script. | |
# source function library |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# The problem is that an RPM package may have a dependency on the asterisk-11-repo RPM | |
# package itself. If you install the other package, it will also pull in the RPM package. | |
# That's a bit icky, to be sure, but it won't actually *break* anything. | |
# | |
# The repo package would be installed, which would drop in a .repo file, but only do | |
# that ONE time. The yumrepo provider would then overwrite it with the actual contents | |
# as defined in your manifest and then maintain those properties. | |
# | |
# This is exactly how it works when you install a package with sample configuration files | |
# and then manage the real configuration files with Puppet. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /opt/puppet/bin/ruby | |
require 'json' | |
raise "Run this script with a node name that has had a catalog compiled on this master" unless ARGV.size == 1 | |
catalog = JSON.parse(File.read("/var/opt/lib/pe-puppet/client_data/catalog/#{ARGV[0]}.json")) | |
puts " Class count: #{catalog['data']['resources'].select { |r| r['type'] == 'Class' }.size}" | |
puts "Resource count: #{catalog['data']['resources'].reject { |r| r['type'] == 'Class' }.size}" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /usr/bin/env ruby | |
require 'augeas' | |
Augeas::open do |aug| | |
puts aug.get('/files/etc/krb5.conf/libdefaults/default_realm') | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
################### don't do this ################### | |
node default { | |
include something | |
include something else | |
} | |
node 'boo' inherits default { | |
include a third thing | |
} |