# -*- mode: ruby -*-
# vi: set ft=ruby :
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/bionic64"
config.trigger.before [:up, :provision] do |trigger|
trigger.ruby do |env, machine|
var_derived_in_ruby_trigger = "hi"
end
end
config.vm.provision "read_var_from_trigger",
type: "shell",
privileged: false,
inline: "echo '[#{var_derived_in_ruby_trigger}']"
end
Output:
$ vagrant up
Vagrant failed to initialize at a very early stage:There was an error loading a Vagrantfile. The file being loadedand the error message are shown below. This is usually caused byan invalid or undefined variable.Path: /Users/jjackson/eclipse-workspace/simplevagrant/VagrantfileLine number: 20Message: undefined local variable or method `var_derived_in_ruby_trigger
How would I set a variable in a trigger if I wanted it to be available in a provisioner?
--
This mailing list is governed under the HashiCorp Community Guidelines - https://www.hashicorp.com/community-guidelines.html. Behavior in violation of those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups "Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email to vagrant-up+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CA%2BonWPdK4sZddU_AeiL3F1jWk2%2Bhfgu%2BDY0JawZnnRvj8dzQoA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/vagrant-up/CADHESCVnCjJZHtt51k%3D%2BY9JsrkjeUJRUugiPEi7c2Z_pphhpDQ%40mail.gmail.com.