Is there a way to change ssh settings (namely config.ssh.host) AFTER provisioning?
Is it possible to refer any settings inside trigger or provision sections (especially guest box IP and full guest virtualbox name)?
vagrant ssh to access box via host-only interface and switch off NAT interface temporarily.
Currenlt workaround flow: comment ssh-related lines, run
vagrant up, uncomment ssh lines, run
It would be nice to do it with just
vagrant up and automate things a bit.
Without comment/uncomment routine:
Vagrant.configure("2") do |config| config.vm.provision "shell" do |s| s.inline = <<-SHELL apt -y install build-essential python3 SHELL end config.vm.define "sample" do |sample| config.vm.hostname = "samplehost" sample.vm.box = "ubuntu/mantic64" sample.vm.network "private_network", ip: "192.168.56.56" sample.ssh.host = "192.168.56.56" sample.ssh.port = 22 end end
vagrant up provisions and starts server
Startup fails after timeout with console output:
vagrant up ✔ 7s Bringing machine 'sample' up with 'virtualbox' provider... ==> sample: Importing base box 'ubuntu/mantic64'... ==> sample: Matching MAC address for NAT networking... ==> sample: Checking if box 'ubuntu/mantic64' version '20231014.0.0' is up to date... ==> sample: Setting the name of the VM: vareport_sample_1700062347569_83000 ==> sample: Clearing any previously set network interfaces... ==> sample: Preparing network interfaces based on configuration... sample: Adapter 1: nat sample: Adapter 2: hostonly ==> sample: Forwarding ports... sample: 22 (guest) => 2222 (host) (adapter 1) ==> sample: Running 'pre-boot' VM customizations... ==> sample: Booting VM... ==> sample: Waiting for machine to boot. This may take a few minutes... sample: SSH address: 192.168.56.56:22 sample: SSH username: vagrant sample: SSH auth method: private key sample: Warning: Host unreachable. Retrying... sample: Warning: Host unreachable. Retrying... sample: Warning: Host unreachable. Retrying... ... Timed out while waiting for the machine to boot. This means that Vagrant was unable to communicate with the guest machine within the configured ("config.vm.boot_timeout" value) time period. ...
Connecting to guest box with virtualbox UI:
ip link shows 2 interfaces created (NAT + host-only)
ip address shows only NAT interface up