vvalgis/vagrant-babushka — pull request #12 by bradfeehan (2013-11-11 15:29:50+00:00)
Title: Refactor of Provisioner: new features, bug fixes (depends on #11)

This pull request includes a lot of new features, some bug fixes, and a large refactor of the main `Provisioner` class. **Note: this pull request depends on #11 being merged first**. If #11 is an undesirable change, please close that pull request and I will refactor this pull request to not require #11.

I've taken care to ensure not to break any features anybody is relying on (like dep sharing and HTTP proxy support), however I can't test with every possibility. If there are any issues after merging this pull request, I'd be happy to help anybody who has issues, with existing or new features.

**If this causes problems, open a GitHub issue and I'll help take care of it!**

## New Features

#### Add configuration options to set Babushka command-line arguments

The plugin now supports setting the values of any of Babushka's command-line arguments when meeting deps. The options include:

* `--color` / `--no-color`
* `--debug`
* `--dry-run`
* `--show-args`
* `--silent`
* `--update`

These options can be set for the meeting of all deps, but can also be overridden for the meeting of specific deps. For example:

```ruby
# ...
babushka.silent = true
babushka.update = true

babushka.meet 'my dep', :silent => false
babushka.meet 'another dep', :source => 'friend', :update => false
```

#### Allow specifying a full bootstrap URL

In addition to the existing ability to install Babushka from an alternative branch using `#bootstrap_branch`, now the entire bootstrap URL can be manually changed using `#bootstrap_url`. If `bootstrap_url` is set, that will take precedence over the `bootstrap_branch`.

## Bug fixes

* Fix the issue on installation/updating APT packages where the Babushka progress meter or spinner produce a lot of garbled output
* Escape all variables that are used in shell commands (this wasn't being done before for things like usernames, dep names, etc).
* Create the Babushka installation directory and set permissions before installing Babushka (some boxes come with /usr/local non-existent or not writeable)
* Find user's home directory more reliably, using tilde expansion instead of guessing that it will always be at /home/$USER
* Fix bug where the bootstrap script wouldn't download if the host didn't have cURL installed -- now the script is downloaded inside the virtual machine (cURL is installed manually before if missing, if the OS is Ubuntu; otherwise an error message is shown, instructing the user to install it manually or consider adding support to the plugin for other operating systems)
* Improvements to logging:
* Don't alter the colours in the output (can cause display issues)
* Show warning message when no deps have been specified to be met
* Set the default value for Babushka's colored output option, based on whether Vagrant is currently outputting coloured output or not
* Use machine name as scope for all logging

## Refactor of Provisioner

* Split large methods into smaller, more understandable methods
* Consider public/private visibility of methods (mainly for testing)
* Improve separation of concerns by ensuring the Provisioner does all the preparation of command strings etc.
* Use Ruby's Forwardable module to reduce boilerplate required to log a message or execute a command on the virtual machine