Skip to content

Commit

Permalink
Do not return an error if ifdown fails
Browse files Browse the repository at this point in the history
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
  • Loading branch information
sethvargo committed Mar 20, 2016
1 parent fa19783 commit 0505771
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion plugins/guests/debian/cap/configure_networks.rb
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,10 @@ def self.configure_networks(machine, networks)
# 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

Expand Down

5 comments on commit 0505771

@bdwyertech
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@geerlingguy
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍 here too—hopefully this is in a release soon, as for now, I have to manually add in an eth1 declaration in /etc/network/interfaces in my Packer build for Ubuntu Xenial 16.04, which is then overridden by Vagrant.

@midikem
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mitchellh When will this be in an release?

@taylorotwell
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Need a fix for this.

@gretel
Copy link

@gretel gretel commented on 0505771 May 10, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

release please.

Please sign in to comment.