Skip to content

Instantly share code, notes, and snippets.

@ikikko
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ikikko/8d3a4b396270a0031cb4 to your computer and use it in GitHub Desktop.
Save ikikko/8d3a4b396270a0031cb4 to your computer and use it in GitHub Desktop.

第8弾 週末ランサーズ「Infrastructure as Code」 ~ ハンズオン手順 ~

目次

  1. 事前準備 / Vagrant の基礎
  2. プロビジョニング (Chef)
  3. テスト (serverspec)
  4. 継続的インテグレーション (Jenkins)

事前準備

USBメモリからファイル一式コピー

'201405_weekendlancers' には、今回のハンズオンを進める際の雛形を置いています。丸ごとローカルにコピーしておいてください。

'201405_weekendlancers_optional' には、ハンズオンを進めるにあたって必要なツールのインストーラを置いています。お使いの PC に各ツールがインストールされていない場合、こちらをコピーしておいてください。

$ tree
.
├── 201405_weekendlancers
│   ├── box
│   │   └── opscode_centos-6.5_chef-provisionerless.box
│   ├── cookbooks
│   │   └── httpd
│   │       └── recipes
│   │           └── default.rb
│   ├── jenkins
│   │   └── .jenkins
│   │   └── jenkins.war
│   └── serverspec
│       └── Gemfile
└── 201405_weekendlancers_optional
    ├── java
    │   ├── jdk-7u55-macosx-x64.dmg
    │   ├── jdk-7u55-windows-i586.exe
    │   └── jdk-7u55-windows-x64.exe
    ├── ruby
    │   ├── DevKit-tdm-32-4.5.2-20111229-1559-sfx.exe
    │   └── rubyinstaller-1.9.3-p545.exe
    ├── ssh
    │   └── Git-1.9.2-preview20140411.exe
    ├── vagrant
    │   ├── vagrant_1.6.2.dmg
    │   └── vagrant_1.6.2.msi
    └── virtualbox
        ├── VirtualBox-4.3.12-93733-OSX.dmg
        └── VirtualBox-4.3.12-93733-Win.exe

Virtualbox のインストール

  • virtualbox/VirtualBox-4.3.12-xxx でインストール(まだインストールしていない人)

[Win] PATH に VirtualBox へのパスを追加しておいてください。デフォルトでは、 'C:¥Program Files¥Oracle¥VirtualBox' になっていると思います。

Vagrant のインストール

  • vagrant/vagrant_1.6.2.xxx でインストール(まだインストールしていない人)
$ vagrant --version

box の追加

$ cd 201405_weekendlancers

$ vagrant box add opscode_centos-6.5 box/opscode_centos-6.5_chef-provisionerless.box

vagrant box list コマンドで 'opscode_centos-6.5' が表示されればオッケーです。

$ vagrant box list
opscode_centos-6.5   (virtualbox, 0)

Vagrant の基礎

Vagrant の初期設定

$ vagrant init opscode_centos-6.5

実行後、Vagrantfile が作成されているかと思います。

VM の起動

$ vagrant up
$ vagrant status

VM に接続

$ vagrant ssh

$ exit

[Win] ssh が使えるようにしておく必要があります。いくつか方法がありますが、USBメモリに'Git for Windows'を入れていますので、こちらをインストールしてください。インストール後、'Git Bash' 内で ssh を使用することができます。以降の作業は、Git Bash 内で行ってください。

VM の一時停止

$ vagrant suspend
$ vagrant status

VM の破棄

$ vagrant destroy
$ vagrant status
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment