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 | |
| message="" | |
| # what OS is this? | |
| cur_os=$(uname -s) | |
| # do we have jq? | |
| if ! which jq >/dev/null 2>&1 ; then | |
| echo "please install jq" >&2 | |
| exit 1 |
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
| # Configure a serial port for IPMI (which provides virtual ones). | |
| # Depends on the "serial_ports" custom fact, included in this module | |
| define ipmi::serial { | |
| include stdlib | |
| include ipmi::serial_prerequisites | |
| $port_exists = member($::serial_ports, "/dev/${title}") | |
| if $port_exists { | |
| service { $title: |
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
| require 'bunny' | |
| require 'logger' | |
| class TestLoggerSubscribeMemleak | |
| def initialize(msg_count=10_000) | |
| @messages_to_write = msg_count | |
| @message_count = msg_count | |
| @connection = Bunny.new(:user=>"jbd_dev_reader", :pass=>"123456", :host=>"localhost", :vhost=>"jbd", :port=>5672) | |
| @connection.start | |
| @channel = @connection.create_channel |
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
| require 'bunny' | |
| require 'logger' | |
| class TestLoggerSubscribeMemleak | |
| def initialize(msg_count=10_000) | |
| @message_count = msg_count | |
| @messages_to_write = msg_count | |
| @connection = Bunny.new(:user=>"test_user", :pass=>"123456", :host=>"localhost", :vhost => "test", :port => 5672) | |
| @connection.start | |
| @channel = @connection.create_channel |
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
| trap('USR2') do | |
| # reconnect to MongoDB with read_secondary reversed | |
| result=MongoMapper.connection.instance_eval('@read_secondary = !@read_secondary') | |
| logger.notice("#{Time.now}: now reading from #{result ? 'secondary' : 'primary'}") | |
| 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
| def all_replicas_in_sync?(verbose=false) | |
| in_sync = true | |
| # connect to the primary | |
| mongo = Mongo::Connection.new(*MongoMapper.connection.primary) | |
| db = mongo.db('local') | |
| last_op=db.collection('oplog.rs').find.sort([['$natural',-1]]).limit(1).to_a[0] | |
| db.collection('slaves').find().to_a.each do |slave| | |
| opdiff = last_op['ts'].increment - slave['syncedTo'].increment | |
| diff = (last_op['ts'].seconds - slave['syncedTo'].seconds)/1000.0 | |
| in_sync = false if diff > 60 |
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
| class foo ($external_volume = true) { | |
| if $external_volume { | |
| notice("True!") | |
| } else { | |
| notice("False!") | |
| } | |
| } | |
| class { 'foo': | |
| external_volume => false, |
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
| matches = { | |
| [true, true] => 'fizzbuzz', | |
| [true, false] => 'fizz', | |
| [false, true] => 'buzz' | |
| } | |
| (1..100).each do |num| | |
| results = [num % 3 == 0, num % 5 == 0] | |
| puts matches[results] || num | |
| 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
| $alias_interface = ['primary:2'] | |
| if $alias_interface =~ /^primary\:(\d+)/ { | |
| notice("Match!") | |
| } else { | |
| notice("No Match :(") | |
| } |
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
| <%= | |
| require 'yaml' | |
| ldap_info = { | |
| 'main' => { | |
| 'label' => @label, | |
| 'host' => @host, | |
| 'port' => @port, | |
| 'uid' => @uid, | |
| 'method' => @method, | |
| 'bind_dn' => @bind_dn, |
NewerOlder