From a0efe049dd67176764fcb8dd60e62735862d889e Mon Sep 17 00:00:00 2001 From: "Z. Cliffe Schreuders" Date: Fri, 26 Oct 2018 14:08:53 +0100 Subject: [PATCH] networking --- lib/templates/Vagrantfile.erb | 20 +++++--------------- 1 file changed, 5 insertions(+), 15 deletions(-) diff --git a/lib/templates/Vagrantfile.erb b/lib/templates/Vagrantfile.erb index f49c126c7..98c4f2f07 100644 --- a/lib/templates/Vagrantfile.erb +++ b/lib/templates/Vagrantfile.erb @@ -108,9 +108,9 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| <%= selected_module.to_s_comment -%> <% if selected_module.module_type == 'network' and selected_module.received_inputs.include? 'IP_address' %> -<%= ' # This module has a datastore entry for IP_address, using that instead of the default.' -%> +<%= ' # This module has a datastore entry for IP_address, using that instead of the default.' %> <% elsif selected_module.module_type == 'network' and @options.has_key? :ip_ranges -%> -<%= ' # This module has a command line ip_range, using that instead of the default.' -%> +<%= ' # This module has a command line ip_range, using that instead of the default.' %> <% end -%> <% case selected_module.module_type when 'base' -%> @@ -139,20 +139,10 @@ Vagrant.configure(VAGRANTFILE_API_VERSION) do |config| <% # Static networking -%> <% else -%> <% # Static oVirt networking -%> -<% # TODO: instead use some shell scripting to identify the name of the network interface (eth0/ens3/...) -%> <% if (@options.has_key? :ovirtuser) && (@options.has_key? :ovirtpass) -%> -<% if @ovirt_template and (@ovirt_template.include? 'kali_linux_msf' or @ovirt_template.include? 'debian_server' )%> - <%= system.name %>.vm.provision 'shell', inline: "echo \"auto lo\niface lo inet loopback\n\nauto eth0\niface eth0 inet static\n\taddress <%= resolve_network(selected_module)%>\" > /etc/network/interfaces" - <%= system.name %>.vm.provision 'shell', inline: "echo '' > /etc/environment" -<% elsif @ovirt_template and @ovirt_template.include? 'debian_desktop_kde' %> - <%= system.name %>.vm.provision 'shell', inline: "echo \"\nauto eth1\niface eth1 inet static\n\taddress <%= resolve_network(selected_module)%>\" >> /etc/network/interfaces" - <%= system.name %>.vm.provision 'shell', inline: "echo '' > /etc/environment" -<% elsif @ovirt_template and ( @ovirt_template.include? 'debian_stretch_server' or @ovirt_template.include? 'debian_stretch_desktop_kde') %> - <%= system.name %>.vm.provision 'shell', inline: "echo \"\nauto ens3\niface ens3 inet static\n\taddress <%= resolve_network(selected_module)%>\" > /etc/network/interfaces" - <%= system.name %>.vm.provision 'shell', inline: "echo '' > /etc/environment" -<% else -%> - <%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, :ovirt__ip => "<%= resolve_network(selected_module)%>", :ovirt__network_name => '<%= get_ovirt_network_name(system.name, @options[:ovirtnetwork]) %>' -<% end -%> + # use some shell scripting to identify the name of the network interface (eth0/ens3/...), and set the IP address statically + <%= system.name %>.vm.provision 'shell', inline: "interface=`ip -o link show | awk '{print $2}' | grep '\(eno\|eth\|ens\)[0-9]\+' -o`; echo -e \"auto lo\niface lo inet loopback\n\nauto $interface\niface $interface inet static\n\taddress <%= resolve_network(selected_module)%>\" > /etc/network/interfaces" + <%= system.name %>.vm.provision 'shell', inline: "echo '' > /etc/environment" <% # Static Virtualbox networking -%> <% else -%> <%= system.name %>.vm.network :<%= selected_module.attributes['type'].first %>, ip: "<%= resolve_network(selected_module)%>"