LoginSignup
0
0

More than 5 years have passed since last update.

vagrant box作成手順

Last updated at Posted at 2018-06-07

VagrantでVMを管理する

centos6.9のminimal版をインストール

VagrantでオリジナルBoxを作成する
インストールに関しては上記を参考する

ネット繋がらせる、eth0設定行う

/etc/sysconfig/network-scripts/ifcfg-eth0
上記のファイルの ONBOOT = yes へ変更  service network restart でネットワーク再起動

パッケージインストール事前準備

yum update -y  ( 既存のパッケージが古いのせいか、更新しないとシェル失敗 )

libselinux-pythonもインストールしておく

selinuxがdisabledで無い場合、「libselinux-python」がインストールされていないと、
ansible実行時に下記のエラーが出る。

msg: Aborting, target uses selinux but python bindings (libselinux-python) aren't installed!

guest Additionsインストール必要なパッケージ追加

yum install -y gcc make kernel-devel

virtualbox-guest-additionsのインストール

参考リンク
guest-addition iso
実行失敗したら、再起動してみる

vagrantユーザー作成(.ssh/authorized_keysも作る)

以下は大事、そのせいで二日ハマった、vagrantが上手いことやってくれると思って、public keyが最初から入れていなかった

curl -k -L -o authorized_keys 'https://raw.github.com/mitchellh/vagrant/master/keys/vagrant.pub'

vagrantユーザーのroot権限を与える

visudoでNOPASSWD: ALL 。。。追加する

掃除

yum clean all

box作成

  • vagrant package --base xxxでbox作成 // 勝手にxxxの名前のVMをbox作成してくれる
  • vagrant box add --name xxxx package.box // vagrantへ登録する

vagrant init && up ( vagrant box list )

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0