LoginSignup
15
14

More than 5 years have passed since last update.

Chef Berkshelf でのハマりどころメモ

Last updated at Posted at 2014-04-12

正直 Chef 使うのやめたい…!

でも OpsWorks が Chef 使えっていうんだからしょうがない…
なんだかんだ、デファクトスタンダードだしな。

ハマりどころとしては2点。

  • リポジトリURLとバージョン(タグ)の指定方法
    specify repository URL and version(tag name) at the same time
  • ネストされた Berksfile (依存関係) の解決
    resolve dependencies for nested Berkfile

リポジトリURLとバージョン(タグ)の指定方法

git プロトコルを使っちゃう

Berksfile
cookbook "vpcnat", github: "weseek/chef-vpcnat"

Output

Failed to download 'vpcnat' from github: 'weseek/chef-vpcnat' with branch: 'master' over protocol: 'git'
Cookbook 'vpcnat' not found in any of the default locations

まあこれはエラーメッセージ見ればわかるし、ポートが空いてるかどうかはネットワークによるし。

tagなのかbranchなのかハッキリしろ

Berksfile
cookbook "vpcnat", git: "https://github.com/weseek/chef-vpcnat", tag: "v1.0.0"

Output

STDERR: Failed to download 'vpcnat' from github: 'weseek/chef-vpcnat' with branch: 'v1.0.0' over protocol: 'git'
Cookbook 'vpcnat' not found in any of the default locations

意味がわからん…

本家ドキュメント によると、

An optional tag key is an alias for branch and can be used interchangeably.

interchangeably(交換可能)だ~?うそつきー!うそつきーー!
(バグ??)

Workable

Berksfile
cookbook "vpcnat", git: "https://github.com/weseek/chef-vpcnat", ref: "tags/v1.0.0"

ネストされた Berksfile (依存関係) の解決

parent/Berksfile
site :opscode

cookbook "awscli", git: "https://github.com/weseek/chef-awscli"
cookbook "vpcnat", git: "https://github.com/weseek/chef-vpcnat", ref: "tags/v1.0.0"
vpcnat/Berksfile
site :opscode
metadata

cookbook "cron", "= 1.3.6"

cookbook "awscli", git: "https://github.com/weseek/chef-awscli"
cookbook "databag-util", git: "https://github.com/weseek/chef-databag-util"
cookbook "ec2util", git: "https://github.com/weseek/chef-ec2util"
vpcnat/metadata.rb
name             'vpcnat'

(snip)

depends 'awscli'
depends 'cron'
depends 'databag-util'
depends 'ec2util'

症状

---- Begin output of BERKSHELF_PATH=/var/lib/aws/opsworks/berkshelf_cache /opt/aws/opsworks/local/bin/berks install --path /opt/aws/opsworks/current/berkshelf-cookbooks ----
STDOUT: Using python (1.4.6)
Using cron (1.3.6)
Installing awscli (0.1.0) from git: 'https://github.com/weseek/chef-awscli' with branch: 'master' at ref: '023e309d506da2752a6d04bff206f6b4f651d515'
Installing vpcnat (1.0.0) from git: 'https://github.com/weseek/chef-vpcnat' with branch: 'v1.0.0' at ref: '6b503834a8ca704aac0e830536770d9075183b20'
STDERR: Cookbook 'databag-util' not found in any of the default locations

databag-util がないって怒られてるけど、おそらく ec2util も同様の症状。

stackoverflow に記事があった。

要するに、デフォルトサイト指定の cookbook はともかく、自前で準備したものの依存関係は、全てトップレベルの Berksfile (上の例だと parent のもの) に書いとかなきゃいけないってことだ。上の例での awscli はそれ故に解決可能になっている。

ってこんなのさ…

やってらんねーぜ!!

え、前時代的すぎない??

なんていうか、Debian が apt-get 使ってるのに未だに rpm で頑張ってた頃の Redhat みたいな印象を受けるんだけど。

Ruby の rvm 、Berkshelf、
PHP の Composer、
いろいろさわったけどどれも使ってたらハゲるの早まりそうなものばっかりだ(rbenv は触ってないからしらん)。
Grails(Maven) を使っている身としては我慢ができない。

15
14
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
15
14