--- layout: docs page_title: Vagrant Triggers Configuration description: Documentation of various configuration options for Vagrant Triggers --- # Configuration Vagrant Triggers has a few options to define trigger behavior. ## Execution Order The trigger config block takes two different operations that determine when a trigger should fire: - `before` - `after` These define _how_ the trigger behaves and when it should fire off during the Vagrant life cycle. A simple example of a _before_ operation could look like: ```ruby config.trigger.before :up do |t| t.info = "Bringing up your Vagrant guest machine!" end ``` Triggers can also be used with [_commands_](#commands), [_actions_](#actions), or [_hooks_](#hooks). By default triggers will be defined to run before or after a Vagrant guest. For more detailed examples of how to use triggers, check out the [usage section](/vagrant/docs/triggers/usage). ## Trigger Options The trigger class takes various options. - `action` (symbol, array) - Expected to be a single symbol value, an array of symbols, or a _splat_ of symbols. The first argument that comes after either **before** or **after** when defining a new trigger. Can be any valid Vagrant command. It also accepts a special value `:all` which will make the trigger fire for every action. An action can be ignored with the `ignore` setting if desired. These are the valid action commands for triggers: - `destroy` - `halt` - `provision` - `reload` - `resume` - `suspend` - `up` - `ignore` (symbol, array) - Symbol or array of symbols corresponding to the action that a trigger should not fire on. - `info` (string) - A message that will be printed at the beginning of a trigger. - `name` (string) - The name of the trigger. If set, the name will be displayed when firing the trigger. - `on_error` (symbol) - Defines how the trigger should behave if it encounters an error. By default this will be `:halt`, but can be configured to ignore failures and continue on with `:continue`. - `only_on` (string, regex, array) - Limit the trigger to these guests. Values can be a string or regex that matches a guest name. - `ruby` (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: `env` and `machine`. 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 `Proc` type, which must be explicitly called out when using the hash syntax for a trigger. ```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 ``` - `run_remote` (hash) - A collection of settings to run a inline or remote script with on the guest. These settings correspond to the [shell provisioner](/vagrant/docs/provisioning/shell). - `run` (hash) - A collection of settings to run a inline or remote script on the host. These settings correspond to the [shell provisioner](/vagrant/docs/provisioning/shell). However, at the moment the only settings `run` takes advantage of are: - `args` - `inline` - `path` **Note:** The `run` option with `inline` is not entirely like a shell provisioner that runs bash. It executes binaries on your machine rather than a bash script. For example: If you wish you use bash to pipe some text to a file in your `run` option with `inline`, wrap your inline script with _`bash -c "