This file contains 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
[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') |
This file contains 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
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 |
This file contains 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
--- | |
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 |
This file contains 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
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", | |
} |
This file contains 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
[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 |
This file contains 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
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, |
This file contains 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
$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" |
This file contains 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
# 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 |
This file contains 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
filetype indent on | |
set expandtab | |
set tabstop=4 | |
set shiftwidth=4 | |
set autoindent | |
set smartindent |
This file contains 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 | |
## | |
## Procedural languages: | |
## | |
a = [] | |
w=File.readlines('/usr/share/dict/words') | |
r=(0..10);c=r.map{Hash.new(0)};r.each{|i| |
OlderNewer