我正在尝试使用以下Vagrantfile(下面的摘录)从centos / 7框创建一个两个VM:
config.vm.define "buildmaster" do |d|
d.vm.hostname = "buildmaster"
d.vm.network "private_network", ip: "10.217.65.200"
d.vm.provision :shell, path: "scripts/install_ansible.sh"
d.vm.provider "virtualbox" do |v|
v.name = "buildmaster"
end
end
config.vm.define "vm#{1}" do |d|
d.vm.hostname = "vm#{1}"
d.vm.network "private_network", ip: "10.217.65.125"
d.vm.provider "virtualbox" do |v|
v.name = "vm#{1}"
end
end
第一个VM获取分配的IP,我可以看到:
ip addr show
[vagrant@buildmaster ~]$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:c3:c0:db brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
valid_lft 78309sec preferred_lft 78309sec
inet6 fe80::5054:ff:fec3:c0db/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:b5:1f:48 brd ff:ff:ff:ff:ff:ff
inet 10.217.65.200/24 brd 10.217.65.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:feb5:1f48/64 scope link
valid_lft forever preferred_lft forever
然而,第二个没有获得分配的IP。我尝试了不同的IP和传递IP的方法,作为字符串,来自带有字符串值的向量等。
[vagrant@vm1 ~]$ ip addr show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 52:54:00:c3:c0:db brd ff:ff:ff:ff:ff:ff
inet 10.0.2.15/24 brd 10.0.2.255 scope global dynamic eth0
valid_lft 86367sec preferred_lft 86367sec
inet6 fe80::5054:ff:fec3:c0db/64 scope link
valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:33:93:fa brd ff:ff:ff:ff:ff:ff
inet6 fe80::a00:27ff:fe33:93fa/64 scope link
valid_lft forever preferred_lft forever
其他人遇到此问题并找到了解决方案吗?
答案 0 :(得分:0)
对于遇到同样问题的人。这是基于Vagrant和CentOS的盒子的问题,也是原子主机。
我在这里报告了这个问题:https://github.com/mitchellh/vagrant/issues/7711虽然它说它已修复,但这不是我最近使用Vagrant 1.9.0的经验。当使用CentOS或Atomic Host时,我仍然需要将它添加到Vagrant文件中:
# Restart networking as a workaround for configured ip not showing up
$network_workaround = <<-NETWORK_WORKAROUND
rm /etc/sysconfig/network-scripts/ifcfg-eth0
systemctl restart network
NETWORK_WORKAROUND
config.vm.provision "network_workaround", type: "shell", privileged: true, inline: $network_workaround
希望这有帮助。