coreos / bugs

Issue tracker for CoreOS Container Linux
https://coreos.com/os/eol/
147 stars 30 forks source link

Can't start Vagrant machines through the "vagrant up" #2103

Open ibazulic opened 6 years ago

ibazulic commented 6 years ago

Issue Report

Bug

Vagrant does not provision Machines when typing "vagrant up" after Git cloning and setting up config.

Container Linux Version

any

Environment

What hardware/cloud provider/hypervisor is being used to run Container Linux? Virtual Box on Windows 10 as host OS. Git Bash was used to stat provisioning process.

Expected Behavior

Vagrant provisions 3 Machines (as set in the config.rb file).

Actual Behavior

$ vagrant up Installing plugins: vagrant-ignition Installing the 'vagrant-ignition' plugin. This can take a few minutes... Fetching: vagrant-share-1.1.9.gem (100%) Fetching: vagrant-ignition-0.0.3.gem (100%) Installed the plugin 'vagrant-ignition (0.0.3)'! Bringing machine 'core-01' up with 'virtualbox' provider... Bringing machine 'core-02' up with 'virtualbox' provider... Bringing machine 'core-03' up with 'virtualbox' provider... ==> core-01: Box 'coreos-alpha' could not be found. Attempting to find and install... core-01: Box Provider: virtualbox core-01: Box Version: >= 0 ==> core-01: Loading metadata for box 'https://alpha.release.core-os.net/amd64-usr/current/coreos_production_vagrant_virtualbox.json' core-01: URL: https://alpha.release.core-os.net/amd64-usr/current/coreos_production_vagrant_virtualbox.json ==> core-01: Adding box 'coreos-alpha' (v1492.4.0) for provider: virtualbox core-01: Downloading: https://alpha.release.core-os.net/amd64-usr/1492.4.0/coreos_production_vagrant_virtualbox.box core-01: Progress: 100% (Rate: 5785k/s, Estimated time remaining: --:--:--) core-01: Calculating and comparing box checksum... ==> core-01: Successfully added box 'coreos-alpha' (v1492.4.0) for 'virtualbox'! ==> core-01: Importing base box 'coreos-alpha'... ==> core-01: Configuring Ignition Config Drive ==> core-01: Matching MAC address for NAT networking... ==> core-01: Checking if box 'coreos-alpha' is up to date... ==> core-01: Setting the name of the VM: coreos-vagrant_core-01_1502740972527_23936 ==> core-01: Clearing any previously set network interfaces... ==> core-01: Preparing network interfaces based on configuration... core-01: Adapter 1: nat core-01: Adapter 2: hostonly ==> core-01: Forwarding ports... core-01: 22 (guest) => 2222 (host) (adapter 1) ==> core-01: Running 'pre-boot' VM customizations... ==> core-01: Booting VM... ==> core-01: Waiting for machine to boot. This may take a few minutes... core-01: SSH address: 127.0.0.1:2222 core-01: SSH username: core core-01: SSH auth method: private key core-01: Warning: Connection reset. Retrying... core-01: Warning: Connection aborted. Retrying... ==> core-01: Machine booted and ready! ==> core-01: Setting hostname... ==> core-01: Configuring and enabling network interfaces... ==> core-01: Running provisioner: file... ==> core-01: Running provisioner: shell... core-01: Running: inline script ==> core-01: mv: ==> core-01: cannot create regular file '/var/lib/coreos-vagrant/' ==> core-01: : Not a directory The SSH command responded with a non-zero exit status. Vagrant assumes that this means the command failed. The output for this command should be in the log above. Please read the output to determine what went wrong.

Reproduction Steps

  1. git clone https://github.com/coreos/coreos-vagrant.git
  2. cd coreos-vagrant
  3. vagrant up

Other Information

I'm not sure that this is a bug but I found the source of the error. This is from the Vagrantfile:

      # This shouldn't be used for the virtualbox provider (it doesn't have any effect if it is though)
      if File.exist?(CLOUD_CONFIG_PATH)
        config.vm.provision :file, :source => "#{CLOUD_CONFIG_PATH}", :destination => "/tmp/vagrantfile-user-data"
        config.vm.provision :shell, :inline => "mv /tmp/vagrantfile-user-data /var/lib/coreos-vagrant/", :privileged => true
      end

This shouldn't be used if VirtualBox is used as a hypervisor but Ruby still executes the script. The path /var/lib/coreos-vagrant is not available on this step, which caused provisioning to fail. I have added the following to the Vagrantfile to test it out:

config.vm.provision :shell, :inline => "mkdir /var/lib/coreos-vagrant/", :privileged => true

and after that the provisioning process went through normally. All instances are up and running and can be SSHed into.

AlexNPavel commented 6 years ago

Due to some changes in how we handle Ignition and cloud config files, that section will now cause vagrant to crash if you have a cloud-config/user-data file when using the default VirtualBox provider. Cloud config is not supported for VirtualBox anymore, only Ignition. To fix the issue, please remove your "user-data" file and use the Ignition configuration instead (there is documentation on how to in the coreos-vagrant README.md file). We are working on supporting Ignition on vagrant-vmware as well, at which point we will remove cloud-config from the Vagrantfile completely.

ibazulic commented 6 years ago

@AlexNPavel Ah, now I see. I have used the official docs at

https://coreos.com/os/docs/latest/booting-on-vagrant.html

which doesn't say anything about this change. It specifically asks for user-data to be present and set up. I'll try setting them up without it. Thanks for the heads up!