4
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
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
67
68
69
70
71
72
73
74
|
# File 'lib/puppet_plugin/identify/command.rb', line 4
def execute
@options = {}
@options[:verbose] = false
@options[:debug] = false
@options[:trace] = false
@options[:provider] = 'virtualbox'
@options[:environment] = 'obeheer1'
@options[:transport] = 'vagrant'
opts = OptionParser.new do |o|
o.banner = "Usage: vagrant identify [options] [name]"
o.separator ""
o.separator "Options:"
o.separator ""
o.on("--[no-]debug",
"Run puppet with --debug (default to false)") do |debug|
@options[:debug] = debug
end
o.on("--[no-]verbose",
"Run puppet with --verbose (default to true)") do |verbose|
@options[:verbose] = verbose
end
o.on("--[no-]trace",
"Run puppet with --trace (default to true)") do |trace|
@options[:trace] = trace
end
o.on("--environment ENV", String,
"Specify the environment. Default is: obeheer1") do |environment|
@options[:environment] = environment
end
o.on("--transport TRANSPORT", String,
"Specify the transport. Default is: vagrant") do |transport|
@options[:transport] = transport
end
o.on("--provider PROVIDER", String,
"Back the machine with a specific provider") do |provider|
@options[:provider] = provider
end
end
argv = parse_options(opts)
if argv.size < 2
@env.ui.info(I18n.t("vagrant.puppet_plugin.commands.identify.need_ip_and_name"))
return 1
end
@hostname = argv[0]
@ipaddress = argv[1]
@env.ui.info(I18n.t(
"vagrant.puppet_plugin.commands.identify.starting",
hostname: @hostname,
ipaddress: @ipaddress))
with_target_vms('default', provider: @options[:provider]) do |machine|
set_name_and_ip(machine)
set_puppet_options(machine)
set_shell_command(machine)
machine.action(:up, @options)
end
end
|