Question

I have a Vagrant file that defines a provisioner like this:

config.vm.provision :shell, :path => "set_rmi_hostname.sh", :args => "<ip_address> <target>"

ip_address and target are ruby variables defined in the same file:

ip = Socket.ip_address_list.detect{|intf| intf.ipv4_private?}
ip_address = ip.ip_address if ip
target = "my_target"

How can I expand these two variables and pass them to my script? Thanks

Was it helpful?

Solution

Use #{variable} to use string expansion in Ruby:

config.vm.provision :shell, :path => "set_rmi_hostname.sh", :args => "#{ip_address} #{target}"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top