LoginSignup
1
1

More than 5 years have passed since last update.

[覚書]Ottoで開発環境を構築 (Appfileをカスタマイズ → Rubyのバージョン指定)

Last updated at Posted at 2015-12-11
  1. [覚書]Ottoで開発環境を構築
  2. [覚書]OttoでAWSに本番環境構築&デプロイ
  3. [覚書]Ottoで開発環境を構築 (Appfileをカスタマイズ → Rubyのバージョン指定)ここ
  4. [覚書]Ottoで開発環境を構築 (MongoDBのDockerコンテナを動かす)

プロジェクト作成

プロジェクトをクローン。

$ git clone https://github.com/hashicorp/otto-getting-started.git

設定

Appfileを作成する。(下記は最小構成のAppfile)

application {
  name = "otto-getting-started"
  type = "ruby"
}

project {
  name = "otto-getting-started"
  infrastructure = "otto-getting-started"
}

infrastructure "otto-getting-started" {
  type = "aws"
  flavor = "simple"
}

Appfileは、HCL (HashiCorp Configuration Language)という言語で書かれているそうです。詳細については、こちらを参照してください。(未確認)

コンパイル

$ otto compile
==> Loading Appfile...
==> Fetching all Appfile dependencies...
==> Compiling...
    Application:    otto-getting-started (ruby)
    Project:        otto-getting-started
    Infrastructure: aws (simple)

    Compiling infra...
    Compiling foundation: consul
==> Compiling main application...
==> Compilation success!
    This means that Otto is now ready to start a development environment,
    deploy this application, build the supporting infrastructure, and
    more. See the help for more information.

    Supporting files to enable Otto to manage your application from
    development to deployment have been placed in the output directory.
    These files can be manually inspected to determine what Otto will do.

コンパイル結果のApplicationProjectInfrastructureの項目が、Appfileに設定した通りになっています。

念のため、ステータスを確認。

$ otto status
==> App Info
    Application:    otto-getting-started (ruby)
    Project:        otto-getting-started
    Infrastructure: aws (simple)
==> Component Status
    Dev environment: NOT CREATED
    Infra:           NOT CREATED
    Build:           NOT BUILT
    Deploy:          NOT DEPLOYED

開発環境の構築

構築

開発環境を構築する。

$ otto dev

ステータス確認

$ otto status
==> App Info
    Application:    otto-getting-started (ruby)
    Project:        otto-getting-started
    Infrastructure: aws (simple)
==> Component Status
    Dev environment: CREATED
    Infra:           NOT CREATED
    Build:           NOT BUILT
    Deploy:          NOT DEPLOYED

カスタマイズ

Appfileに、下記の記述を追加することでRubyのバージョンを指定できます。

customization "ruby" {
  ruby_version = "2.1"
}

先ほど作った開発環境を削除します。

$ otto dev destroy

コンパイルしなおして、開発環境を構築します。

$ otto compile
$ otto dev

otto devコマンドを実行した際に、下記の行が出力されているはずです。

==> default: [otto] Installing Ruby 2.1 and supporting packages...

Rubyのバージョンを確認します。

$ otto dev ssh
vagrant@precise64:/vagrant$ ruby --version
ruby 2.1.7p400 (2015-08-18 revision 51632) [x86_64-linux-gnu]

Rubyのバージョン2.1がインストールされています。

参考

以上

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