質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
コマンド

コマンドとは特定のタスクを行う為に、コンピュータープログラムへ提示する指示文です。多くの場合、コマンドはShellやcmdようなコマンドラインインターフェイスに対する指示文を指します。

VirtualBox

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

サーバ

サーバは、 クライアントサーバモデルにおいてクライアントからの要求に対し 何らかのサービスを提供するプログラムを指す言葉です。 また、サーバーソフトウェアを稼動させているコンピュータ機器そのもののことも、 サーバーと呼ぶ場合もあります。

Q&A

解決済

1回答

6767閲覧

Vagrantでvagrantfileの編集方法と、vagrantfileの一部を誤って削除してしまった時の対処法を教えて下さい。

h-o

総合スコア134

コマンド

コマンドとは特定のタスクを行う為に、コンピュータープログラムへ提示する指示文です。多くの場合、コマンドはShellやcmdようなコマンドラインインターフェイスに対する指示文を指します。

VirtualBox

VirtualBoxは、現在米オラクル社が開発している、 x86仮想化ソフトウェア・パッケージの一つです。

Vagrant

Vagrantは、VirtualBox上の仮想マシンを コマンドラインから作成してくれるソフトウェアです。 ビルド環境など容易に構築が可能です。

サーバ

サーバは、 クライアントサーバモデルにおいてクライアントからの要求に対し 何らかのサービスを提供するプログラムを指す言葉です。 また、サーバーソフトウェアを稼動させているコンピュータ機器そのもののことも、 サーバーと呼ぶ場合もあります。

0グッド

0クリップ

投稿2016/04/26 08:23

編集2016/04/26 08:30

###前提・実現したいこと
Vagrantでboxをつくり仮想環境のOSを入れて、仮想環境にIPアドレスを設定するためvagrantfileの内容を編集しようとすると文字の入力(一部の文字はできる)、削除ができなくなり、「$ vagrant halt」で閉じることもできなくなったのでターミナルごと閉じてまたvagrantfileの編集を試みたのですが上手くいかずそうしているうちにvagrantfileの一部を書き換えてしまいました。

###発生している問題・エラーメッセージ

・vagrantfileの編集ができない
・vagrantfileが正式な方法で閉じられない
・vagrantfileの内容を一部変更してしまった。

###該当のソースコード

mac1-no-iMac:~ mac$ vagrant global-status id name provider state directory ------------------------------------------------------------------------ e52e08d default virtualbox running /Users/mac/Desktop/centOS70_64 f47e1c0 default virtualbox running /Users/mac The above shows information about all known Vagrant environments on this machine. This data is cached and may not be completely up-to-date. To interact with any of the machines, you can go to that directory and run Vagrant, or you can use the ID directly with Vagrant commands from any directory. For example: "vagrant destroy 1a2b3c4d" mac1-no-iMac:~ mac$ mac1-no-iMac:~ mac$ vi vagrantfile # The most common configuration options are documented and commented below. # For a complete reference, please see the online documentation at # https://docs.vagrantup.com. # Every Vagrant development environment requires a box. You can search for # boxes at https://atlas.hashicorp.com/search. config.vm.box = "CentOS7_box" # Disable automatic box update checking. If you disable this, then # boxes will only be checked for updates when the user runs # `vagrant box outdated`. This is not recommended. # config.vm.box_check_update = false # Create a forwarded port mapping which allows access to a specific port # within the machine from a port on the host machine. In the example below, # accessing "localhost:8080" will access port 80 on the guest machine. # config.vm.network "forwarded_port", guest: 80, host: 8080 # Create a private network, which allows host-only access # config.vm.synced_folder "../data", "/vagrant_data" # Provider-specific configuration so you can fine-tune various # backing providers for Vagrant. These expose provider-specific options. # Example for VirtualBox: # # config.vm.provider "virtualbox" do |vb| # # Display the VirtualBox GUI when booting the machine # vb.gui = true # # # Customize the amount of memory on the VM: # vb.memory = "1024" # end # # View the documentation for the provider you are using for more # information on available options. # Define a Vagrant Push strategy for pushing to Atlas. Other push strategies # such as FTP and Heroku are also available. See the documentation at # https://docs.vagrantup.com/v2/push/atlas.html for more information. # config.push.define "atlas" do |push| # push.app = "YOUR_ATLAS_USERNAME/YOUR_APPLICATION_NAME" # end # Enable provisioning with a shell script. Additional provisioners such as # Puppet, Chef, Ansible, Salt, and Docker are also available. Please see the # documentation for more information about their specific syntax and use. # config.vm.provision "shell", inline: <<-SHELL # sudo apt-get update # sudo apt-get install -y apache2 # SHELL end $ vagrant halt -- INSERT --``` ###試したこと ・$ vi vagrantfileを開いた状態でダブルクリックやドラッグしてみたらたまに文字が入力できたり削除できたりしたがなぜそうなったか不明 ・vagrantfileのendのあとにコピペで「$ vagrant halt」を入力したが反応なし。 ###補足情報(言語/FW/ツール等のバージョンなど) MacOS : 10.10.5 vagrant : 1.8.0 virtualboxバージョン 5.0.18 r106667 仮想環境のOS : CentOS7

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答1

0

ベストアンサー

Vagrantファイルを書き換えてしまっても、
また持ってくれば良いだけの話です。

バックアップだけとっておき、必要に応じてばんばん書き換えましょう。


これはViの使い方がキモな質問だと思います。

Viはマウスという軟弱なモノがない時代のエディターで、
起動直後は標準モードという入力が出来ない代わりに、ショートカット次第で自由自在にカーソルを瞬間移動させられるモードです。
その後、iキー等を入力するといつものエディターと同じく入力出来る「入力モード」になります。
入力が終わったらEscキーを押す事で標準モードに戻る事が出来ます。

標準モードでは「:(コロン)」キーを押すと1コマンド入力することができ、
保存する場合は:w、保存せずに終了する時は:q!を入力してください。


vagrantfileのendのあとにコピペで「$ vagrant halt」を入力したが反応なし。

vagrant haltは起動中の仮想マシンを終了させる為のコマンドです。
何も反応が無かったことから、仮想マシンは起動していないと推測されます。

vagrant upを実行してエラー内容を確認してみましょう。

投稿2016/04/26 13:04

miyabi-sun

総合スコア21158

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

h-o

2016/04/27 08:26

ありがとうございます。 ほんとに助かりました。少し闇が晴れた感じです。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問