How would I set a variable in a trigger if I wanted it to be available in a
provisioner?

Here's a quick (failing) test case:


# -*- 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 loaded
and the error message are shown below. This is usually caused by
an invalid or undefined variable.

Path: /Users/jjackson/eclipse-workspace/simplevagrant/Vagrantfile
Line number: 20
Message: undefined local variable or method `var_derived_in_ruby_trigger


Thanks,
Jamie

-- 
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 [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vagrant-up/CA%2BonWPdK4sZddU_AeiL3F1jWk2%2Bhfgu%2BDY0JawZnnRvj8dzQoA%40mail.gmail.com.

Reply via email to