ラベル 仮想化 の投稿を表示しています。 すべての投稿を表示
ラベル 仮想化 の投稿を表示しています。 すべての投稿を表示

2017年6月17日土曜日

vagrant up するとエラーが出た。(vagrant-hostsupdater)

Vagrantを使用して仮想環境(CentOS7)を作成しようとした際にエラーが発生しました。
暫定対応ではあるものの一旦解決ということでメモします。
テスト環境としてしか使用していないので良いかなぁ。

環境
 VirtualBox:5.1.22r115126
 Vagrant:1.8.6

エラーログ
-------------------------------------
$ vagrant up
Bringing machine 'test' up with 'virtualbox' provider...
==> test: Importing base box 'geerlingguy/centos7'...
==> test: Matching MAC address for NAT networking...
==> test: Checking if box 'geerlingguy/centos7' is up to date...
==> test: Setting the name of the VM: test_test_1497674923638_5926
==> test: Clearing any previously set network interfaces...
==> test: Preparing network interfaces based on configuration...
    test: Adapter 1: nat
    test: Adapter 2: hostonly
==> test: Forwarding ports...
    test: 22 (guest) => 2422 (host) (adapter 1)
    test: 22 (guest) => 2222 (host) (adapter 1)
==> test: Running 'pre-boot' VM customizations...
==> test: Booting VM...
==> test: Waiting for machine to boot. This may take a few minutes...
    test: SSH address: 127.0.0.1:2222
    test: SSH username: vagrant
    test: SSH auth method: private key
    test: Warning: Remote connection disconnect. Retrying...
    test: Warning: Remote connection disconnect. Retrying...
    test: Warning: Remote connection disconnect. Retrying...
==> test: Machine booted and ready!
==> test: Checking for guest additions in VM...
==> test: [vagrant-hostsupdater] Checking for host entries
==> test: [vagrant-hostsupdater] Writing the following entries to (C:/WINDOWS/system32/drivers/etc/hosts)
==> test: [vagrant-hostsupdater]   192.168.33.53  test  # VAGRANT: 9eb404e1ac140ac4d8bb999a55ed8440 (test) / 97f8545c-ab6a-4e87-9bac-7b2739ef1a99
==> test: [vagrant-hostsupdater] This operation requires administrative access. You may skip it by manually adding equivalent entries to the hosts file.
==> test: Forcing shutdown of VM...
==> test: Destroying VM and associated drives...
C:/Users/shiro/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.2/lib/vagrant-hostsupdater/HostsUpdater.rb:98:in `initialize': Permission denied @ rb_sysopen - C:/WINDOWS/system32/drivers/etc/hosts (Errno::EACCES)
        from C:/Users/shiro/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.2/lib/vagrant-hostsupdater/HostsUpdater.rb:98:in `open'
        from C:/Users/shiro/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.2/lib/vagrant-hostsupdater/HostsUpdater.rb:98:in `addToHosts'
        from C:/Users/shiro/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.2/lib/vagrant-hostsupdater/HostsUpdater.rb:47:in `addHostEntries'
        from C:/Users/shiro/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.2/lib/vagrant-hostsupdater/Action/UpdateHosts.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/check_guest_additions.rb:49:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/customize.rb:40:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/wait_for_communicator.rb:71:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/customize.rb:40:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/boot.rb:18:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/customize.rb:40:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/sane_defaults.rb:38:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/set_hostname.rb:16:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/forward_ports.rb:31:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/network_fix_ipv6.rb:41:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/network.rb:122:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/clear_network_interfaces.rb:26:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/prepare_nfs_settings.rb:18:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/synced_folders.rb:87:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/synced_folder_cleanup.rb:28:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/synced_folders/nfs/action_cleanup.rb:19:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/prepare_nfs_valid_ids.rb:12:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/handle_forwarded_port_collisions.rb:49:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/prepare_forwarded_port_collision_params.rb:30:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/env_set.rb:19:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/provision.rb:80:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/clear_forwarded_ports.rb:15:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/set_name.rb:50:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/clean_machine_folder.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/check_accessible.rb:18:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/call.rb:53:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/call.rb:53:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/call.rb:53:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/box_check_outdated.rb:78:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/match_mac_address.rb:19:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/discard_state.rb:15:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/import.rb:74:in `import'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/import.rb:13:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/prepare_clone_snapshot.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/prepare_clone.rb:15:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/customize.rb:40:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/check_accessible.rb:18:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/call.rb:53:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/config_validate.rb:25:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/handle_box.rb:56:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:95:in `block in finalize_action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builtin/call.rb:53:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/plugins/providers/virtualbox/action/check_virtualbox.rb:17:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/warden.rb:34:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/builder.rb:116:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/runner.rb:66:in `block in run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/util/busy.rb:19:in `busy'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/action/runner.rb:66:in `run'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/machine.rb:225:in `action_raw'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/machine.rb:200:in `block in action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/environment.rb:567:in `lock'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/machine.rb:186:in `call'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/machine.rb:186:in `action'
        from C:/HashiCorp/Vagrant/embedded/gems/gems/vagrant-1.8.6/lib/vagrant/batch_action.rb:82:in `block (2 levels) in run'

-------------------------------------
ログの以下の内容から
C:/WINDOWS/system32/drivers/etc/hostsを変更?しようとしたけど、
権限で無理でしたーってことらしい。
C:/Users/shiro/.vagrant.d/gems/gems/vagrant-hostsupdater-1.0.2/lib/vagrant-hostsupdater/HostsUpdater.rb:98:in `initialize': Permission denied @ rb_sysopen - C:/WINDOWS/system32/drivers/etc/hosts (Errno::EACCES)
そもそもvagrant-hostsupdaterってなんだろうと調べてみたら
hostsファイルにエントリを追加するプラグインっぽい。
(ちょろっと書いてるけど管理者権限が必要みたい)
Vagrant::Hostsupdater

わざわざ管理者権限でvagrant upするのもどうかと思ったので、
ドキュメントに従って、Vagrantfileを変更しました。

変更箇所
変更前:c1.vm.network :private_network, ip: "192.168.33.53"
変更後:c1.vm.network :private_network, ip: "192.168.33.53", hostsupdater: "skip"

変更後再度「$ vagrant up」を実行。
エラーは解消して仮想環境が立ち上がりましたー。

が、しかし、、赤文字で以下の文章が出現・・・。
-------------------------------------
$ vagrant up
Bringing machine 'test' up with 'virtualbox' provider...
==> test: Importing base box 'geerlingguy/centos7'...
==> test: Matching MAC address for NAT networking...
==> test: Checking if box 'geerlingguy/centos7' is up to date...
==> test: Setting the name of the VM: test_test_1497677181126_29912
==> test: Clearing any previously set network interfaces...
==> test: Preparing network interfaces based on configuration...
    test: Adapter 1: nat
    test: Adapter 2: hostonly
==> test: Forwarding ports...
    test: 22 (guest) => 2422 (host) (adapter 1)
    test: 22 (guest) => 2222 (host) (adapter 1)
==> test: Running 'pre-boot' VM customizations...
==> test: Booting VM...
==> test: Waiting for machine to boot. This may take a few minutes...
    test: SSH address: 127.0.0.1:2222
    test: SSH username: vagrant
    test: SSH auth method: private key
    test: Warning: Remote connection disconnect. Retrying...
    test: Warning: Remote connection disconnect. Retrying...
    test: Warning: Remote connection disconnect. Retrying...
==> test: Machine booted and ready!
==> test: Checking for guest additions in VM...
==> test: [vagrant-hostsupdater] Checking for host entries
==> test: [vagrant-hostsupdater] Skipping adding host entries (config.vm.network hostsupdater: "skip" is set)
==> test: Setting hostname...
==> test: Configuring and enabling network interfaces...
==> test: Mounting shared folders...
    test: /vagrant => D:/vagrant/test
Vagrant was unable to mount VirtualBox shared folders. This is usually
because the filesystem "vboxsf" is not available. This filesystem is
made available via the VirtualBox Guest Additions and kernel module.
Please verify that these guest additions are properly installed in the
guest. This is not a bug in Vagrant and is usually caused by a faulty
Vagrant box. For context, the command attempted was:

mount -t vboxsf -o uid=1000,gid=1000 vagrant /vagrant

The error output from the command was:

mount: wrong fs type, bad option, bad superblock on vagrant,
       missing codepage or helper program, or other error

       In some cases useful info is found in syslog - try
       dmesg | tail or so.
-------------------------------------

調べると同じ事象ですでに解決策まで探してくれている記事を発見(ありがたや)。
VirtualBox 5.1.20で共有フォルダーが動かなくなる対策


早速実行してみる。

起動した仮想環境にログインして、以下のコマンドを実行。
$ sudo rm /sbin/mount.vboxsf && sudo ln -s /usr/lib/VBoxGuestAdditions/mount.vboxsf /sbin/mount.vboxsf

仮想マシンを再起動するためローカル環境で以下のコマンドを実行。
$ vagrant reload

無事エラー解消!

上記以外にも以下の対応でも対処できるようです。
仮想環境にログイン
$ vagrant ssh
カーネルアップデート
$ sudo yum update kernel
$ exit
仮想環境再起動
$ vagrant reload

はまりどころが結構ありますが、
使いこなせればかなり便利です。

今回は以上です。




2016年6月11日土曜日

VirtualBox Vagrant CentOS7 Box 作りたい

※だいぶ古くなっていて以下の手順では作れない可能性が高いです。あくまで参考程度に。

いろいろ試してみようと思っても
PCの中がごちゃごちゃするのが嫌なので
VirtualBoxとVagrantを導入します。
ついでに自分でLinuxのボックス作ってLinuxの復習。

それぞれの説明。

VirtualBox:
 Oracle VM VirtualBox (オラクル ブイエム バーチャルボックス)。
 x86 ベース・システム用の仮想化ソフトウェア・パッケージ。
 現在(2016年4月)、Oracle Databaseで有名なオラクルが開発を行っている。

Vagrant:
 FLOSS(Free/Libre and Open Source Software)の仮想開発環境構築ソフトウェア。
 仮想マシンでの開発環境の構築を設定まで自動的に行うことができる。
 違う環境への移行も簡単(作成した仮想マシンを別のPCで再構築なんてのもできる)。

Boxファイル:
 Vagrantで作成・使用する、仮想マシンのベース(ひな形)になるイメージファイル。
 今回はこれを作成します。(ベースになる環境を構築するってこと~)

ちなみにBoxファイルを公開しているサイトもあって
それを利用することもできるらしい。


ではでは、
さっそく、導入する際に行った作業やなどをメモしていきます。

----------------------------------------------------------------------

ダウンロード、インストール

VirtualBox、Vagrantのインストール(ダウンロード:VirtualBox、Vagrant)

・インストールについては以下のサイトがとてもわかりやすかったです。
  Oracle VM VirtualBox をインストールする手順 (Windows 7)
  Vagrant をWindowsにインストールする手順

CentOS7.1 ISOファイルのダウンロード(ダウンロード:CentOS7Minimal)
CentOS7のインストールはVirtualBoxの設定後に行います。

VirtualBoxの設定

VirtualBoxを起動

VirtualBoxにて仮想マシンを新規作成
作成時の設定内容
  ・名前:CentOS7
  ・タイプ:Linux
  ・バージョン:Red Hat (64-bit)
  ・メモリーサイズ:2048 MB
  ・ハードディスク:仮想ハードディスクを作成する
  ・ハードディスクのファイルタイプ:VDI
  ・物理ハードディスクにあるストレージ:可変
  ・ファイルの場所とサイズ:場所はデフォルトのまま、サイズは40GB

作成した仮想マシンを右クリックして設定
 ・オーディオ  - オーディオを有効化のチェックを外す
 ・USB      - USBコントローラーを有効化のチェックを外す
 ・ネットワーク - アダプター1 - 高度 - ポートフォワーディング -
  新規ポートフォワーディングルールを追加(右上にある+マーク)
   設定内容
    名前:SSH
    プロトコル:TCP
    ホストIP:127.0.0.1
    ホストポート:2222
    ゲストIP: (空白)
    ゲストポート:22
 ・ストレージ - コントローラーIDE - 右端にあるディスクマークをクリック -
  仮想光学ディスクファイルを選択 - ダウンロードしたCentOS7のISOファイルを選択

 OKを押して保存

CentOS7を仮想マシンにインストール

仮想マシンを選択して起動をクリック
仮想マシンが起動してCentOS7のインストールが始まる
メモ:
「表示された仮想マシンの画面をクリックするとメッセージが表示される
 キャプチャ-をクリックで仮想マシン内の操作が可能になる。
 右のControlキーを押すと仮想マシンから抜けられる」

Install CentOS 7を選択してエンターキーを押下

言語設定を日本語にする。
続行をクリック

インストール先をクリック
 ローカル標準ディスクを選択
 完了をクリック

ネットワークとホスト名をクリック
 イーサネット(enpOs3)をオンにする
 完了をクリック

インストールの開始をクリック

ROOTパスワードをクリック
  パスワードを設定:vagrant
  完了を2回クリック

ユーザーの作成をクリック
  ユーザー名:vagrant
  パスワード:vagrant
  完了を2回クリック

再起動をクリック

※こっから先はTeraTermなどSSH接続用のツールを使用して作業をします。
TeraTermのインストールなどについてわからない方は以下のサイトなど参考にするといいかも。
Tera Termのインストール - Tera Termの使い方
接続するときのホストとポート番号は「VirtualBoxの設定」のネットワークで設定した
ホストIP:127.0.0.1、ホストポート:2222を指定します。
SSH接続しなくても作業はできますが、コピペなどができるのでSSH接続しての作業がおすすめ。


CentOS7の設定

sudoの設定

vagrantユーザーにsudoを許可する。

・以下のコマンドでvagrantをwheelグループに追加
 # usermod -aG wheel vagrant

・追加されたことを確認
  # id vagrant

・sudo の設定ファイルを開く
  # visudo
  (/etc/sudoers が開かれる)

・設定ファイルを編集
  ## Allows people in group wheel to run all commands
  %wheel  ALL=(ALL)  ALL (コメントされている場合はコメントを外す)

  ## Same thing without a password
  %wheel   ALL=(ALL)   NOPASSWD: ALL (コメントされている場合はコメントを外す)

 「Defaults               requiretty 」の次の行に以下を追加する。
 Defaults:vagrant    !requiretty

  保存して閉じる

SSH設定

# mkdir /home/vagrant/.ssh
# chmod 700 /home/vagrant/.ssh
# curl https://raw.githubusercontent.com/mitchellh/vagrant/master/keys/vagrant.pub >> /home/vagrant/.ssh/authorized_keys
# chmod 600 /home/vagrant/.ssh/authorized_keys
# chown -R vagrant:vagrant /home/vagrant/.ssh

不要サービスの停止・無効化

ひとまず参考にしたサイト通りに、サービスを無効化します。
(firewalldはもともとなかった・・)

全サービスの一覧表示(qを入力して一覧からコマンドラインに戻れる)
 # systemctl list-units --type service

状態確認
 # systemctl status postfix
停止
 # systemctl stop postfix
無効化
 # systemctl disable postfix
状態確認
 # systemctl status postfix 

SELinuxの無効化

いろいろ厄介らしいのでSELinuxを無効化。
# vi /etc/selinux/config

以下の行を変更
 変更前) SELINUX=enforcing
 変更後) SELINUX=disabled

既存パッケージのアップデート

# yum -y update

追加パッケージのインストール

# yum -y groupupdate "Development Tools"
# yum -y install man-pages-ja wget vim-enhanced

# reboot
(再起動されるので再度ログイン)

VirtualBox Guest Additionsのインストール

VirtualBoxの実行中仮想マシンのメニューから、
[デバイス] > [Guest Additions のCDイメージを挿入...]を選択し、
以下の手順でインストールする。
  # mkdir /media/cdrom
 # mount -r /dev/cdrom /media/cdrom
 # sh /media/cdrom/VBoxLinuxAdditions.run
  yesを応答する。
 # umount /media/cdrom

----トラブルシューティングメモ----
 実行中に[失敗](FAILED)が出てなかなか正常にインストールできなかった。
 ログなどいろいろ調べた結果、 以下のサイトで実施している
 トラブルシューティングの内容を実行したら正常にインストールできました。
 VirtualBox/クリップボードの共有

 【実施した内容】
  ls で確認したkernelのバージョンと
  uname -r で確認したkernelのバージョンが同じことを確認
   # ls /usr/src/kernels/<kernelバージョン>
     # uname -r

  違った場合は以下を実施する  
   # yum remove -y kernel-devel kernel-headers gcc
   # yum install -y kernel-devel-`uname -r` kernel-headers-`uname -r` gcc

  .bashrcファイルの末尾に以下の行を追記する。
   # vi ~/.bashrc
    export KERN_DIR=/usr/src/kernel/`uname -r`
  .bashrcの再読み込み
   # . ~/.bashrc
  インストールの再実施
   # sh /media/cdrom/VBoxLinuxAdditions.run

yum のキャッシュ削除

# yum clean all

シャットダウン

# shutdown -h now

ボックスの作成

コマンドプロンプトを起動(ファイル名を指定して実行のところでcmdを入力して実行すると出てくるよ)

vagrant package --base <仮想マシン名> package.boxを実行してboxファイルを作成。
 > vagrant package --base CentOS7 package.box
 >dir package.box

※package.boxは実行した時の場所(フォルダ)に作成されるので移動してから行う

ボックスをVagrantに登録

vagrant box add --name <Vagrantでのボックス名> package.box
 > vagrant box add --name centos7 package.box
 > vagrant box list
centos7が表示され追加されていることを確認。

ボックスを使ってみる

好きな場所にフォルダを作成します。(VirtualBox上での名前になります。日本語は使わないほうが無難かな?)
今回はCドライブの直下にVagrantフォルダを作成して、
その下に各仮想マシン用のフォルダを作成して管理しようと思います。

作成したらコマンドプロンプトで作成したフォルダに移動。
 > cd C:/Vagrant/testVagrant

vagrant init <Vagrantでのボックス名>を実行して仮想マシン用の設定ファイルを作成。
> vagrant init centos7

実行場所にVagrantfileが作成されます。

以下のコマンドで仮想マシンの起動(初回実行時は仮想マシンの作成)
 > vagrant up

以下のコマンドでSSH接続用のホスト名、ポート番号、ユーザ名が表示されます。
 > vagrant ssh

SSH接続する。


以上です。
これで多分できるはず!
新しいことを気軽に試せるっていいですよね。

おわり。



以下は参考にさせてもらったページ

 ・systemctlコマンド
  6.2. システムサービスの管理
・VagrantでBox作成
  Vagrantコマンド
・その他
  Tera Termのインストール - Tera Termの使い方
  VirtualBox/クリップボードの共有