oracle / vagrant-projects

Vagrant projects for Oracle products and other examples
Universal Permissive License v1.0
930 stars 474 forks source link

Vagrant OL9 Box: Unable to set private_network static IP #442

Closed hussam-qasem closed 1 year ago

hussam-qasem commented 1 year ago

Dear Philippe @AmedeeBulle,

I am unable to set a private_network / Static IP with the Oracle Linux 9 boxes:

Using the Vagrantfile:

Vagrant.configure("2") do |config|
  config.vm.box = "oraclelinux/9"
  config.vm.box_url = "https://oracle.github.io/vagrant-projects/boxes/oraclelinux/9.json"
  config.vm.network "private_network", ip: "192.168.56.4"
end

When running vagrant up, I get the error:

==> default: Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/sbin/ifdown ''
mv -f '/tmp/vagrant-network-entry--1661417989-0' '/etc/sysconfig/network-scripts/ifcfg-'
(test -f /etc/init.d/NetworkManager && /etc/init.d/NetworkManager restart) || ((systemctl | grep NetworkManager.service) && systemctl restart NetworkManager)
/sbin/ifup ''

Stdout from the command:

  NetworkManager.service                                                                   loaded active running   Network Manager

Stderr from the command:

bash: line 4: /sbin/ifdown: No such file or directory
bash: line 7: /sbin/ifup: No such file or directory

I am not sure if NetworkManager-initscripts-updown needs to be part of the OL9 box. (It's not part of the OL8 box, and OL8 works fine)

hussam-qasem commented 1 year ago

I tried adding NetworkManager-initscripts-updown to the base box, but that didn't solve the problem (just realized interface name appears empty?):

==> default: Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!

/sbin/ifdown ''
mv -f '/tmp/vagrant-network-entry--1661511789-0' '/etc/sysconfig/network-scripts/ifcfg-'
(test -f /etc/init.d/NetworkManager && /etc/init.d/NetworkManager restart) || ((systemctl | grep NetworkManager.service) && systemctl restart NetworkManager)
/sbin/ifup ''

Stdout from the command:

  NetworkManager.service                                                                   loaded active running   Network Manager

Stderr from the command:

Usage: ifdown <device name>
Usage: ifup <device name>
AmedeeBulle commented 1 year ago

Apologies for the delay...

I believe the issue comes from the fact that OL9 is purely Network Manager based and the /etc/sysconfig/network-scripts directory is empty...

Worth noticing that there is no interface name in your error messages (e.g. ifcfg- should be ifcfg-eth1 or something similar).

Another issue might be the NIC Type as the image only contains the virtio drivers -- You could try adding nic_type: "virtio" to the config.vm.network stanza.

I'll look a this more in detail shortly.

hussam-qasem commented 1 year ago

Thank you @AmedeeBulle. nic_type: "virtio" did the trick.

Vagrant.configure("2") do |config|
  config.vm.box = "oraclelinux/9"
  config.vm.box_url = "https://oracle.github.io/vagrant-projects/boxes/oraclelinux/9.json"
  config.vm.network "private_network", ip: "192.168.56.4", nic_type: "virtio"
end
AmedeeBulle commented 1 year ago

Great! thank you for confirming.