Merge pull request #10067 from pleycpl/patch-1

Colorize ruby commands
This commit is contained in:
Brian Cain 2018-07-30 08:59:24 -07:00 committed by GitHub
commit 66bd13732c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 34 additions and 22 deletions

View File

@ -99,7 +99,7 @@ Within the definition, a plugin advertises what components it adds to
Vagrant. An example is shown below where a command and provisioner are
added:
```
```ruby
class MyPlugin < Vagrant.plugin("2")
name "My Plugin"

View File

@ -58,7 +58,7 @@ Communication channels to the machine are guaranteed to be running at this
point, so the most common way to detect the operating system is to do
some basic testing:
```
```ruby
class MyGuest < Vagrant.plugin("2", "guest")
def detect?(machine)
machine.communicate.test("cat /etc/myos-release")

View File

@ -55,7 +55,7 @@ process to determine if the OS that Vagrant is running on is this host.
If you detect that it is your operating system, return `true` from `detect?`.
Otherwise, return `false`.
```
```ruby
class MyHost < Vagrant.plugin("2", "host")
def detect?(environment)
File.file?("/etc/arch-release")

View File

@ -176,7 +176,7 @@ Provider-specific configuration is a special case of a normal
configuration component, name the configuration the same as the provider,
and as a second parameter, specify `:provider`, like so:
```
```ruby
config("my_cloud", :provider) do
require_relative "config"
Config
@ -188,7 +188,7 @@ parameter is given, Vagrant will automatically expose this as provider-specific
configuration for your provider. Users can now do the following in their
Vagrantfiles:
```
```ruby
config.vm.provider :my_cloud do |config|
# Your specific configuration!
end

View File

@ -69,7 +69,7 @@ be overridden only for that provider.
Example:
```
```ruby
Vagrant.configure("2") do |config|
config.vm.box = "precise64"

View File

@ -136,13 +136,13 @@ If you really need to use this connection mode though, it is possible to enable
With auto-generated inventory:
```
```ruby
ansible.raw_arguments = ["--connection=paramiko"]
```
With a custom inventory, the private key must be specified (e.g. via an `ansible.cfg` configuration file, `--private-key` argument, or as part of your inventory file):
```
```ruby
ansible.inventory_path = "./my-inventory"
ansible.raw_arguments = [
"--connection=paramiko",

View File

@ -170,7 +170,7 @@ to Chef Solo. This is done by setting the `json` property with a Ruby
hash (dictionary-like object), which is converted to JSON and passed
in to Chef:
```
```ruby
Vagrant.configure("2") do |config|
config.vm.provision "chef_solo" do |chef|
# ...

View File

@ -19,11 +19,13 @@ File provisioning is a simple way to, for example, replicate your local
you will not have to run `git config --global` every time you provision a
new VM.
Vagrant.configure("2") do |config|
# ... other configuration
```ruby
Vagrant.configure("2") do |config|
# ... other configuration
config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
end
config.vm.provision "file", source: "~/.gitconfig", destination: ".gitconfig"
end
```
If you want to upload a folder to your guest system, it can be accomplished by
using a file provisioner seen below. When copied, the resulting folder on the guest will
@ -31,11 +33,13 @@ replace `folder` as `newfolder` and place its on the guest machine. Note that if
you'd like the same folder name on your guest machine, make sure that the destination
path has the same name as the folder on your host.
Vagrant.configure("2") do |config|
# ... other configuration
```ruby
Vagrant.configure("2") do |config|
# ... other configuration
config.vm.provision "file", source: "~/path/to/host/folder", destination: "$HOME/remote/newfolder"
end
config.vm.provision "file", source: "~/path/to/host/folder", destination: "$HOME/remote/newfolder"
end
```
Prior to copying `~/path/to/host/folder` to the guest machine:
@ -93,7 +97,9 @@ lead to some confusing results due to the underlying tool used to copy files and
folders between the host and guests. For example, if you have a source and
destination with a trailing slash defined below:
config.vm.provision "file", source: "~/pathfolder", destination: "/remote/newlocation/"
```ruby
config.vm.provision "file", source: "~/pathfolder", destination: "/remote/newlocation/"
```
You are telling vagrant to upload `~/pathfolder` under the remote dir `/remote/newlocation`,
which will look like:
@ -106,15 +112,21 @@ which will look like:
This behavior can also be achieved by defining your file provisioner below:
config.vm.provision "file", source: "~/pathfolder", destination: "/remote/newlocation/pathfolder"
```ruby
config.vm.provision "file", source: "~/pathfolder", destination: "/remote/newlocation/pathfolder"
```
Another example is using globing on the host machine to grab all files within a
folder, but not the top level folder itself:
config.vm.provision "file", source: "~/otherfolder/.", destination: "/remote/otherlocation"
```ruby
config.vm.provision "file", source: "~/otherfolder/.", destination: "/remote/otherlocation"
```
The file provisioner is defined to include all files under `~/otherfolder`
to the new location `/remote/otherlocation`. This idea can be achieved by simply
having your destination folder differ from the source folder:
config.vm.provision "file", source: "/otherfolder", destination: "/remote/otherlocation"
```ruby
config.vm.provision "file", source: "/otherfolder", destination: "/remote/otherlocation"
```

View File

@ -22,7 +22,7 @@ you want to have a UI. Common use cases include wanting to see a browser
that may be running in the machine, or debugging a strange boot issue.
You can easily tell the VirtualBox provider to boot with a GUI:
```
```ruby
config.vm.provider "virtualbox" do |v|
v.gui = true
end