# Launching a trigger after UP to run Ruby code

**URL:** <https://discuss.hashicorp.com/t/launching-a-trigger-after-up-to-run-ruby-code/28293>\
**Category:** Vagrant\
**Created:** [August 16, 2021, 6:45pm UTC](https://discuss.hashicorp.com/t/launching-a-trigger-after-up-to-run-ruby-code/28293 "2021-08-16T18:45:50Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![amsou](https://sea2.discourse-cdn.com/hashicorp/user_avatar/discuss.hashicorp.com/amsou/32/15999_2.png) [@amsou](https://discuss.hashicorp.com/u/amsou)\
**Post date:** [August 16, 2021, 6:45pm UTC](https://discuss.hashicorp.com/t/launching-a-trigger-after-up-to-run-ruby-code/28293/1 "2021-08-16T18:45:50Z")

</div>

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.

```auto
IMPORTANT_VALUE = "xxx"

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

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

  # 
  config1.vm.define "db" do |db|
    db.vm.hostname = "db"
    db.vm.network :private_network, ip: "10.0.0.10"
    ...
    db.vm.provision "shell", path: "install-db.sh"
  end

  # 
  config1.vm.define "web" do |web|
    web.vm.hostname = "web"
    web.vm.network :private_network, ip: "10.0.0.11"
    ...
    web.vm.provision "shell", path: "install-web.sh"
  end
end

Vagrant.configure("2") do |config2|
  config2.vm.define "client" do |client|
    client.vm.box = "..."
    client.vm.hostname = "client"
    client.vm.network :private_network, ip: "10.0.0.100"
    ...
    client.vm.provision "shell", path: "install-client.sh"
  end  
end

```

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.

```auto
 config1.trigger.after :up do|config1Trigger|
   config1Trigger.name ="save_important_value"
   config1Trigger.info ="running after vagrant up"
   config1Trigger.execute_ruby(save_important_value)
 end

```

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:

> <https://github.com/hashicorp/vagrant/commit/5daa25db806f15e8150e57f5c9292c56cc2f5e95>
>
> Fixes #9840: Introduce \`ruby\` option for trigger

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

```auto
    client.vm.network :private_network, ip: "10.0.0.100"

```

And some like this:

```auto
    client.vm.network "private_network", ip: "10.0.0.100"

```

I was wondering what is the difference.

Regards,
