Vagrant box 추천

vagrant 박스 – 공식 박스가 배포되는 경우

debian/stretch64
ubuntu/bionic64
centos/7

공식은 아니지만 여기도 종종 사용하고
bento/ubuntu-18.04이렇게 공식박스를 제공하는 곳도 있지만…

문제는.. 
openbsd, fedora 등 오픈소스진영은 배포자가 관리 주체가 불확실한 경우가 많다
대부분 virtualbox 버전만 제공된다.

parallels, hyperv는 개인이 만든걸 쓰거나 직접 만들어야된다.

그래서 윈도우에 virtualbox를 깔고 쓰게 되는데…

그러다가 발견한 이 계정.

https://app.vagrantup.com/generic

1) hyperv
2) libvirt
3) parallels
4) virtualbox
5) vmware_desktop

다있음.

Error: Vagrant box respository

Message

➜  testva vagrant init ubuntu/xenial64
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.
➜  testva vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/xenial64' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
The box 'ubuntu/xenial64' could not be found or
could not be accessed in the remote catalog. If this is a private
box on HashiCorp's Atlas, 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://atlas.hashicorp.com/ubuntu/xenial64"]
Error: Could not resolve host: atlas.hashicorp.com

Ubuntu 17.10 기본 apt install vagrnat 설치할 때 리포지터리 URL문제

설정을 변경해주거나 vagrant 공식 사이트에서 deb를 다운받아 설치하면 해결

vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Box 'ubuntu/xenial64' could not be found. Attempting to find and install...
    default: Box Provider: virtualbox
    default: Box Version: >= 0
==> default: Loading metadata for box 'ubuntu/xenial64'
    default: URL: https://vagrantcloud.com/ubuntu/xenial64
==> default: Adding box 'ubuntu/xenial64' (v20180302.0.0) for provider: virtualbox
    default: Downloading: https://vagrantcloud.com/ubuntu/boxes/xenial64/versions/20180302.0.0/providers/virtualbox.box
==> default: Successfully added box 'ubuntu/xenial64' (v20180302.0.0) for 'virtualbox'!
==> default: Importing base box 'ubuntu/xenial64'...
==> default: Matching MAC address for NAT networking...
==> default: Setting the name of the VM: docker-ub

주소가 바뀌었다.

https://atlas.hashicorp.com/ubuntu/xenial64

https://vagrantcloud.com/ubuntu/xenial64

Vagrant global 설정 변경

??어뜨케 하나

/home/{USERNAME}/.vagrant.d/data/checkpoint_cache??

아닌것같고… 확인필요

Vagrantfile 변경

https://www.vagrantup.com/docs/vagrantfile/machine_settings.html

config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.box_url = "https://vagrantcloud.com/ubuntu/xenial64"

공식 사이트에서 deb설치

그냥 새로 깔았다.

찾으려면 설치경로 전체에서 문자열 검색해야할 것 같다.

Vagrant berkshelf 동작이 안되는 경우

vagrant도 ruby  기반이라서 내장 ruby gem을 가지고 있다

내장 ruby gem과 rbenv/rvm/그냥설치… 된 다양한 루비환경이 분리되어있기 때문에 생기는 문제

 

운이 좋으면 두개를 겹쳐서 설치해도 되는 경우도 있다.

명령어가 있는 gem은 설치시 path를 셋팅한다.

운이 좋으면 높은 우선순위를 잡아서 실행이 될수도 있다.

 

 

 

해결하려면 다른환경에 설치된 gem을 지우고 vagrant 내장 gem을 따로 설치 해 주면 된다.

gem uninstall chef chef-zero berkshelf knife-solo

맞나? 이거 대충써놨다가 수정하려니까 기억이 안난다.

딱봐도 아닌데… 이걸 지우는게 해결책일리가 없다.

 

vagrant 내장 gem을 설치해야할 것 같은데

다음에 생각나면 다시 해봐야겠다.

 

 

Vagrant에서 .bashrc source가 먹히지 않는 문제

오류상황

vagrant shell에서 rbenv가 안먹힌다.

vagrant ssh 접속해서 보니 설치가 잘 돼 있고 path도 잡혀있는데

vagrant 설치시에 command not found가 발생

source가 안먹히는건가? 라고 생각

 

검색해보니

키워드 :

  • vagrant
  • command not found
  • source
  • not working

맘에드는 대답이 안나왔는데… 찾다보니 이런게 보인다.

https://stackoverflow.com/questions/29628635/why-is-source-home-vagrant-bashrc-not-working-in-a-vagrant-shell-provisionin

.bashrc에 인터렉티브 쉘이 아닌경우 리턴을 시키는문구가 있다고?

 

ubuntu .bashrc를 확인

.bashrc의 맨 앞에 이런게 있다.

# If not running interactively, don't do anything
case $- in
    *i*) ;;
      *) return;;
esac

If not running interactively, don’t do anything.
인터렉티브 쉘이 아닌경우, 아무것도 하지마.

rbenv공식 메뉴얼에는 .bashrc에 패스를 잡으라고 돼 있었는데..(메뉴얼이 바뀐건가? bash_profile에 하라고 돼있네)
어쨌든 이전 메뉴얼대로 하면 안돌아간다.

위의 검색결과에 나오는 스택오버플로우에는
.bashrc에서 return명령을 없애라고 하는데… 필요해서 해놨겠지.. 이 방법은 안쓰겠다.
대신에 .bash_profile/.profile에서 패스를 잡고 source .profile을 하면 된다.
아니면 .custom_profile을 만들어서 임포트해도 되고 .profile.d/를 써도될듯

Vagrant Base Box 만들기 – HyperV

공식문서
https://www.vagrantup.com/docs/boxes/base.html
https://www.vagrantup.com/docs/hyperv/boxes.html

용량줄이기
https://blog.asamaru.net/2015/10/14/creating-a-vagrant-base-box/sudo dd if=/dev/zero of=/EMPTY bs=1M
sudo rm -f /EMPTY

그냥 이렇게만 따라했다.
정리는 나중에봐서…

완성된 박스는

https://app.vagrantup.com/archmagece/boxes/sb-ub16.04.2-hyperv
여기 올릴 생각인데