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.
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.
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:
Also, I have noticed while browsing the internet many examples… I noticed that some code is written like this:
client.vm.network :private_network, ip: "10.0.0.100"
And some like this:
client.vm.network "private_network", ip: "10.0.0.100"
I was wondering what is the difference.
Regards,