結論
Vagrantのバージョンを最新版(2.0.2)に上げたことでフォルダの共有はできた。
ただし、双方向の同期についてはまだ分かっていない。
vagrant rsync-auto
で、ホストのファイルをゲストに同期することはできた。
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.provider "hyperv" do |h|
h.differencing_disk = true # Faster cloning and uses less disk space
end
config.vm.synced_folder '.', '/vagrant', type: "rsync"
end
はじめにやろうとしたこと。
vagrantでhyper-vを扱うためにいくつかの参考サイトを確認した。
VagrantでプロバイダーにWindowsのHyper-Vを使ってみる
Windows 10でHyper-Vを使ってVagrantを動かす
Windows10のHyper-Vを使ったVagrantのBoxファイル作成方法
Learning to Use Vagrant on Windows 10
とりあえず、以下のVagrantfileを作って、vagrant up --provider=hyperv
。
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
end
仮想スイッチの外部ネットワークのネットワークアダプタにうっかりローカル接続のアダプタを選んでIPが取得できないなどのエラーはありつつも、実際に接続しているWifi接続のアダプタに修正することが立ち上がるところまでは無事に終了。
ただし、共有フォルダのマウントがされなかった。ここからが長かった。
共有フォルダを認識させるためにsambaを利用しているところが多かったため、同じようにやろうとした。
が、エラーが続出
CIFS VFS: No username specified
CIFS VFS: Error connecting to socket. Aborting operation
CIFS VFS: cifs_mount failed w/return code = -115
No host IP was given to the Vagrant core NFS helper. This is
an internal error that should be reported as a bug.
This is an internal bug with Vagrant and an issue should be filed.
winnfsdを使おうとしても失敗*
No valid IDs were given to the NFS synced folder implementation to
prune. This is an internal bug with Vagrant and an issue should be
filed.
と、調べているうちに、vagrantが最新になっていないことにきづいた。
Vagrant2.0.2にアップデートしてみると、最初に書いた通り、すんなりと通った。
更新はちゃんとしよう。。。
余談
dockerもいれてみた。*
Vagrant.configure("2") do |config|
config.vm.box = "centos/7"
config.vm.provider "hyperv" do |h|
h.differencing_disk = true # Faster cloning and uses less disk space
end
config.vm.synced_folder '.', '/vagrant'
config.vm.provision "shell", inline: <<-SHELL
if ! docker > /dev/null 2>&1; then
yum install -y yum-utils \
device-mapper-persistent-data \
lvm2
yum-config-manager \
--add-repo \
https://download.docker.com/linux/centos/docker-ce.repo
yum install -y docker-ce
yum list docker-ce --showduplicates | sort -r
systemctl start docker
docker run hello-world
fi
if ! /usr/local/bin/docker-compose > /dev/null 2>&1; then
curl -L https://github.com/docker/compose/releases/download/1.19.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
fi
SHELL
end