LoginSignup
2
4

More than 5 years have passed since last update.

ChefTips: Berkshelf で 特定バージョンのCookbookをダウンロード

Last updated at Posted at 2016-06-14

Chef で使う Cookbook をダウンロードするとき、いくつかの選択肢がありますが、よく使うものの一つが Berkshelf です。多分。

Berkshelf

http://berkshelf.com
Chef Cookbook の管理ソフト。依存するCookbookを supermarket や Github/Gitlab からダウンロードしてくれる。Ruby でいうところの Bundler。

Berksfile での バージョン指定方法

Chef社が管理する chef supermarket から cookbook をダウンロードする時と、Github/Gitlab で管理されている cookbook をダウンロードする時とで少し表記が異なります。

慣例的に、Github/Gitlab では Cookbookのバージョンを tag で管理することが多いようです。そのため、Berksfile にも tag オプションで指定することにご注意ください。

$ cat Berksfile
source 'https://supermarket.getchef.com'

# from supermarket
cookbook 'lvm', '= 2.1.2'

# from Github / Gitlab
cookbook "firewalld-cookbook", git: "git@github.com:kentarok/firewalld-cookbook.git", tag: "v1.1.0"

metadata

$ chef exec berks vendor ./vendor

バージョン指定の表記

ざっくりまとめると下記のように記述します。詳細は公式をご参照ください。

  • Equal to (=)
  • Greater than (>)
  • Greater than equal to (<)
  • Less than (<)
  • Less than equal to (<=)
  • Pessimistic (~>)

参考/引用: About Cookbook Versions

git clone で ダウンロードする際の バージョン指定方法

参考までに、git clone では -b オプションでタグを指定します。ブランチ扱いなんでしょうか…。

$git clone -b v1.0.0 git@github.com:kentarok/firewalld-cookbook.git

git コマンドでのタグ付与方法

github / gitlab WebGUIからタグを付与することもできますが、gitコマンドで付与してあげるほうがお手軽なように思えます。

$ git tag -a "v2.0.0" -m "tag msg 2.0.0"
$ git tag
$ git push --tags

参考/引用: Chef Berkshelf でのハマりどころメモ@Qiita

2
4
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
2
4