LoginSignup
1
2

More than 5 years have passed since last update.

Ansible+Vagrantで開発環境とAnsibleで本番環境の構築 Ruby + MySQL ①

Last updated at Posted at 2017-02-18

前提

  • VagrantとVirtualBoxはインストール済み

CentOS7.2環境の構築

  • Vagrantbox.esにアクセスして、BOXのURLを取得
  • コマンドプロンプトを立ち上げて、下記コマンドを実行して、BOXを作成
C:\>vagrant box add CentOS7_x64 https://github.com/CommanderK5/packer-centos-template/releases/download/0.7.2/vagrant-centos-7.2.box
==> box: Box file was not detected as metadata. Adding it directly...
==> box: Adding box 'CentOS7_x64' (v0) for provider:
    box: Downloading: https://github.com/CommanderK5/packer-centos-template/releases/download/0.7.2/vagrant-centos-7.2.box
    box: Progress: 100% (Rate: 1448k/s, Estimated time remaining: --:--:--)
==> box: Successfully added box 'CentOS7_x64' (v0) for 'virtualbox'!

出来上がりましたね。

  • 早速確認
vagrant box list
CentOS7_x64       (virtualbox, 0)
  • 仮想マシンを格納するフォルダを作成する。
    ここではUserユーザのものとして、 C:\Users\User\VM\CentOS7_x64_001とする。 コマンドプロンプトで以下のとおり実行する。
C:\Users\User>cd vm
C:\Users\User\VM>cd CentOS7_x64_001
C:\Users\User\VM\CentOS7_x64_001>
  • 仮想マシンの作成
C:\Users\User\VM\CentOS7_x64_001>vagrant init CentOS7_x64
A `Vagrantfile` has been placed in this directory. You are now
ready to `vagrant up` your first virtual environment! Please read
the comments in the Vagrantfile as well as documentation on
`vagrantup.com` for more information on using Vagrant.

これで、vagrantfileが作成されました。

  • 下記コマンドで立ち上げてみましょう
C:\Users\User\VM\CentOS7_x64_001>vagrant up
  • 接続してみよう。
    C:\Users\User\VM\CentOS7_x64_001でgitのbashHereにて下記コマンドを実行
$ vagrant ssh
Last login: Thu Jul 16 08:48:31 2015 from 10.0.2.2
Welcome to your Vagrant-built virtual machine.
[vagrant@localhost ~]$

ログインできましたね。。

Ansibleのインストール

*EPEL(Extra Package for Enterprise Linux)レポジトリを利用する。

sudo yum install epel-release

*ようやくたどり着いたこのコマンド でansibleのインストール

sudo yum install ansible --enablerepo=epel-testing

途中でY/Nを聞かれる場合、すべてYとします。

1
2
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
1
2