1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
|
<h1 id="configuration"> Configuration </h1> <p>Vagrant Triggers has a few options to define trigger behavior.</p> <h2 id="options"> Options </h2> <p>The trigger class takes various options.</p> <ul> <li>
<p><a href="#action"><code>action</code></a> (symbol, array) - Expected to be a single symbol value, an array of symbols, or a <em>splat</em> of symbols. The first argument that comes after either <strong>before</strong> or <strong>after</strong> when defining a new trigger. Can be any valid Vagrant command. It also accepts a special value <code>:all</code> which will make the trigger fire for every action. An action can be ignored with the <code>ignore</code> setting if desired. These are the valid action commands for triggers:</p> <ul> <li>
<a href="#destroy"><code>destroy</code></a> </li> <li>
<a href="#halt"><code>halt</code></a> </li> <li>
<a href="#provision"><code>provision</code></a> </li> <li>
<a href="#reload"><code>reload</code></a> </li> <li>
<a href="#resume"><code>resume</code></a> </li> <li>
<a href="#suspend"><code>suspend</code></a> </li> <li>
<a href="#up"><code>up</code></a> </li> </ul> </li> <li>
<p><a href="#ignore"><code>ignore</code></a> (symbol, array) - Symbol or array of symbols corresponding to the action that a trigger should not fire on.</p> </li> <li>
<p><a href="#info"><code>info</code></a> (string) - A message that will be printed at the beginning of a trigger.</p> </li> <li>
<p><a href="#name"><code>name</code></a> (string) - The name of the trigger. If set, the name will be displayed when firing the trigger.</p> </li> <li>
<p><a href="#on_error"><code>on_error</code></a> (symbol) - Defines how the trigger should behave if it encounters an error. By default this will be <code>:halt</code>, but can be configured to ignore failures and continue on with <code>:continue</code>.</p> </li> <li>
<p><a href="#only_on"><code>only_on</code></a> (string, regex, array) - Limit the trigger to these guests. Values can be a string or regex that matches a guest name.</p> </li> <li>
<p><a href="#ruby"><code>ruby</code></a> (block) - A block of Ruby code to be executed on the host. The block accepts two arguments that can be used with your Ruby code: <code>env</code> and <code>machine</code>. These options correspond to the Vagrant environment used (note: these are not your shell's environment variables), and the Vagrant guest machine that the trigger is firing on. This option can only be a <code>Proc</code> type, which must be explicitly called out when using the hash syntax for a trigger.</p> <div class="highlight"><pre class="highlight ruby" data-language="ruby">ubuntu.trigger.after :up do |trigger|
trigger.info = "More information"
trigger.ruby do |env,machine|
greetings = "hello there #{machine.id}!"
puts greetings
end
end
</pre></div>
</li> <li>
<p><a href="#run_remote"><code>run_remote</code></a> (hash) - A collection of settings to run a inline or remote script with on the guest. These settings correspond to the <a href="../provisioning/shell">shell provisioner</a>.</p> </li> <li>
<p><a href="#run"><code>run</code></a> (hash) - A collection of settings to run a inline or remote script on the host. These settings correspond to the <a href="../provisioning/shell">shell provisioner</a>. However, at the moment the only settings <code>run</code> takes advantage of are:</p> <ul> <li>
<a href="#args"><code>args</code></a> </li> <li>
<a href="#inline"><code>inline</code></a> </li> <li>
<a href="#path"><code>path</code></a> </li> </ul> </li> <li>
<p><a href="#warn"><code>warn</code></a> (string) - A warning message that will be printed at the beginning of a trigger.</p> </li> <li>
<p><a href="#exit_codes"><code>exit_codes</code></a> (integer, array) - A set of acceptable exit codes to continue on. Defaults to <code>0</code> if option is absent. For now only valid with the <code>run</code> option.</p> </li> <li>
<p><a href="#abort"><code>abort</code></a> (integer,boolean) - An option that will exit the running Vagrant process once the trigger fires. If set to <code>true</code>, Vagrant will use exit code 1. Otherwise, an integer can be provided and Vagrant will it as its exit code when aborting.</p> </li> </ul><div class="_attribution">
<p class="_attribution-p">
© 2010–2018 Mitchell Hashimoto<br>Licensed under the MPL 2.0 License.<br>
<a href="https://www.vagrantup.com/docs/triggers/configuration.html" class="_attribution-link">https://www.vagrantup.com/docs/triggers/configuration.html</a>
</p>
</div>
|