Quantcast
Channel: Bashタグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 2828

VirtualBoxの開発スピードにVagrantが追いついてないから

$
0
0

すげなくおとこわりされる

VagrantでBoxを作るのはいい。
でも、VirtualBoxの開発はありがたいことに活発で、しばしばVagrantのバージョンアップが追いつかなくて、互換性検証が終わっていないがためか、つれなく以下みたいに断られる。
この状態になると、最後にVMに保存された状態以後、Vagrantでできていたことが一切できなくなる。
vagrant sshすらできない。
ひとまずsshコマンドを手打ちしていたけれど、もう死ぬ。めんどい。
よってbash_profileで対処したから、備忘録として書いておく。

command
$ vagrant up
'default' is reporting that it isn't usable on this system. The
reason is shown below:

Vagrant has detected that you have a version of VirtualBox installed
that is not supported by this version of Vagrant. Please install one of
the supported versions listed below to use Vagrant:

4.0, 4.1, 4.2, 4.3, 5.0, 5.1, 5.2, 6.0

A Vagrant update may also be available that adds support for the version
you specified. Please check www.vagrantup.com/downloads.html to download
the latest version.

無理やり対処してみる

仕方ないのでひとまずVagrantが対応してくれるまで強引にそれっぽい関数をbash_profileに書いている。
ちなみにVirtualBox 6.1.2までで、この問題が治っている感じがしないので、vagrant reloadの代替は強引にsshしてコマンド実行するようなことをしている。
正直な感想は、なんのためのプロビジョニングかわからない状態であるが。。

~/.bash_profile
function vagrantssh(){uuid=`cat .vagrant/machines/${1}/virtualbox/id`port=`VBoxManage showvminfo $uuid | grep-e"NIC [0-9]* Rule" | grep ssh | sed-e's/.* host port = \([0-9]*\).*/\1/g'`
  ssh vagrant@localhost -p$port-i ./.vagrant/machines/default/virtualbox/private_key "df -h | grep vagrant"> /dev/null
  if[$?];then
    ssh vagrant@localhost -p$port-i ./.vagrant/machines/${1}/virtualbox/private_key "sudo -E mount -t vboxsf vagrant /vagrant"fi
  ssh vagrant@localhost -p$port-i ./.vagrant/machines/${1}/virtualbox/private_key
}function vagrantup(){uuid=`cat .vagrant/machines/${1}/virtualbox/id`
  VBoxManage startvm $uuid--type headless
}function vagrantreload(){uuid=`cat .vagrant/machines/${1}/virtualbox/id`port=`VBoxManage showvminfo $uuid | grep-e"NIC [0-9]* Rule" | grep ssh | sed-e's/.* host port = \([0-9]*\).*/\1/g'`
  ssh vagrant@localhost -p$port-i ./.vagrant/machines/${1}/virtualbox/private_key "sudo -E reboot"}function vagranthalt(){uuid=`cat .vagrant/machines/${1}/virtualbox/id`
  VBoxManage controlvm $uuid acpipowerbutton
}

Viewing all articles
Browse latest Browse all 2828

Latest Images

Trending Articles