Hi,
I am trying to write a Vagrantfile that spins up 'N' VMs with static IPs defined my me which are defined by an environment variable(array)
export ARR_IP=("10.20.20.10" "10.20.20.11" "10.20.20.12")
Vagrantfile:
CFG_NUM = 3
CFG_IP = "${ARR_IP[*]}"
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.ssh.forward_agent = true
(1..CFG_NUM).each do |i|
config.vm.define CFG_NAME+"#{i}" do |s|
s.vm.box = "ceph/ubuntu-xenial"
s.vm.hostname = CFG_NAME+"#{i}"
s.vm.network :private_network, ip: CFG_IP["#{i-1}"] ====> trying to iterate over IPs
s.vm.provider :libvirt do |v|
v.memory = 4094
v.cpus = 2
v.nested = true
end
end
end
end
This is throwing an error for me which says IP is nil
Error occurred while creating new network: {:iface_type=>:private_network, :netmask=>"255.255.255.0", :dhcp_enabled=>true, :forward_mode=>"nat", :ip=>nil, :protocol=>"tcp", :id=>"5d813bfc-2d27-49cf-8351-9948e73f9b66"}.
What is the correct way to substitute the array element here?
Regards