Merge pull request #7159 from mitchellh/sethvargo/down_ubuntu

Do not return an error if ifdown fails
This commit is contained in:
Seth Vargo 2016-03-31 17:01:13 +02:00
commit b2cd865a55
1 changed files with 4 additions and 1 deletions

View File

@ -42,7 +42,10 @@ module VagrantPlugins
# each specifically, we avoid reconfiguring eth0 (the NAT interface) so
# SSH never dies.
interfaces.each do |interface|
comm.sudo("/sbin/ifdown eth#{interface} 2> /dev/null")
# Ubuntu 16.04+ returns an error when downing an interface that
# does not exist. The `|| true` preserves the behavior that older
# Ubuntu versions exhibit and Vagrant expects (GH-7155)
comm.sudo("/sbin/ifdown eth#{interface} 2> /dev/null || true")
comm.sudo("/sbin/ip addr flush dev eth#{interface} 2> /dev/null")
end