Launching a trigger after UP to run Ruby code

Hello everyone,

I’m kind of new to vagrant and I was wondering if anyone could help with my issues? It’s no critical.

I have a file that looks like this; I’m trying to create a dev environment that consists of 3 machines. One db, one web server and the client workspace.


Vagrant.configure("2") do |config1|

  config1.vm.box_url = "..." = "..."

  config1.vm.define "db" do |db|
    db.vm.hostname = "db" :private_network, ip: ""
    db.vm.provision "shell", path: ""

  config1.vm.define "web" do |web|
    web.vm.hostname = "web" :private_network, ip: ""
    web.vm.provision "shell", path: ""

Vagrant.configure("2") do |config2|
  config2.vm.define "client" do |client| = "..."
    client.vm.hostname = "client" :private_network, ip: ""
    client.vm.provision "shell", path: ""

What I need to do is to store the IMPORTANT_VALUE (in this case, it’s a constant). In reality, it’s a random value used to encrypt something on the vms. That value needs to be stored in a file.

I wanted to create a trigger.

 config1.trigger.after :up do|config1Trigger| ="save_important_value" ="running after vagrant up"

In my case, I’d like to call a Ruby function save_important_value. It opens a file and write that value in it.

Any suggestions on why my trigger doesn’t work? I’ve seen the function exists here:

Also, I have noticed while browsing the internet many examples… I noticed that some code is written like this: :private_network, ip: ""

And some like this: "private_network", ip: ""

I was wondering what is the difference.