website/docs: update docs for new provisioner style
This commit is contained in:
parent
6ea8dc8e20
commit
ee0423b792
|
@ -11,7 +11,8 @@ points common to all provisioners that are important to know.
|
||||||
|
|
||||||
## Configuration
|
## Configuration
|
||||||
|
|
||||||
First, every provisioner is configured within your [Vagrantfile](/v2/vagrantfile/index.html)
|
First, every provisioner is configured within your
|
||||||
|
[Vagrantfile](/v2/vagrantfile/index.html)
|
||||||
using the `config.vm.provision` method call. For example, the Vagrantfile
|
using the `config.vm.provision` method call. For example, the Vagrantfile
|
||||||
below enables shell provisioning:
|
below enables shell provisioning:
|
||||||
|
|
||||||
|
@ -44,6 +45,24 @@ it can greatly improve readability. Additionally, some provisioners, like
|
||||||
the Chef provisioner, have special methods that can be called within that
|
the Chef provisioner, have special methods that can be called within that
|
||||||
block to ease configuration that can't be done with the key/value approach.
|
block to ease configuration that can't be done with the key/value approach.
|
||||||
|
|
||||||
|
Provisioners can also be named. These names are used cosmetically for output
|
||||||
|
as well as overriding provisioner settings (covered further below). An example
|
||||||
|
of naming provisioners is shown below:
|
||||||
|
|
||||||
|
```ruby
|
||||||
|
Vagrant.configure("2") do |config|
|
||||||
|
# ... other configuration
|
||||||
|
|
||||||
|
config.vm.provision "bootstrap", type: "shell" do |s|
|
||||||
|
s.inline = "echo hello"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
```
|
||||||
|
|
||||||
|
Naming provisioners is simple. The first argument to `config.vm.provision`
|
||||||
|
becomes the name, and then a `type` option is used to specify the provisioner
|
||||||
|
type, such as `type: "shell"` above.
|
||||||
|
|
||||||
## Running Provisioners
|
## Running Provisioners
|
||||||
|
|
||||||
Provisioners are run in three cases: the initial `vagrant up`, `vagrant
|
Provisioners are run in three cases: the initial `vagrant up`, `vagrant
|
||||||
|
@ -57,6 +76,8 @@ The `--provision-with` flag can be used if you only want to run a
|
||||||
specific provisioner if you have multiple provisioners specified. For
|
specific provisioner if you have multiple provisioners specified. For
|
||||||
example, if you have a shell and Puppet provisioner and only want to
|
example, if you have a shell and Puppet provisioner and only want to
|
||||||
run the shell one, you can do `vagrant provision --provision-with shell`.
|
run the shell one, you can do `vagrant provision --provision-with shell`.
|
||||||
|
The arguments to `--provision-with` can be the provisioner type (such as
|
||||||
|
"shell") or the provisioner name (such as "bootstrap" from above).
|
||||||
|
|
||||||
## Run Once or Always
|
## Run Once or Always
|
||||||
|
|
||||||
|
@ -118,6 +139,9 @@ The ordering of the provisioners will be to echo "foo", "baz", then
|
||||||
"bar" (note the second one might not be what you expect!). Remember:
|
"bar" (note the second one might not be what you expect!). Remember:
|
||||||
ordering is _outside in_.
|
ordering is _outside in_.
|
||||||
|
|
||||||
|
With multiple provisioners, use the `--provision-with` setting along
|
||||||
|
with names to get more fine grainted control over what is run and when.
|
||||||
|
|
||||||
## Overriding Provisioner Settings
|
## Overriding Provisioner Settings
|
||||||
|
|
||||||
<div class="alert alert-block alert-warn">
|
<div class="alert alert-block alert-warn">
|
||||||
|
@ -135,17 +159,16 @@ you may want to define common provisioners in the global configuration
|
||||||
scope of a Vagrantfile, but override certain aspects of them internally.
|
scope of a Vagrantfile, but override certain aspects of them internally.
|
||||||
Vagrant allows you to do this, but has some details to consider.
|
Vagrant allows you to do this, but has some details to consider.
|
||||||
|
|
||||||
To override settings, you must assign an ID to your provisioner. Then
|
To override settings, you must assign a name to your provisioner.
|
||||||
it is only a matter of specifying the same ID to override:
|
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.vm.provision "shell",
|
config.vm.provision "foo", type: "shell",
|
||||||
inline: "echo foo", id: "foo"
|
inline: "echo foo"
|
||||||
|
|
||||||
config.vm.define "web" do |web|
|
config.vm.define "web" do |web|
|
||||||
web.vm.provision "shell",
|
web.vm.provision "foo", type: "shell",
|
||||||
inline: "echo bar", id: "foo"
|
inline: "echo bar"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
@ -162,14 +185,14 @@ below, the output would be "foo" then "bar":
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
Vagrant.configure("2") do |config|
|
Vagrant.configure("2") do |config|
|
||||||
config.vm.provision "shell",
|
config.vm.provision "foo", type: "shell",
|
||||||
inline: "echo ORIGINAL!", id: "foo"
|
inline: "echo ORIGINAL!"
|
||||||
|
|
||||||
config.vm.define "web" do |web|
|
config.vm.define "web" do |web|
|
||||||
web.vm.provision "shell",
|
web.vm.provision "shell",
|
||||||
inline: "echo foo"
|
inline: "echo foo"
|
||||||
web.vm.provision "shell",
|
web.vm.provision "foo", type: "shell",
|
||||||
inline: "echo bar", id: "foo"
|
inline: "echo bar"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
Loading…
Reference in New Issue