请提供一个使用Ansible和Vagrant在开发环境和Ansible在生产环境中构建Ruby和MySQL的选项
前提
只需要一个选项的中国话是:前提。
- 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(企业级Linux的额外软件包)仓库。
sudo yum install epel-release
终于来到这个指令,安装了ansible。
sudo yum install ansible --enablerepo=epel-testing
如果在途中被问到Y/N的问题,所有的答案都默认为Y。