Vagrantでの環境構築について。 CentOS7での環境構築の手順を構築してみます。
「HashiCorp」(Vagrantを開発したMitchell Hashimoto氏が創業した会社)による「Vagrant Cloud」のサイトにある手順ですと以下になります。
・「Vagrant Cloud」でのCentOS7のboxでの構築手順
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
$ vagrant box add centos/7 ==> box: Loading metadata for box 'centos/7' box: URL: https://atlas.hashicorp.com/centos/7 This box can work with multiple providers! The providers that it can work with are listed below. Please review the list and choose the provider you will be working with. 1) hyperv 2) libvirt 3) virtualbox 4) vmware_desktop Enter your choice: 3 ==> box: Adding box 'centos/7' (v1710.01) for provider: virtualbox box: Downloading: https://vagrantcloud.com/centos/boxes/7/versions/1710.01/providers/virtualbox.box ==> box: Successfully added box 'centos/7' (v1710.01) for 'virtualbox'! |
boxイメージが追加されたので、「Vagrantfile」を作成して、その後、vagrantを初期化してアップします。
1 2 3 4 |
$ vagrant init centos/7 $ vagrant up |
基本手順として基本的には問題ないです。
ただ、実際の開発ではもう少し細かなOSのバージョン指定などもあるので、Bentoのboxイメージを使ったインストール方法を試してみます。
BentoはChefの開発元である会社(Opscodeから2013年に社名をChefに変更)によりメンテナンス・公開されているプロジェクトです。
作成時の手順なども公開されており、「HashiCorp」による公式サイトでもBentoを使ったOSインストールは公開されています。
・「Vagrant Cloud」でのCentOS7.4のboxでの構築手順
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
$ vagrant box add bento/centos-7.4 ==> box: Loading metadata for box 'bento/centos-7.4' box: URL: https://atlas.hashicorp.com/bento/centos-7.4 This box can work with multiple providers! The providers that it can work with are listed below. Please review the list and choose the provider you will be working with. 1) parallels 2) virtualbox 3) vmware_desktop Enter your choice: 2 ==> box: Adding box 'bento/centos-7.4' (v201710.25.0) for provider: virtualbox box: Downloading: https://vagrantcloud.com/bento/boxes/centos-7.4/versions/201710.25.0/providers/virtualbox.box ==> box: Successfully added box 'bento/centos-7.4' (v201710.25.0) for 'virtualbox'! |
boxイメージが追加されたので、「Vagrantfile」を作成して、その後、vagrantを初期化してアップします。
1 2 3 4 |
$ vagrant init bento/centos-7.4 $ vagrant up |
手順的にはBentoを使った場合でも変化はないです。
標準OSの公開後、1カ月以内にはBentoでも公開されているようですので、よほど最新のOSを使う必要がない限りはBentoを使っての構築となるかと。
このブログは株式会社CoLabMixによる技術ブログです。
GCP、AWSなどでのインフラ構築・運用や、クローリング・分析・検索などを主体とした開発を行なっています。
Ruby on RailsやDjango、Pythonなどの開発依頼などお気軽にお声がけください。
開発パートナーを増やしたいという企業と積極的に繋がっていきたいです。
お問い合わせやご依頼・ご相談など