I tried to do the following:

     CFG_IP="$LIST_IPS".split(",") or CFG_IP="$LIST_IPS".split(" ")

Neither worked and added a debug to understand

DEBUG create_networks: In config found network type private_network options 
{:ip=>"$LIST_IPS", :protocol=>"tcp", 
:id=>"49129a87-dcdd-4539-a898-e2ef8b2bed38"}

Dont think the substitution worked as I had expected.

On Tuesday, February 6, 2018 at 12:15:05 AM UTC+5:30, Shashank Korada wrote:
>
> Thank you Alvaro. This certainly helps but since I am exporting a space 
> separated(or comma separated) variable of IP addresses can I perform 
> operations on the env var in the vagrantfile for it to become a list that u 
> mentioned
>
> export LIST_IP="10.10.10.10 10.10.10.11"
>
> in Vagrantfile:
> CFG_IP=$LIST_IP (some action on LIST_IP)
>
> How can I perform some operation on the var LIST_IP in the vagrant file so 
> that CFG_IP becomes ["10.10.10.10", "10.10.10.11"] so that its usable like 
> the way you defined.
>
> Regards,
>
>
>
> On Monday, February 5, 2018 at 4:14:18 AM UTC+5:30, Alvaro Miranda 
> Aguilera wrote:
>>
>> you can use:
>>
>> ["192.168.11.11", "192.168.12.12"].to_enum.with_index(1).each do |ip, i|
>>
>> then you can use the ip and/or the index/counter i
>>
>> On Sun, Feb 4, 2018 at 10:39 PM, Shashank Korada <shashan...@gmail.com> 
>> wrote:
>>
>>> 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 vagrant-up+...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/vagrant-up/8af38eae-0606-4f40-ad09-22b2a04c39b3%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/vagrant-up/8af38eae-0606-4f40-ad09-22b2a04c39b3%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>>
>> -- 
>> Alvaro
>>
>>

-- 
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 vagrant-up+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/vagrant-up/e64492c2-0ad3-4b0a-bb31-1746580c7aa8%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to