Skip to content

Instantly share code, notes, and snippets.

View hunner's full-sized avatar

Hunter Haugen hunner

View GitHub Profile
@hunner
hunner / gist:9379414
Created March 6, 2014 00:05
puppet resource profile info with 5000 iptables rules.
[root@iau7gk8wy0bmy5p firewall]# cat test.rb
$: << '/etc/puppet/modules/firewall/lib'
require 'ruby-prof'
require 'facter'
require 'puppet'
# Profile the code
RubyProf.start
Puppet::Resource.indirection.search('firewall')
@hunner
hunner / test.rb
Last active August 29, 2015 14:02
confine :true => begin
a = Puppet::Node::Facts.indirection
a.terminus_class = :network_device
a.find(Puppet::Indirector::Request.new(:facts, :find, "clustered", nil))
rescue
:false
end
---
language: ruby
bundler_args: --without development
script: "bundle exec rake validate && bundle exec rake lint && bundle exec rake spec SPEC_OPTS='--color --format documentation'"
matrix:
fast_finish: true
include:
- rvm: 1.8.7
env: PUPPET_GEM_VERSION="~> 2.7.0" FACTER_GEM_VERSION="~> 1.6.0"
- rvm: 1.8.7
define some_define (
$listening_service,
$haproxy_acl,
#...
) {
concat::fragment { "HAProxy ACL for ${listening_service} from ${name}":
order => "20-${listening_service}-01-acl",
target => '/etc/haproxy/haproxy.cfg',
content => " acl ${haproxy_acl}\n",
}
[1] pry(#<RSpec::Core::ExampleGroup::Nested_1::Nested_1::Nested_2::Nested_2>)> cd subject
[2] pry(#<Puppet::Resource::Catalog>):1> puts resource("File[/dne/_etc_haproxy_haproxy.cfg/fragments/10_haproxy-base]")[:content]
global
chroot /var/lib/haproxy
daemon
group haproxy
log 10.10.10.10 local0
maxconn 4000
pidfile /var/run/haproxy.pid
stats socket /var/lib/haproxy/stats
@hunner
hunner / site.pp
Last active August 29, 2015 14:17
perf testing concats
node 'agent' {
$file_count = '100'
$backend = 'concat'
$content = "test1\n"
each(range('1',$file_count)) |$file_num| {
case $backend {
'concat': {
concat { "/tmp/frag_${file_num}":
ensure => present,
$url_hash = {
'public_protocol' => pick($public_protocol,'http'),
'public_address' => pick($public_address,'127.0.0.1'),
'compute_port' => pick($compute_port, '8774'),
'compute_version' => pick($compute_version,'v2'),
}
$url = "${url_hash['public_protocol']}://${url_hash['public_address']}:${url_hash['compute_port']}/${url_hash['compute_version']}/${tenant_id}s"
# Find the type of a given profile in the profile cache, or if it is not found
# try reloading the cache and looking again.
def self.find_profile_type(profile)
profiles = @@profile_cache ||= sort_profiles
if profiles[profile]
profiles[profile]
else
@@profile_cache = sort_profiles
@@profile_cache[profile]
end
@hunner
hunner / .gvimrc
Created February 17, 2011 00:26
Simple file for MacVim and auto-indentation
filetype indent on
set expandtab
set tabstop=4
set shiftwidth=4
set autoindent
set smartindent
@hunner
hunner / gist:1032544
Created June 17, 2011 22:56
This is an example of procedural languages at work.
#!/usr/bin/env ruby
##
## Procedural languages:
##
a = []
w=File.readlines('/usr/share/dict/words')
r=(0..10);c=r.map{Hash.new(0)};r.each{|i|