Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cleaner output when downloading files in a Vagrant provisioning script

Tags:

curl

vagrant

wget

I use Vagrant for quickly bringing up test environments, development servers, etc. A lot of my Vagrant setups use provisioning scripts to automate the download and configuration of various tools as necessary. However the "tricks" that command-line download utilities such as curl and wget use to generate their progress bars/status displays (backspacing to overwrite the current line of text to increment a progress bar, etc.) do not render well at all when run in a Vagrant provision script, and result in huge spews of junk such as the following that cause legitimate output to quickly scroll off.

==> default: #
==> default: #########
############                                                              16.7%
############                                                              16.7%
==> default: #
==> default: #
==> default: #
==> default: #
==> default: #
==> default: #
==> default: #
==> default: #
==> default: #
==> default: #
==> default: #
==> default: #
==> default:
==> default:
==> default:
############                                                              16.8%

Is there a way to "clean up" the output of either curl or wget to be neater, and not use the "backspace over current line to redraw it" tricks? I prefer wget but would switch to curl if necessary. Alternatively, is there another download tool with a simpler/neater output format that I could use instead? (preferably one available in Ubuntu's repository, as that is the distro I use with most of my Vagrant setups)

My current solution is to disable output entirely (using wget's --no-verbose or curl's -s) but this is not ideal as it results in long pauses where nothing is output during the vagrant build (some of the files that I download are rather large); it would be nice to at least have a simple "percent done" progress display, or even a simple line of "marching dots."

like image 620
Donald Burr Avatar asked Jun 27 '15 08:06

Donald Burr


People also ask

What does vagrant up -- provision do?

Provisioners in Vagrant allow you to automatically install software, alter configurations, and more on the machine as part of the vagrant up process. This is useful since boxes typically are not built perfectly for your use case.

What is the provision that used in vagrant by default?

By default, provisioners are only run once, during the first vagrant up since the last vagrant destroy , unless the --provision flag is set, as noted above.

Which of following can be used as Provisioner with vagrant?

5) What is Provisioner in Vagrant? A) A provisioner is a tool to set up the virtual environment, and can be as simple as a shell script, but alternatively a more advanced tool like Chef, Puppet, or Ansible can be used.

What is vagrant script?

An inline script is a script that is given to Vagrant directly within the Vagrantfile. An example is best: Vagrant.configure("2") do |config| config.vm.provision "shell", inline: "echo Hello, World" end. Vagrant.configure("2") do |config| config.vm.provision "shell", inline: "echo Hello, World" end.


1 Answers

I use wget with the --progress=bar:force option. While not ideal, this makes the outlook better. Without this option, wget defaults to the dot type progress bar, because it does not detect a terminal.

like image 145
fatlasercat Avatar answered Sep 30 '22 06:09

fatlasercat