From 0505771481222b4893daa5454ff6c9c16f471fa4 Mon Sep 17 00:00:00 2001 From: Seth Vargo Date: Sun, 20 Mar 2016 18:19:03 +0200 Subject: [PATCH] Do not return an error if ifdown fails Ubuntu versions prior to 16.04 always returned a successful exit status, even if one tried to down an interface that does not exist. This behavior changed in Ubuntu 16.04 to return an error. This commit preserves the old behavior. Fixes GH-7155 --- plugins/guests/debian/cap/configure_networks.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/plugins/guests/debian/cap/configure_networks.rb b/plugins/guests/debian/cap/configure_networks.rb index cf416ec09..0580bc293 100644 --- a/plugins/guests/debian/cap/configure_networks.rb +++ b/plugins/guests/debian/cap/configure_networks.rb @@ -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