Created
August 5, 2013 15:54
-
-
Save dallasmarlow/6157024 to your computer and use it in GitHub Desktop.
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
| # plugins, recipes, clusters, etc | |
| Dir['lib/*', 'recipes/*', 'config/groups/*'].each {|plugin| load plugin} | |
| # default settings | |
| load 'config/settings' |
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 'collins_client' | |
| class CollinsSelector | |
| attr_reader :collins | |
| def initialize config | |
| @collins = Collins::Client.new config | |
| end | |
| def select attribute, selector | |
| collins.find(defaults.merge(selector)).collect do |node| | |
| node.send attribute | |
| end | |
| end | |
| def selectors selectors | |
| defaults.merge! selectors | |
| end | |
| def method_missing method, *args | |
| missing_method = method.to_s | |
| if missing_method.start_with? 'select_' | |
| select missing_method.sub('select_', ''), *args | |
| else | |
| collins.send method, *args | |
| end | |
| end | |
| private | |
| def defaults | |
| @defaults ||= { | |
| :type => :server_node.upcase, | |
| :status => :allocated, | |
| :operation => :and, | |
| :size => 10 ** 5, | |
| :details => true, | |
| } | |
| end | |
| 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
| task :hadoop_pb do | |
| collins.selectors :primary_role => :hadoop, :pool => :peanutbutter | |
| # namenode / job tracker | |
| server collins.select_hostname(:secondary_role => /^namenode$/).first, :namenode, :jobtracker | |
| # secondary namenode | |
| role :secondary_namenode, collins.select_hostname(:secondary_role => :secondary_namenode).first | |
| # datanodes / task trackers | |
| collins.select_hostname(:secondary_role => :datanode).each do |node| | |
| server node, :datanode, :tasktracker | |
| end | |
| 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
| require File.expand_path File.join File.dirname(__FILE__), 'hash.rb' | |
| require 'colored' | |
| require 'ipaddr' | |
| # helpers | |
| def info *messages | |
| puts messages.join("\s").blue | |
| end | |
| def warn *messages | |
| puts messages.join("\s").yellow | |
| end | |
| def error *messages | |
| puts messages.join("\s").red | |
| end | |
| def fatal *messages | |
| abort messages.join("\s").red | |
| end | |
| def collins_group_assets | |
| find_servers_for_task(current_task).collect do |host| | |
| collins.find hostname: host, | |
| details: true, | |
| size: 10000 | |
| end.flatten | |
| 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
| # ssh options | |
| ssh_options[:forward_agent] = true | |
| ssh_options[:keys] = Dir.glob(File.join(ENV['HOME'], '.ssh', 'id_*')).reject do |key| | |
| key.start_with? '.' | |
| end | |
| # misc options | |
| default_run_options[:pty] = true | |
| # collins selector | |
| set :collins_config, '~/.collins.yaml' | |
| set :collins_yaml, YAML.load_file(File.expand_path(collins_config)) | |
| set :collins, CollinsSelector.new(collins_yaml[:collins] || collins_yaml['collins']) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment