Turns out I cant be exporting an array in bash.
So I now want to export a variable with space separated IPs
ARR_IP="10.20.20.10 10.20.20.11 10.20.20.12"
Is there a way to break this up in the Vagrantfile? Some sort of operations?
On Monday, February 5, 2018 at 2:22:47 AM UTC+5:30, Shashank Korada wrote:
>
> 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
>
>
>
--
This mailing list is governed under the HashiCorp Community Guidelines -
https://www.hashicorp.com/community-guidelines.html. Behavior in violation of
those guidelines may result in your removal from this mailing list.
GitHub Issues: https://github.com/mitchellh/vagrant/issues
IRC: #vagrant on Freenode
---
You received this message because you are subscribed to the Google Groups
"Vagrant" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/vagrant-up/8af38eae-0606-4f40-ad09-22b2a04c39b3%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.