plugins/provisioners/chef/provisioner/chef_client.rb in vagrant-unbundled-2.0.0.1 vs plugins/provisioners/chef/provisioner/chef_client.rb in vagrant-unbundled-2.0.1.0
- old
+ new
@@ -71,38 +71,45 @@
def run_chef_client
if @config.run_list && @config.run_list.empty?
@machine.ui.warn(I18n.t("vagrant.chef_run_list_empty"))
end
- if @machine.guest.capability?(:wait_for_reboot)
- @machine.guest.capability(:wait_for_reboot)
- end
-
command = CommandBuilder.command(:client, @config,
windows: windows?,
colored: @machine.env.ui.color?,
)
-
+
+ still_active = 259 #provisioner has asked chef to reboot
+
@config.attempts.times do |attempt|
- if attempt == 0
- @machine.ui.info I18n.t("vagrant.provisioners.chef.running_client")
- else
- @machine.ui.info I18n.t("vagrant.provisioners.chef.running_client_again")
- end
+ exit_status = 0
+ while exit_status == 0 || exit_status == still_active
+ if @machine.guest.capability?(:wait_for_reboot)
+ @machine.guest.capability(:wait_for_reboot)
+ elsif attempt > 0
+ sleep 10
+ @machine.communicate.wait_for_ready(@machine.config.vm.boot_timeout)
+ end
+ if attempt == 0
+ @machine.ui.info I18n.t("vagrant.provisioners.chef.running_client")
+ else
+ @machine.ui.info I18n.t("vagrant.provisioners.chef.running_client_again")
+ end
- opts = { error_check: false, elevated: true }
- exit_status = @machine.communicate.sudo(command, opts) do |type, data|
- # Output the data with the proper color based on the stream.
- color = type == :stdout ? :green : :red
+ opts = { error_check: false, elevated: true }
+ exit_status = @machine.communicate.sudo(command, opts) do |type, data|
+ # Output the data with the proper color based on the stream.
+ color = type == :stdout ? :green : :red
- data = data.chomp
- next if data.empty?
+ data = data.chomp
+ next if data.empty?
- @machine.ui.info(data, color: color)
- end
+ @machine.ui.info(data, color: color)
+ end
- # There is no need to run Chef again if it converges
- return if exit_status == 0
+ # There is no need to run Chef again if it converges
+ return if exit_status == 0
+ end
end
# If we reached this point then Chef never converged! Error.
raise ChefError, :no_convergence
end