将 ruby​​ 变量传递给供应商 [英] Passing ruby variable to provisioner

查看:50
本文介绍了将 ruby​​ 变量传递给供应商的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 Vagrant 文件,它定义了这样的配置器:

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 和 target 是在同一个文件中定义的 ruby​​ 变量:

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

推荐答案

使用 #{variable} 在 Ruby 中使用字符串扩展:

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

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

这篇关于将 ruby​​ 变量传递给供应商的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆