Vagrantfile piece:
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
# Use Centos 7 64-bit as our operating system
config.vm.box = "centos/7"
# Configurate the virtual machine to use 2GB of RAM and 2 CPU
config.vm.provider :virtualbox do |vb|
vb.name = "vagrant-jenkins"
vb.customize ["modifyvm", :id, "--memory", "2048"]
vb.customize ["modifyvm", :id, "--cpus", "2"]
vb.customize ["modifyvm", :id, "--natdnshostresolver1", "on"]
end
config.vm.network :private_network, ip: "192.168.56.8"
...
end
Logs when vagrant up:
> ➜ toy vagrant up Bringing machine 'default' up with 'virtualbox'
> provider...
> ==> default: Checking if box 'centos/7' is up to date...
> ==> default: A newer version of the box 'centos/7' for provider 'virtualbox' is
> ==> default: available! You currently have version '1804.02'. The latest is version
> ==> default: '1902.01'. Run `vagrant box update` to update.
> ==> default: Clearing any previously set forwarded ports...
> ==> default: Clearing any previously set network interfaces...
> ==> default: Preparing network interfaces based on configuration...
> default: Adapter 1: nat
> default: Adapter 2: hostonly
> ==> default: Forwarding ports...
> default: 22 (guest) => 2222 (host) (adapter 1)
> ==> default: Running 'pre-boot' VM customizations...
> ==> default: Booting VM...
> ==> default: Waiting for machine to boot. This may take a few minutes...
> default: SSH address: 127.0.0.1:2222
> default: SSH username: vagrant
> default: SSH auth method: private key
> ==> default: Machine booted and ready! [default] GuestAdditions 5.2.14 running --- OK.
> ==> default: Checking for guest additions in VM...
> ==> default: Setting hostname...
> ==> default: Configuring and enabling network interfaces...
> default: SSH address: 127.0.0.1:2222
> default: SSH username: vagrant
> default: SSH auth method: private key
> ==> default: Mounting shared folders...
When trying to ssh to it, it is pending on connecting to the private IP:
➜ toy ssh -v toy
OpenSSH_7.6p1, LibreSSL 2.6.2
debug1: Reading configuration data /Users/abc/.ssh/config
debug1: /Users/abc/.ssh/config line 11: Applying options for toy
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 48: Applying options for *
debug1: Connecting to 192.168.56.8 port 22.
ssh config:
Host toy
Hostname 192.168.56.8
User vagrant
IdentityFile ~/Vagrant/Toy/.vagrant/machines/default/virtualbox/private_key