Skip to content

Instantly share code, notes, and snippets.

@hakobera

hakobera/1.md Secret

Last active August 29, 2015 14:26
Show Gist options
  • Star 8 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hakobera/a5ced7653957a6491047 to your computer and use it in GitHub Desktop.
Save hakobera/a5ced7653957a6491047 to your computer and use it in GitHub Desktop.
ハシコープ会LT@2015/8/15

Quipper と Hashicorp

自己紹介

  • 本多 一行
  • twitter: @hakobera
  • DevOps エンジニア@Quipper,Ltd

Hashicorp と私

  • ◯ Vagrant
  • △ Packer
  • × Serf
  • × Consul
  • ◯ Terraform
  • ◯ Atlas
  • × Vault

Vagrant

  • Ansible Playbook のローカル検証用
  • 少し前では単体テストでも使ってたけど、先週 Docker に移行した

Packer

  • 検証中
  • コスト削減のため AWS のスポットインスタンスを使いたいので、Ansible でプロビジョニング済みAMIを作成するために使いたい
  • CloudInit (userdata) で頑張れば、使わなくてもいいのではないか?と悩み中

Serf/Consule

  • 使ってません
  • 何が便利なのか、今日勉強できれば・・・

Terraform & Atlas

Terraform

  • インスタンスの洗い替えのタイミングで導入
  • CircleCI から自動で適用している
  • tfstate ファイルは Atlas で管理(CircleCI から push)

Atlas

  • 現状、tfstate ファイルの管理にのみ使っている
  • Github 連携も試してみたけど、CircleCI から適用した方が便利なので使ってない
    • 適用が手作業になるので、面倒くさい
  • 最近、実は tfstate を S3 で管理するようにすれば、使わなくても良いのではないかという思いを抱きつつある。

Codenize Tool との棲み分け

こまめに変更するものは codenize tool にしている。 AWS management console でちょこっと変えても、export できるので便利。

やってしまった事例

  • CircleCI で timeout 時間を伸ばすの忘れて、apply が timeout
    • RDS を新規に作る時は気をつけよう
    • tfstate がズレて、再度 apply するのが大変 (tfstate の手修正 orz)
  • IAM role 付け替えて apply したら、インスタンス破棄
    • AWS の制限とかちゃんと把握しておきましょう

悩み

  • リポジトリ/ファイルの分割の単位
    • CircleCI から自動で適用する関係上、VPC 単位でリポジトリを分割
    • ファイルはほぼ Resources 単位 (aws_xxx_ の prefix が一致するもの)で分けている
      • 2015-08-05 16 15 54
  • Private DNS問題
    • 現状、Auto Scaling Group がないので Private IP は固定して運用しているが、動的になった場合、DNS の管理が Terraform でできなくなる
    • そこで Consul?

今後やりたいこと

  • 一部移行できていないものがあるので Terraforming 使ってみようと思っている

まとめ/その他

  • Hashicorp ツール便利
  • Terraform はすごい勢いて変更が入るので、watch しておいた方が良さげ。他人の issue を眺めていると、同じ失敗をしないで済む。
  • いつかコミットしてみたい(主に Terraform)
machine:
environment:
PATH: $HOME/.terraform-0.6.1:$PATH
TERRAFORM_VERSION: 0.6.1
dependencies:
cache_directories:
- ~/.terraform-0.6.1
pre:
- |
mkdir -p $HOME/.terraform-${TERRAFORM_VERSION}
if [ -z "$(ls -A $HOME/.terraform-${TERRAFORM_VERSION})" ]; then
cd $HOME/.terraform-${TERRAFORM_VERSION}
curl -LO https://dl.bintray.com/mitchellh/terraform/terraform_${TERRAFORM_VERSION}_linux_amd64.zip
unzip terraform_${TERRAFORM_VERSION}_linux_amd64.zip
rm terraform_${TERRAFORM_VERSION}_linux_amd64.zip
fi
test:
pre:
- terraform remote config -backend=Atlas -backend-config "name=quipper/quipper"
- terraform remote pull
- cat .terraform/terraform.tfstate
post:
- terraform plan --refresh=false config
deployment:
production:
branch: master
commands:
- terraform remote config -backend=Atlas -backend-config "name=quipper/quipper"
- terraform remote pull
- cat .terraform/terraform.tfstate
- terraform apply -refresh=false config:
timeout: 1800
- terraform remote push
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment