Skip to content

Instantly share code, notes, and snippets.

View hunner's full-sized avatar

Hunter Haugen hunner

View GitHub Profile
$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"
@hunner
hunner / example_spec.rb
Last active May 17, 2018 11:53
Example code for beaker-rspec on master & agent
# This is what a test would look like.
require 'spec_helper_acceptance'
describe 'some class' do
it 'does stuff' do
pp=<<-EOS
notify { 'done stuff spec':
message => 'This message should appear',
}
EOS
@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,
[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
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",
}
---
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
@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
@hunner
hunner / bashbot.sh
Created May 31, 2014 01:42
Bash irc bot
#!/usr/bin/env bash
line=""
started=""
rm botfile
mkfifo botfile
tail -f botfile | nc irc.cat.pdx.edu 6667 | while true ; do
if [ -z $started ] ; then
echo "USER bdbot 0 bdbot :I iz a bot" > botfile
echo "NICK bdbot" >> botfile
@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')
require 'spec_helper_acceptance'
describe 'ntp class' do
it "applies idempotently" do
pp = "class { 'ntp': }"
apply_manifest(pp, :catch_failures => true)
apply_manifest(pp, :catch_changes => true)
end
describe file("/etc/ntp.conf") do
it { should be_file }