Class: Caterer::Command::Provision

Inherits:
Server show all
Defined in:
lib/caterer/command/provision.rb

Instance Method Summary collapse

Methods inherited from Server

#add_server_opts, #image_list, #init_server, #target_servers, #with_target_servers

Methods inherited from Base

#initialize, #parse_options

Constructor Details

This class inherits a constructor from Caterer::Command::Base

Instance Method Details

#executeObject



5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/caterer/command/provision.rb', line 5

def execute
  options = {}
  parser = OptionParser.new do |opts|
    opts.banner = "Usage: cater provision HOST [options]"
  end

  add_server_opts(parser, options)

  # add provision specific options
  parser.on('-d JSON', '--data JSON', 'json data that the provisioner may use' ) do |d|
    options[:data] = d
  end
  parser.on('--ghost', 'provision in ghost-mode (leave no trace)') do
    options[:ghost] = true
  end
  parser.on('--dry', "sync provision configuration, but don't run the provisioner") do
    options[:dry] = true
  end

  parser.separator ""

  # Parse the options
  argv = parse_options(parser, true)
  return if not argv

  with_target_servers(argv, options) do |server|
    server.provision(dry_run: options[:dry], ghost_mode: options[:ghost])
  end

  0
end