我有两个流浪虚拟机,每个虚拟机都有自己的私有IP地址。我希望能够使用模板将虚拟机作为主厨配方中的服务器列表传递。
这是我的haproxy.cfg.erb没有默认和全局部分。我的每一个流浪的vms都在vagrant文件中定义了一个私有ip。如果我尝试卷曲loadbalacer的ip,则抛出503错误
答案 0 :(得分:0)
如果在vagrant VM中使用ifconfig可以看到分配的私有IP: -
[vagrant@default-centos ~]$ ifconfig
enp0s3: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.2.15 netmask 255.255.255.0 broadcast 10.0.2.255
inet6 fe80::a00:27ff:fec3:36f0 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:c3:36:f0 txqueuelen 1000 (Ethernet)
RX packets 37365 bytes 48794691 (46.5 MiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 6475 bytes 549951 (537.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
enp0s8: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 192.168.13.101 netmask 255.255.255.0 broadcast 192.168.13.255
inet6 fe80::a00:27ff:fe1a:2ec5 prefixlen 64 scopeid 0x20<link>
ether 08:00:27:1a:2e:c5 txqueuelen 1000 (Ethernet)
RX packets 17 bytes 1948 (1.9 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 35 bytes 5197 (5.0 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0
然后OHAI可以访问指定的私人ipaddress,例如: -
node[:network][:interfaces][:enp0s8][:addresses].detect{|k,v| v[:family] == "inet" }.first