hashicorp / vagrant

Vagrant is a tool for building and distributing development environments.
https://www.vagrantup.com
Other
26.28k stars 4.43k forks source link

GuestAdditions does not automatically installed #12379

Open maksym-fishman opened 3 years ago

maksym-fishman commented 3 years ago

Vagrant version

$ vagrant --version Vagrant 2.2.16 $ vagrant plugin list vagrant-guest_ansible (0.0.4, global) vagrant-vbguest (0.29.0, global)

Host operating system

$ lsb_release -a LSB Version: core-11.1.0ubuntu2-noarch:security-11.1.0ubuntu2-noarch Distributor ID: Ubuntu Description: Ubuntu 20.04.2 LTS Release: 20.04 Codename: focal

$ virtualbox -h Oracle VM VirtualBox VM Selector v6.1.22

Guest operating system

[vagrant@node2 ~]$ lsb_release -a LSB Version: :core-4.1-ia32:core-4.1-noarch Distributor ID: RedHatEnterprise Description: Red Hat Enterprise Linux release 8.0 (Ootpa) Release: 8.0 Codename: Ootpa

Vagrantfile

VAGRANTFILE_API_VERSION = "2"
VAGRANT_DISABLE_VBOXSYMLINKCREATE = "1"
file_to_disk1 = './disk-0-1.vdi'
file_to_disk2 = './disk-0-2.vdi'
file_to_disk3 = './disk-0-3.vdi'
file_to_disk4 = './disk-0-4.vdi'
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Use same SSH key for each machine
config.ssh.insert_key = false
config.vm.box_check_update = false
config.vbguest.auto_update = true

# Repo Server
config.vm.define "repo" do |repo|
  repo.vm.box = "rdbreak/rhel8repo"
#  repo.vm.hostname = "repo.ansi.example.com"
  repo.vm.provision :shell, :inline => "sudo sed -i 's/PasswordAuthentication no/PasswordAuthentication yes/g' /etc/ssh/sshd_config; sudo systemctl restart sshd;", run: "always"
  repo.vm.provision :shell, :inline => "yum install https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm -y; sudo yum install -y sshpass python3-pip python3-devel httpd sshpass vsftpd createrepo", run: "always"
  repo.vm.provision :shell, :inline => " python3 -m pip install -U pip ; python3 -m pip install pexpect; python3 -m pip install ansible", run: "always"
  repo.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: [".git/", "*.vdi"]
  repo.vm.network "private_network", ip: "192.168.55.199"

  repo.vm.provider "virtualbox" do |repo|
    repo.memory = "512"
  end
end

# Node 1
config.vm.define "node1" do |node1|
  node1.vm.box = "rdbreak/rhel8node"
#  node1.vm.hostname = "node1.ansi.example.com"
  node1.vm.network "private_network", ip: "192.168.55.201"
  node1.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: [".git/", "*.vdi"]
  node1.vm.provider "virtualbox" do |node1|
    node1.memory = "1024"

    unless File.exist?(file_to_disk1)
      node1.customize ['createhd', '--filename', file_to_disk1, '--variant', 'Fixed', '--size', 2 * 1024]
      node1.customize ['storagectl', :id, '--name', 'SATA Controller', '--add', 'sata', '--portcount', 2]
      node1.customize ['storageattach', :id,  '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk1]
      end
  end

    node1.vm.provision "shell", inline: <<-SHELL
    yes| sudo mkfs.ext4 /dev/sdb
    SHELL
    node1.vm.synced_folder ".", "/vagrant"
 end

# Node 2
config.vm.define "node2" do |node2|
  node2.vm.box = "rdbreak/rhel8node"
#  node2.vm.hostname = "node2.ansi.example.com"
  node2.vm.network "private_network", ip: "192.168.55.202"
  node2.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: [".git/", "*.vdi"]
  node2.vm.provider "virtualbox" do |node2|
    node2.memory = "1024"

    unless File.exist?(file_to_disk2)
      node2.customize ['createhd', '--filename', file_to_disk2, '--variant', 'Fixed', '--size', 2 * 1024]
      node2.customize ['storagectl', :id, '--name', 'SATA Controller', '--add', 'sata', '--portcount', 2]
      node2.customize ['storageattach', :id,  '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk2]
      end
 end

    node2.vm.provision "shell", inline: <<-SHELL
    yes| sudo mkfs.ext4 /dev/sdb
    SHELL
    node2.vm.synced_folder ".", "/vagrant"
end

# Node 3
config.vm.define "node3" do |node3|
  node3.vm.box = "rdbreak/rhel8node"
#  node3.vm.hostname = "node3.ansi.example.com"
  node3.vm.network "private_network", ip: "192.168.55.203"
  node3.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: [".git/", "*.vdi"]
  node3.vm.provider "virtualbox" do |node3|
    node3.memory = "512"

   unless File.exist?(file_to_disk3)
      node3.customize ['createhd', '--filename', file_to_disk3, '--variant', 'Fixed', '--size', 2 * 1024]
      node3.customize ['storagectl', :id, '--name', 'SATA Controller', '--add', 'sata', '--portcount', 2]
      node3.customize ['storageattach', :id,  '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk3]
      end
  end

    node3.vm.provision "shell", inline: <<-SHELL
    yes| sudo mkfs.ext4 /dev/sdb
    SHELL
    node3.vm.synced_folder ".", "/vagrant"
end

# Node 4
config.vm.define "node4" do |node4|
  node4.vm.box = "rdbreak/rhel8node"
#  node4.vm.hostname = "node4.ansi.example.com"
  node4.vm.network "private_network", ip: "192.168.55.204"
  node4.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: [".git/", "*.vdi"]
  node4.vm.provider "virtualbox" do |node4|
    node4.memory = "512"

    unless File.exist?(file_to_disk4)
      node4.customize ['createhd', '--filename', file_to_disk4, '--variant', 'Fixed', '--size', 2 * 1024]
      node4.customize ['storagectl', :id, '--name', 'SATA Controller', '--add', 'sata', '--portcount', 2]
      node4.customize ['storageattach', :id,  '--storagectl', 'SATA Controller', '--port', 1, '--device', 0, '--type', 'hdd', '--medium', file_to_disk4]
      end
  end

    node4.vm.provision "shell", inline: <<-SHELL
    yes| sudo mkfs.ext4 /dev/sdb
    SHELL
    node4.vm.synced_folder ".", "/vagrant"
end

# Control Node
config.vm.define "control" do |control|
  control.vm.box = "rdbreak/rhel8node"
#  control.vm.hostname = "control.ansi.example.com"
  control.vm.network "private_network", ip: "192.168.55.200"
  control.vm.provider :virtualbox do |control|
    control.customize ['modifyvm', :id,'--memory', '2048']
    end
  control.vm.synced_folder ".", "/vagrant", type: "rsync", rsync__exclude: [".git/", "*.vdi"]
  control.vm.provision :ansible_local do |ansible|
  ansible.playbook = "/vagrant/playbooks/master.yml"
  ansible.install = false
  ansible.compatibility_mode = "2.0"
  ansible.inventory_path = "/vagrant/inventory"
  ansible.config_file = "/vagrant/ansible.cfg"
  ansible.limit = "all"
 end
end
end

Debug output

==> node3: Attempting graceful shutdown of VM... ==> node3: Clearing any previously set forwarded ports... ==> node3: Fixed port collision for 22 => 2222. Now on port 2202. ==> node3: Clearing any previously set network interfaces... ==> node3: Preparing network interfaces based on configuration... node3: Adapter 1: nat node3: Adapter 2: hostonly ==> node3: Forwarding ports... node3: 22 (guest) => 2202 (host) (adapter 1) ==> node3: Running 'pre-boot' VM customizations... ==> node3: Booting VM... ==> node3: Waiting for machine to boot. This may take a few minutes... node3: SSH address: 127.0.0.1:2202 node3: SSH username: vagrant node3: SSH auth method: private key ==> node3: Machine booted and ready! [node3] GuestAdditions versions on your host (6.1.22) and guest (5.2.30) do not match. Updating Subscription Management repositories. Unable to read consumer identity This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register. Error: There are no enabled repos. Unmounting Virtualbox Guest Additions ISO from: /mnt umount: /mnt: not mounted. ==> node3: Checking for guest additions in VM... node3: The guest additions on this VM do not match the installed version of node3: VirtualBox! In most cases this is fine, but in rare cases it can node3: prevent things such as shared folders from working properly. If you see node3: shared folder errors, please make sure the guest additions within the node3: virtual machine match the version of VirtualBox you have installed on node3: your host and reload your VM. node3: node3: Guest Additions Version: 5.2.30 node3: VirtualBox Version: 6.1 The following SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed!

umount /mnt

Stdout from the command:

Stderr from the command:

umount: /mnt: not mounted.

Expected behavior

[control] GuestAdditions seems to be installed (6.1.22) correctly, but not running. Redirecting to /bin/systemctl start vboxadd.service Redirecting to /bin/systemctl start vboxadd-service.service VirtualBox Guest Additions: Starting. VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules. This may take a while. VirtualBox Guest Additions: To build modules for other installed kernels, run VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup VirtualBox Guest Additions: or VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all VirtualBox Guest Additions: Building the modules for kernel 4.18.0-80.el8.x86_64. VirtualBox Guest Additions: Running kernel modules will not be replaced until the system is restarted Restarting VM to apply changes...

Actual behavior

vagrant ssh node3 Last login: Mon Sep 23 23:53:03 2019 from 10.0.2.2 [vagrant@rhel8 ~]$ wget https://download.virtualbox.org/virtualbox/6.1.22/VBoxGuestAdditions_6.1.22.iso --2021-05-19 16:53:31-- https://download.virtualbox.org/virtualbox/6.1.22/VBoxGuestAdditions_6.1.22.iso Resolving download.virtualbox.org (download.virtualbox.org)... 184.30.24.84 Connecting to download.virtualbox.org (download.virtualbox.org)|184.30.24.84|:443... connected. HTTP request sent, awaiting response... 200 OK Length: 61020160 (58M) [application/octet-stream] Saving to: 'VBoxGuestAdditions_6.1.22.iso'

VBoxGuestAdditions_6.1.22.is 100%[=============================================>] 58.19M 11.9MB/s in 5.0s

2021-05-19 16:53:36 (11.7 MB/s) - 'VBoxGuestAdditions_6.1.22.iso' saved [61020160/61020160]

[vagrant@rhel8 ~]$ sudo mount VBoxGuestAdditions_6.1.22.iso /mnt/ mount: /mnt: WARNING: device write-protected, mounted read-only. [vagrant@rhel8 ~]$ sudo /mnt/VBoxLinuxAdditions.run Verifying archive integrity... All good. Uncompressing VirtualBox 6.1.22 Guest Additions for Linux........ VirtualBox Guest Additions installer Removing installed version 5.2.30 of VirtualBox Guest Additions... Copying additional installer modules ... Installing additional modules ... VirtualBox Guest Additions: Starting. VirtualBox Guest Additions: Building the VirtualBox Guest Additions kernel modules. This may take a while. VirtualBox Guest Additions: To build modules for other installed kernels, run VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup VirtualBox Guest Additions: or VirtualBox Guest Additions: /sbin/rcvboxadd quicksetup all VirtualBox Guest Additions: Building the modules for kernel 4.18.0-80.el8.x86_64. VirtualBox Guest Additions: Running kernel modules will not be replaced until the system is restarted

Steps to reproduce

Use existing vagrant file run "vagrant up"

References

vagrant (2).log

maksym-fishman commented 3 years ago

There is no issue mentioned above for guest OS as below:

[vagrant@repo ~]$ cat /etc/os-release
NAME="Red Hat Enterprise Linux"
VERSION="8.3 (Ootpa)"
ID="rhel"
ID_LIKE="fedora"
VERSION_ID="8.3"
PLATFORM_ID="platform:el8"
PRETTY_NAME="Red Hat Enterprise Linux 8.3 (Ootpa)"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:redhat:enterprise_linux:8.3:GA"
HOME_URL="https://www.redhat.com/"
BUG_REPORT_URL="https://bugzilla.redhat.com/"

REDHAT_BUGZILLA_PRODUCT="Red Hat Enterprise Linux 8"
REDHAT_BUGZILLA_PRODUCT_VERSION=8.3
REDHAT_SUPPORT_PRODUCT="Red Hat Enterprise Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="8.3"
soapy1 commented 3 years ago

Hey there, it looks like this is maybe a problem with the box. In particular, these debug lines are of interest:

Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Error: There are no enabled repos.

It looks like the installation of the guest additions is failing out here (at the dependency installation stage). To resolve this you'll need to setup the guest OS to be able to install software using the system package manager. Or, you can choose to not auto update the guest additions by adding the line config.vbguest.auto_update = false.