忘れそうなので自分用メモ
ちょっとした実験をしたくてせっかくなので、こんな感じのVagrantfileでubuntu-16.04を上げようとしたらエラーが出た。
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
if Vagrant.has_plugin?("vagrant-cachier")
config.cache.scope = :box
end
config.vm.define :server do |server|
server.vm.hostname = "dev.example.com"
server.vm.box = "opscode_ubuntu-16.04"
server.vm.box_url = "http://opscode-vm-bento.s3.amazonaws.com/vagrant/virtualbox/opscode_ubuntu-16.04_chef-provisionerless.box"
server.vm.network :private_network, ip: "192.168.53.30"
server.vm.network :forwarded_port, host: 8422, guest: 22
server.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
end
end
こんなエラー
==> server: Configuring and enabling network interfaces...
The following SSH command responded with a non-zero exit status.
Vagrant assumes that this means the command failed!
/sbin/ifdown eth1 2> /dev/null
Stdout from the command:
Stderr from the command:
mesg: ttyname failed: Inappropriate ioctl for device
どうも、nicのI/F名がeth0/eth1から enp0s3/enp0s8 とかに変わったらしく次のバージョンのVagrantでは直るっぽい。この辺り参照 -> https://github.com/mitchellh/vagrant/issues/7155
IP固定できないと辛いので、こんな感じで仮対応した
...
server.vm.network :private_network, ip: "192.168.53.30", auto_config: false
server.vm.network :forwarded_port, host: 8422, guest: 22
server.vm.provider "virtualbox" do |vb|
vb.memory = "2048"
end
server.vm.provision 'shell', inline: "ifconfig enp0s8 192.168.53.30"
...
vagrant up時にこんなエラーがでるけどとりあえずIPは割り当てられた。
...
==> server: Configuring cache buckets...
==> server: Running provisioner: shell...
server: Running: inline script
==> server: mesg:
==> server: ttyname failed
==> server: :
==> server: Inappropriate ioctl for device
==> server: Configuring cache buckets...
$ vagrant ssh
Welcome to Ubuntu 16.04 LTS (GNU/Linux 4.4.0-21-generic x86_64)
* Documentation: https://help.ubuntu.com/
vagrant@dev:~$ ifconfig
enp0s3 Link encap:Ethernet HWaddr 08:00:27:54:d5:fb
inet addr:10.0.2.15 Bcast:10.0.2.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe54:d5fb/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2869 errors:0 dropped:0 overruns:0 frame:0
TX packets:1800 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:554522 (554.5 KB) TX bytes:261836 (261.8 KB)
enp0s8 Link encap:Ethernet HWaddr 08:00:27:4d:c0:0c
inet addr:192.168.53.30 Bcast:192.168.53.255 Mask:255.255.255.0
inet6 addr: fe80::a00:27ff:fe4d:c00c/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:8 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:648 (648.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:12 errors:0 dropped:0 overruns:0 frame:0
TX packets:12 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1
RX bytes:1092 (1.0 KB) TX bytes:1092 (1.0 KB)
とりあえず、指定したIPで接続もできたけど、provisionでipつけてるんでvagrant upする時に --provisionつけないといけないのがいけてない...。
もうちょっとスマートな方法ないかねー。