Class: Mofa::CLI

Inherits:
Thor
  • Object
show all
Includes:
Config, Thor::Actions
Defined in:
lib/mofa/cli.rb

Constant Summary collapse

@@option_verbose =
false
@@option_debug =
false

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Config

config, load

Class Method Details

.option_debugObject



86
87
88
# File 'lib/mofa/cli.rb', line 86

def self.option_debug
  @@option_debug
end

.option_verboseObject



82
83
84
# File 'lib/mofa/cli.rb', line 82

def self.option_verbose
  @@option_verbose
end

Instance Method Details

#provision(cookbook_name_or_path) ⇒ Object



31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
# File 'lib/mofa/cli.rb', line 31

def provision(cookbook_name_or_path)
  set_verbosity
  cookbook_name_or_path ||= '.'

  token = MofaCmd.generate_token

  hostlist = Hostlist.create(options[:concrete_target])
  cookbook = Cookbook.create(cookbook_name_or_path, token, options[:override_mofa_secrets])
  runlist_map = RunlistMap.create(cookbook, hostlist, token, options[:runlist])
  attributes_map = AttributesMap.create(cookbook, hostlist, token, options[:runlist], options[:attributes])

  cmd = ProvisionCmd.new(token, cookbook)

  cmd.hostlist = hostlist
  cmd.runlist_map = runlist_map
  cmd.attributes_map = attributes_map
  cmd.options = options

  cmd.prepare
  cmd.execute(options[:ssh_port], options[:ssh_user], options[:ssh_keyfile])
  cmd.cleanup
end

#upload(cookbook_path) ⇒ Object



60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
# File 'lib/mofa/cli.rb', line 60

def upload(cookbook_path)
  set_verbosity

  cookbook_path ||= '.'

  token = MofaCmd.generate_token
  cookbook = Cookbook.create(cookbook_path, token)

  cmd = UploadCmd.new(token, cookbook)

  cmd.prepare
  # FIXME: bring in the ssh-port in a different way
  cmd.execute(22)
  cmd.cleanup
end

#versionObject



78
79
80
# File 'lib/mofa/cli.rb', line 78

def version
  puts VERSION
end