Merge pull request #9889 from treytabner/debian-systemd-networkd

Increase priority and support multiple networks for Debian with systemd-networkd
This commit is contained in:
Chris Roberts 2018-07-19 14:13:46 -07:00 committed by GitHub
commit 4d4e707b73
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 10 deletions

View File

@ -82,11 +82,10 @@ module VagrantPlugins
# Configure guest networking using networkd
def self.configure_networkd(machine, interfaces, comm, networks)
net_conf = []
root_device = interfaces.first
networks.each do |network|
dev_name = interfaces[network[:interface]]
net_conf = []
net_conf << "[Match]"
net_conf << "Name=#{dev_name}"
net_conf << "[Network]"
@ -106,15 +105,16 @@ module VagrantPlugins
else
net_conf << "DHCP=yes"
end
remote_path = upload_tmp_file(comm, net_conf.join("\n"))
dest_path = "#{NETWORKD_DIRECTORY}/50-vagrant-#{dev_name}.network"
comm.sudo(["mkdir -p #{NETWORKD_DIRECTORY}",
"mv -f '#{remote_path}' '#{dest_path}'",
"chown root:root '#{dest_path}'",
"chmod 0644 '#{dest_path}'"].join("\n"))
end
remote_path = upload_tmp_file(comm, net_conf.join("\n"))
dest_path = "#{NETWORKD_DIRECTORY}/50-vagrant.network"
comm.sudo(["mkdir -p #{NETWORKD_DIRECTORY}",
"mv -f '#{remote_path}' '#{dest_path}'",
"chown root:root '#{dest_path}'",
"chmod 0644 '#{dest_path}'",
"systemctl restart systemd-networkd.service"].join("\n"))
comm.sudo(["systemctl restart systemd-networkd.service"].join("\n"))
end
# Configure guest networking using net-tools

View File

@ -111,7 +111,7 @@ describe "VagrantPlugins::GuestDebian::Cap::ConfigureNetworks" do
expect(comm.received_commands[0]).to match("mv -f '/tmp/vagrant-network-entry.*' '/etc/systemd/network/.*network'")
expect(comm.received_commands[0]).to match("chown")
expect(comm.received_commands[0]).to match("chmod")
expect(comm.received_commands[0]).to match("systemctl restart")
expect(comm.received_commands[2]).to match("systemctl restart")
end
end