Module: Vagabond::Actions::Cluster

Defined in:
lib/vagabond/actions/cluster.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.included(klass) ⇒ Object



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'lib/vagabond/actions/cluster.rb', line 5

def included(klass)
  klass.class_eval do
    class << self
      def _cluster_options
        [[
            :auto_provision, :type => :boolean,
            :desc => 'Automatically provision nodes', :default => true
          ],
          [
            :delay, :type => :numeric, :default => 0,
            :desc => 'Add delay between provisions (helpful for indexing)'
          ],
          [
            :parallel, :type => :boolean, :default => false,
            :desc => 'Build nodes in parallel'
          ]
        ]
      end
    end
  end
end

Instance Method Details

#_clusterObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
# File 'lib/vagabond/actions/cluster.rb', line 32

def _cluster
  clr = vagabondfile[:clusters][name] if vagabondfile[:clusters]
  if(clr)
    ui.info "#{ui.color('Vagabond:', :bold)} Building cluster - #{ui.color(name, :green)}"
    if(vagabondfile[:local_chef_server] && vagabondfile[:local_chef_server][:enabled])
      require 'vagabond/server'
      srv = ::Vagabond::Server.new
      srv.send(:setup, 'up')
      srv.execute
      # Reload so we get proper values
      load_configurations
    end
    cluster_instances = clr.map do |n|
      ui.info "Building #{n} for cluster!"
      v_inst = Vagabond.new
      v_inst.options = options.dup
      v_inst.send(:setup, 'up', n, :ui => ui)
      v_inst.execute
      if(options[:delay].to_i > 0 && n != clr.last)
        ui.warn "Delay requested between node processing. Sleeping for #{options[:delay].to_i} seconds."
        sleep(options[:delay].to_i)
      end
      v_inst
    end
    if(options[:parallel])
      ui.info "Waiting for parallel completes!"
      cluster_instances.map do |inst|
        inst.wait_for_completion
      end
    end
    ui.info "  -> #{ui.color("Built cluster #{name}", :green)}"
  else
    ui.error "Cluster name provided does not exist: #{name}"
  end
end

#cluster_validate?Boolean

Returns:

  • (Boolean)


28
29
30
# File 'lib/vagabond/actions/cluster.rb', line 28

def cluster_validate?
  false
end