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
75
76
77
78
79
80
81
82
83
84
|
# File 'lib/logical-construct/ground-control/provision.rb', line 27
def define
manifest = nil
in_namespace do
directory marshalling.absolute_path
task :collect, [:ipaddr] do |task, args|
self.target_address = args[:ipaddr]
end
tunnel = LogicalConstruct::SSHTunnel.new do |tunnel|
tunnel.target_address = proxy_value.target_address
copy_settings_to(tunnel)
self.local_target_port = tunnel.proxy_value.local_target_port
end
manifest = LogicalConstruct::GenerateManifest.new(self)
start_flight = Mattock::Rake::RemoteCommandTask.define_task(:start_flight => :collect) do |start_flight|
start_flight.remote_server.address = proxy_value.target_address
start_flight.command =
Mattock::CommandLine.new("nohup",
"/opt/logical-construct/bin/flight-deck",
"-C start_server")
start_flight.command.redirect_stdin("/dev/null")
start_flight.command.redirect_stdout("/opt/logical-construct/flight_deck_server.log")
start_flight.command.copy_stream_to(2, 1)
start_flight.command.redirections << "&"
end
start_resolution = Mattock::Rake::RemoteCommandTask.define_task(:start_resolution => :deliver_manifest) do |start_flight|
start_flight.remote_server.address = proxy_value.target_address
start_flight.verbose = 3
start_flight.command =
Mattock::CommandLine.new("nohup",
"/opt/logical-construct/bin/flight-deck")
start_flight.command.redirect_stdin("/dev/null")
start_flight.command.redirect_stdout("/opt/logical-construct/flight_deck.log")
start_flight.command.copy_stream_to(2, 1)
start_flight.command.redirections << "&"
end
task manifest.root_task => :collect
task_spine(:start_flight, :deliver_manifest, :fulfill_manifest, :start_resolution, :complete_provision)
task :deliver_manifest => manifest[:deliver]
task :fulfill_manifest => manifest[:fulfill]
tunnel.wrap(manifest[:deliver])
tunnel.wrap(manifest[:fulfill])
task :complete_provision => tunnel[:close_tunnel]
end
desc "Provision :ipaddr with specified configs"
task root_task, [:ipaddr] => self[:complete_provision]
end
|