Skip to content

Commit

Permalink
vagrant: workaround to fix private network ip address in fedora
Browse files Browse the repository at this point in the history
Fedora stop supporting syconfig network script so we added a workaround
here
hashicorp/vagrant#12762 (comment)
to fix it.
  • Loading branch information
MrFreezeex committed Aug 1, 2023
1 parent 93e788d commit 7ca5d71
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ if File.exist?(CONFIG)
end

# Defaults for config options defined in CONFIG
$num_instances ||= 3
$num_instances ||= 1
$instance_name_prefix ||= "k8s"
$vm_gui ||= false
$vm_memory ||= 2048
Expand All @@ -52,7 +52,7 @@ $shared_folders ||= {}
$forwarded_ports ||= {}
$subnet ||= "172.18.8"
$subnet_ipv6 ||= "fd3c:b398:0698:0756"
$os ||= "ubuntu2004"
$os ||= "fedora37"
$network_plugin ||= "flannel"
# Setting multi_networking to true will install Multus: https://github.com/k8snetworkplumbingwg/multus-cni
$multi_networking ||= "False"
Expand Down Expand Up @@ -207,7 +207,8 @@ Vagrant.configure("2") do |config|
end

ip = "#{$subnet}.#{i+100}"
node.vm.network :private_network, ip: ip,
node.vm.network :private_network,
:ip => ip,
:libvirt__guest_ipv6 => 'yes',
:libvirt__ipv6_address => "#{$subnet_ipv6}::#{i+100}",
:libvirt__ipv6_prefix => "64",
Expand All @@ -222,6 +223,14 @@ Vagrant.configure("2") do |config|
node.vm.provision "shell", inline: "rm -f /etc/modprobe.d/local.conf"
node.vm.provision "shell", inline: "sed -i '/net.ipv6.conf.all.disable_ipv6/d' /etc/sysctl.d/99-sysctl.conf /etc/sysctl.conf"
end
# Hack for fedora37/38 to get the IP address of the second interface
if ["fedora37", "fedora38"].include? $os
config.vm.provision "shell", inline: <<-SHELL
nmcli conn modify 'Wired connection 2' ipv4.addresses $(cat /etc/sysconfig/network-scripts/ifcfg-eth1 | grep IPADDR | cut -d "=" -f2)
nmcli conn modify 'Wired connection 2' ipv4.method manual
service NetworkManager restart
SHELL
end

# Disable firewalld on oraclelinux/redhat vms
if ["oraclelinux","oraclelinux8","rhel7","rhel8","rockylinux8"].include? $os
Expand Down

0 comments on commit 7ca5d71

Please sign in to comment.