[空気にも躓く][memo] Varying Vagrant Vagrants と vagrant-hostsupdater と /private/etc/hosts
最近、空気にも躓く。
後日談あり。
WordPress の検証環境を共有する為に 10up / varying-vagrant-vagrants を利用しようとした。
https://github.com/10up/varying-vagrant-vagrants/blob/master/README.md
[zunermuka ~]$ git clone git://github.com/10up/varying-vagrant-vagrants.git vagrant-local
[zunermuka ~]$ cd vagrant-local/
[zunermuka ~/vagrant-local]$ vagrant up
時間がかかると思い、別の作業に没頭していた。
忘れた頃に、完了を確認してみると、以下のようなエラーが出力されていた。
vagrant-hostsupdater/HostsUpdater.rb:104:in `digest': can't convert nil into String (TypeError)
ってどこから?
まさか、本体側の /private/etc/hosts を変更する際に Password の入力を待っていて時間切れで追記できなかったとか?
それならばと、
[zunermuka ~/vagrant-local]$ sudo sh -c 'echo "192.168.50.4 vvv.dev local.wordpress.dev local.wordpress-trunk.dev src.wordpress-develop.dev build.wordpress-develop.dev" >> /private/etc/hosts'
[zunermuka ~/vagrant-local]$ sudo dscacheutil -flushcache
これで、名前解決できるはず。
[zunermuka ~/vagrant-local]$ vagrant status
Current machine states:
default running (virtualbox)
The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.
[zunermuka ~/vagrant-local]$ vagrant ssh
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686)
* Documentation: https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 06:22:31 2012 from 10.0.2.2
vagrant@vvv:~$ less .bash_history
cat /etc/rc.local
sudo update-locale LANG=en_US
sudo locale-gen en_US
sudo update-locale LANG=en_US
hist
history
初めての login なのに .bash_history に履歴がある。(自分で作る時は気をつけなければ)
vagrant ssh で接続はできる。
しかしブラウザからは 192.168.50.4 local.wordpress.dev では反応無し。
vagrant@vvv:~$ ps aux | grep nginx
vagrant@vvv:~$ ps aux | grep mysql
動いてません。でも簡単にやり直しが効くのが Vagrant の良い所。(再取得で負担が掛かるので控えます)
vagrant@vvv:~$ sudo /sbin/shutdown -h now
vagrant@vvv:~$
Broadcast message from vagrant@vvv
(/dev/pts/0) at 5:47 ...
The system is going down for halt NOW!
Connection to 127.0.0.1 closed by remote host.
[zunermuka ~/vagrant-local]$ vagrant status
Current machine states:
default poweroff (virtualbox)
The VM is powered off. To restart the VM, simply run `vagrant up`
[zunermuka ~/vagrant-local]$ vagrant destroy
追記した /private/etc/hosts は元に戻しておく。
[zunermuka ~/vagrant-local]$ vagrant up
[zunermuka ~/vagrant-local]$ vagrant status
Current machine states:
default running (virtualbox)
The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.
[zunermuka ~/vagrant-local]$ lv /private/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
192.168.50.4 vvv.dev # VAGRANT: 594646ae8d11d5505 (default) / b
24da294-ad05-4de4-8263-ef80e1462d20
192.168.50.4 vvv.dev # VAGRANT: 594646ae8d11d5505 (default) / b
24da294-ad05-4de4-8263-ef80e1462d20
192.168.50.4 local.wordpress.dev # VAGRANT: 594646ae8d11d5505 (
default) / b24da294-ad05-4de4-8263-ef80e1462d20
192.168.50.4 local.wordpress-trunk.dev # VAGRANT: 594646ae8d11d
5505 (default) / b24da294-ad05-4de4-8263-ef80e1462d20
192.168.50.4 src.wordpress-develop.dev # VAGRANT: 594646ae8d11d
5505 (default) / ef80e1462d20
192.168.50.4 build.wordpress-develop.dev # VAGRANT: 594646ae8d1
1d5505 (default) / ef80e1462d20
成功。
http://local.wordpress.dev/ ブラウザで確認。
こんなぼけたパターンは少ないよね。
※エラーの記録
[default] Checking for host entries
[default] Forcing shutdown of VM...
[default] Destroying VM and associated drives...
[default] Running cleanup tasks for 'shell' provisioner...
/Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:104:in `digest': can't convert nil into String (TypeError)
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:104:in `hexdigest'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:104:in `signature'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:66:in `block in getHostEntries'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:65:in `each'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:65:in `getHostEntries'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:33:in `block in addHostEntries'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:32:in `each'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:32:in `addHostEntries'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/Action/UpdateHosts.rb:18:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builtin/call.rb:57:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builtin/call.rb:57:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-berkshelf-1.3.3/lib/berkshelf/vagrant/action/configure_chef.rb:14:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-berkshelf-1.3.3/lib/berkshelf/vagrant/action/load_shelf.rb:14:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-berkshelf-1.3.3/lib/berkshelf/vagrant/action/set_ui.rb:12:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builtin/env_set.rb:19:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builtin/call.rb:57:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builder.rb:116:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/runner.rb:61:in `block in run'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/util/busy.rb:19:in `busy'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/runner.rb:61:in `run'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/machine.rb:147:in `action'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/batch_action.rb:63:in `block (2 levels) in run'
後日談あり。
WordPress の検証環境を共有する為に 10up / varying-vagrant-vagrants を利用しようとした。
https://github.com/10up/varying-vagrant-vagrants/blob/master/README.md
[zunermuka ~]$ git clone git://github.com/10up/varying-vagrant-vagrants.git vagrant-local
[zunermuka ~]$ cd vagrant-local/
[zunermuka ~/vagrant-local]$ vagrant up
時間がかかると思い、別の作業に没頭していた。
忘れた頃に、完了を確認してみると、以下のようなエラーが出力されていた。
vagrant-hostsupdater/HostsUpdater.rb:104:in `digest': can't convert nil into String (TypeError)
ってどこから?
まさか、本体側の /private/etc/hosts を変更する際に Password の入力を待っていて時間切れで追記できなかったとか?
それならばと、
[zunermuka ~/vagrant-local]$ sudo sh -c 'echo "192.168.50.4 vvv.dev local.wordpress.dev local.wordpress-trunk.dev src.wordpress-develop.dev build.wordpress-develop.dev" >> /private/etc/hosts'
[zunermuka ~/vagrant-local]$ sudo dscacheutil -flushcache
これで、名前解決できるはず。
[zunermuka ~/vagrant-local]$ vagrant status
Current machine states:
default running (virtualbox)
The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.
[zunermuka ~/vagrant-local]$ vagrant ssh
Welcome to Ubuntu 12.04 LTS (GNU/Linux 3.2.0-23-generic-pae i686)
* Documentation: https://help.ubuntu.com/
Welcome to your Vagrant-built virtual machine.
Last login: Fri Sep 14 06:22:31 2012 from 10.0.2.2
vagrant@vvv:~$ less .bash_history
cat /etc/rc.local
sudo update-locale LANG=en_US
sudo locale-gen en_US
sudo update-locale LANG=en_US
hist
history
初めての login なのに .bash_history に履歴がある。(自分で作る時は気をつけなければ)
vagrant ssh で接続はできる。
しかしブラウザからは 192.168.50.4 local.wordpress.dev では反応無し。
vagrant@vvv:~$ ps aux | grep nginx
vagrant@vvv:~$ ps aux | grep mysql
動いてません。でも簡単にやり直しが効くのが Vagrant の良い所。(再取得で負担が掛かるので控えます)
vagrant@vvv:~$ sudo /sbin/shutdown -h now
vagrant@vvv:~$
Broadcast message from vagrant@vvv
(/dev/pts/0) at 5:47 ...
The system is going down for halt NOW!
Connection to 127.0.0.1 closed by remote host.
[zunermuka ~/vagrant-local]$ vagrant status
Current machine states:
default poweroff (virtualbox)
The VM is powered off. To restart the VM, simply run `vagrant up`
[zunermuka ~/vagrant-local]$ vagrant destroy
追記した /private/etc/hosts は元に戻しておく。
[zunermuka ~/vagrant-local]$ vagrant up
[zunermuka ~/vagrant-local]$ vagrant status
Current machine states:
default running (virtualbox)
The VM is running. To stop this VM, you can run `vagrant halt` to
shut it down forcefully, or you can run `vagrant suspend` to simply
suspend the virtual machine. In either case, to restart it again,
simply run `vagrant up`.
[zunermuka ~/vagrant-local]$ lv /private/etc/hosts
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
192.168.50.4 vvv.dev # VAGRANT: 594646ae8d11d5505 (default) / b
24da294-ad05-4de4-8263-ef80e1462d20
192.168.50.4 vvv.dev # VAGRANT: 594646ae8d11d5505 (default) / b
24da294-ad05-4de4-8263-ef80e1462d20
192.168.50.4 local.wordpress.dev # VAGRANT: 594646ae8d11d5505 (
default) / b24da294-ad05-4de4-8263-ef80e1462d20
192.168.50.4 local.wordpress-trunk.dev # VAGRANT: 594646ae8d11d
5505 (default) / b24da294-ad05-4de4-8263-ef80e1462d20
192.168.50.4 src.wordpress-develop.dev # VAGRANT: 594646ae8d11d
5505 (default) / ef80e1462d20
192.168.50.4 build.wordpress-develop.dev # VAGRANT: 594646ae8d1
1d5505 (default) / ef80e1462d20
成功。
http://local.wordpress.dev/ ブラウザで確認。
こんなぼけたパターンは少ないよね。
※エラーの記録
[default] Checking for host entries
[default] Forcing shutdown of VM...
[default] Destroying VM and associated drives...
[default] Running cleanup tasks for 'shell' provisioner...
/Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:104:in `digest': can't convert nil into String (TypeError)
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:104:in `hexdigest'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:104:in `signature'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:66:in `block in getHostEntries'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:65:in `each'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:65:in `getHostEntries'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:33:in `block in addHostEntries'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:32:in `each'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/HostsUpdater.rb:32:in `addHostEntries'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-hostsupdater-0.0.10/lib/vagrant-hostsupdater/Action/UpdateHosts.rb:18:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builtin/call.rb:57:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builtin/call.rb:57:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-berkshelf-1.3.3/lib/berkshelf/vagrant/action/configure_chef.rb:14:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-berkshelf-1.3.3/lib/berkshelf/vagrant/action/load_shelf.rb:14:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Users/zunermuka/.vagrant.d/gems/gems/vagrant-berkshelf-1.3.3/lib/berkshelf/vagrant/action/set_ui.rb:12:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builtin/env_set.rb:19:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builtin/call.rb:57:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/warden.rb:34:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/builder.rb:116:in `call'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/runner.rb:61:in `block in run'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/util/busy.rb:19:in `busy'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/action/runner.rb:61:in `run'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/machine.rb:147:in `action'
from /Applications/Vagrant/embedded/gems/gems/vagrant-1.3.5/lib/vagrant/batch_action.rb:63:in `block (2 levels) in run'
コメント