Class: Chef::Knife::ClusterLaunch
Instance Attribute Summary
#broker, #problems
Instance Method Summary
collapse
#all_computers, #bootstrapper, #configure_dry_run, #confirm_execution, #confirm_or_exit, #die, #discover_computers, #display, #exit_if_unhealthy!, #gemfile, #get_relevant_slice, #get_slice, #has_problem, #healthy?, included, load_deps, #load_ironfan, #pick_apart, #predicate_str, #progressbar_for_threads, #relevant?, #run, #run_bootstrap, #section, #sub_command, #wait_for_ssh
Instance Method Details
#_run ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
# File 'lib/chef/knife/cluster_launch.rb', line 66
def _run
load_ironfan
die(banner) if @name_args.empty?
configure_dry_run
full_target = get_slice(*@name_args)
display(full_target)
target = full_target.select(&:launchable?)
warn_or_die_on_bogus_servers(full_target) unless full_target.select(&:bogus?).empty?
die("", "#{ui.color("All computers are running -- not launching any.",:blue)}", "", 0) if target.empty?
if config[:bootstrap]
ensure_common_environment(target)
end
section("Syncing to chef")
target.save :providers => :chef
unless target.empty?
ui.info "Preparing shared resources:"
all_computers(*@name_args).prepare
end
ui.info("")
section("Launching computers", :green)
display(target)
launched = target.launch
launch_succeeded = true
Ironfan.parallel(launched) do |computer|
if (computer.is_a?(Exception)) then
ui.error "Error launching #{computer.inspect}; skipping after-launch tasks.";
launch_succeeded = false
else
perform_after_launch_tasks(computer) if computer.machine.perform_after_launch_tasks?
end
end
if healthy? and launch_succeeded
section('All computers launched correctly', :white)
section('Applying aggregations:')
all_computers(*@name_args).aggregate
else
section('Some computers could not be launched')
exit 1
end
display(target)
end
|
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
|
# File 'lib/chef/knife/cluster_launch.rb', line 129
def perform_after_launch_tasks(computer)
unless config[:dry_run]
if config[:wait_ssh]
Ironfan.step(computer.name, 'trying ssh', :white)
nil until wait_for_ssh(computer){ sleep @initial_sleep_delay ||= 10 }
end
end
if config[:bootstrap]
Ironfan.step(computer.name, 'bootstrapping', :green)
run_bootstrap(computer)
end
end
|
#warn_or_die_on_bogus_servers(target) ⇒ Object
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
# File 'lib/chef/knife/cluster_launch.rb', line 145
def warn_or_die_on_bogus_servers(target)
ui.info("")
ui.info "Cluster has servers in a transitional or undefined state (shown as 'bogus'):"
ui.info("")
display(target)
ui.info("")
unless config[:force]
die(
"Launch operations may be unpredictable under these circumstances.",
"You should wait for the cluster to stabilize, fix the undefined server problems",
"(run \"knife cluster show CLUSTER\" to see what the problems are), or launch",
"the cluster anyway using the --force option.", "", -2)
end
ui.info("")
ui.info "--force specified"
ui.info "Proceeding to launch anyway. This may produce undesired results."
ui.info("")
end
|