프로비저닝 도구 중의 하나인 Vagrant를 알아보자.
Windows에서 VirtualBox를 사용하려면 Hyper-V가 비활성화가 되어야 한다.
PS C:\Users\jaeseok.park> Disable-WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
PS C:\Users\jaeseok.park> WindowsOptionalFeature -Online -FeatureName Microsoft-Hyper-V-All
FeatureName : Microsoft-Hyper-V-All
DisplayName : Hyper-V
Description : 가상 컴퓨터와 그 리소스를 만들고 실행하기 위한 서비스 및 관리 도구를 제공합니다.
RestartRequired : Possible
State : Disabled
CustomProperties :
msi를 다운받아서 default 값으로 설치 진행한다.
# vagrant --version
Vagrant 2.2.19
PS D:\Workspace\hello-vagrant> vagrant init harshicorp/bionic64
5
Vagrant failed to initialize at a very early stage:
The version of powershell currently installed on this host is less than
the required minimum version. Please upgrade the installed version of
powershell to the minimum required version and run the command again.
Installed version: N/A
Minimum required version: 3
시작부터 심상찮다. 버전을 확인해 보자. ConEmu
에서의 문제로 확인되었다. ConEmu
버전 업데이트 후 다시 실행하면 문제가 해결된다.
# vagrant init hashicorp/bionic64
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.
# vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'hashicorp/bionic64' could not be found. Attempting to find and install...
default: Box Provider: virtualbox
default: Box Version: >= 0
The box 'hashicorp/bionic64' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Vagrant Cloud, please verify you're logged in via
`vagrant login`. Also, please double-check the name. The expanded
URL and error message are shown below:
URL: ["https://vagrantcloud.com/hashicorp/bionic64"]
Error: schannel: failed to receive handshake, SSL/TLS connection failed
Proxy와 SSL 문제를 먼저 해결하자.
# set http_proxy=http://xxx.xxx.xxx.xxx:8080
# set https_proxy=http://xxx.xxx.xxx.xxx:8080
URL: ["https://vagrantcloud.com/hashicorp/bionic64"]
Error: schannel: next InitializeSecurityContext failed: Unknown error (0x80092012) - 해당 함수에서 인증서에 대한 파기 여부를 검사하지 못했습니다.
Vagrantfile
에 insecure
옵션을 추가하자.
config.vm.box_download_insecure = true
# vagrant up
...
==> default: Forwarding ports...
default: 22 (guest) => 2222 (host) (adapter 1)
==> 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: Guest Additions Version: 6.0.10
default: VirtualBox Version: 6.1
==> default: Mounting shared folders...
default: /vagrant => D:/Workspace/hello-vagrant
잘 동작한다. Proxy 설정과 Insecure 옵션 2가지가 충분조건임을 알 수 있다.
참고로 아래와 같이 box를 먼저 추가하고 up
시켜도 동일한 결과를 얻을 수 있다.
# vagrant box add --insecure hashicorp/bionic64
==> box: Loading metadata for box 'hashicorp/bionic64'
box: URL: https://vagrantcloud.com/hashicorp/bionic64
This box can work with multiple providers! The providers that it
can work with are listed below. Please review the list and choose
the provider you will be working with.
1) hyperv
2) virtualbox
3) vmware_desktop
Enter your choice: 2
# vagrant ssh
Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-58-generic x86_64)Welcome to Ubuntu 18.04.3 LTS (GNU/Linux 4.15.0-58-generic x86_64)
* Documentation: https://help.ubuntu.com
* Management: https://landscape.canonical.com
* Support: https://ubuntu.com/advantage
System information as of Wed Dec 1 12:52:45 UTC 2021
System load: 0.0 Processes: 89
Usage of /: 2.5% of 61.80GB Users logged in: 0
Memory usage: 11% IP address for eth0: 10.0.2.15
Swap usage: 0%
0 packages can be updated.
0 updates are security updates.
vagrant@vagrant:~$ ls -al
total 40
drwxr-xr-x 5 vagrant vagrant 4096 Aug 15 2019 .
drwxr-xr-x 3 root root 4096 Aug 15 2019 ..
-rw-r--r-- 1 vagrant vagrant 220 Aug 15 2019 .bash_logout
-rw-r--r-- 1 vagrant vagrant 3771 Aug 15 2019 .bashrc
drwx------ 2 vagrant vagrant 4096 Aug 15 2019 .cache
drwx------ 3 vagrant vagrant 4096 Aug 15 2019 .gnupg
-rw-r--r-- 1 vagrant vagrant 807 Aug 15 2019 .profile
drwx------ 2 vagrant root 4096 Dec 1 12:47 .ssh
-rw-r--r-- 1 vagrant vagrant 0 Aug 15 2019 .sudo_as_admin_successful
-rw-r--r-- 1 vagrant vagrant 6 Aug 15 2019 .vbox_version
-rw-r--r-- 1 root root 180 Aug 15 2019 .wget-hsts
vagrant@vagrant:~$ exit
logout
Connection to 127.0.0.1 closed.
# vagrant destroy
▶ 【참고 '2023-12-25 Updated】
$vagrant plugin install vagrant-proxyconf
Installing the 'vagrant-proxyconf' plugin. This can take a few minutes...
ERROR: SSL verification error at depth 0: unable to get local issuer certificate (20)
ERROR: You must add ***** to your local trusted store
$set SSL_CERT_FILE=D:\etc\xxxxxx.crt
$vagrant plugin update
Updating installed plugins...
Updated 'dotenv' to version '2.8.1'!
▶ [참고] 과거 정리 자료
# Ignore SSL
$vagrant box add --insecure hashicorp/precise64
# or add following in Vagrantfile
config.vm.box_download_insecure = true
#for installing plug-in
$vagrant plugin install vagrant-proxyconf # not working
$vagrant plugin install vagrant-proxyconf --plugin-source http://rubygems.org # use http instead of https, but still not working
$vagrant plugin install --plugin-clean-sources --plugin-source http://rubygems.org vagrant-proxyconf
# workaround of above https problem -- vagrant 설치폴더
$sudo -E echo ./xxxxxxx.crt >> /C/HashiCorp/Vagrant/embedded/cacert.pem
[참고]
$vagrant box remove hashicorp/bionic64
$vagrant global-status