6
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Chef】Berksfileでのcookbookの取得先設定

Posted at

はじめに

Berksfileでcookbookの取得先を設定する方法について記事を書きます。

Berksfileについては、以下の記事でも紹介しているので併せてご覧下さい。

今回使用するChefのバージョン

バージョン
% knife -v
Chef Infra Client: 17.10.0
%

それぞれの取得先に応じたBerksfileの設定

supermarketから取得したい場合

Berksfile
source 'https://supermarket.chef.io'

cookbook 'td-agent', '~> 3.2.0'
cookbook 'nginx', '~> 12.0.12'

※supermarketは、オープンソースのcookbookの共有を行うサイトになります。

GitHubのリポジトリから取得したい場合

以下のようにcookbookが格納されているGitHubのリポジトリを設定することも可能

Berksfile(リポジトリ指定)
cookbook "apache2", git: "git@github.com:masuwa9028/apache2.git"
Berksfile(ブランチ指定)
cookbook "apache2", git: "git@github.com:masuwa9028/apache2.git" , branch: "update-metadata-rb"

cookbookを取得するコマンド

「はじめに」でご紹介した記事に記載していなかったので、こちらに記載しておきます。

コマンド
berks vendor
実行例
% berks vendor
Top level ::CompositeIO is deprecated, require 'multipart/post' and use `Multipart::Post::CompositeReadIO` instead!
Top level ::Parts is deprecated, require 'multipart/post' and use `Multipart::Post::Parts` instead!
Resolving cookbook dependencies...
Using apache2 (1.0.8) from git@github.com:masuwa9028/apache2.git (at update-metadata-rb)
Using apt (7.4.2)
Using nginx (12.0.12)
Using yum (7.4.0)
Using td-agent (3.2.0)
Vendoring apache2 (1.0.8) to /Users/ma-sato/Code/chef-repo/berks-cookbooks/apache2
Vendoring apt (7.4.2) to /Users/ma-sato/Code/chef-repo/berks-cookbooks/apt
Vendoring nginx (12.0.12) to /Users/ma-sato/Code/chef-repo/berks-cookbooks/nginx
Vendoring td-agent (3.2.0) to /Users/ma-sato/Code/chef-repo/berks-cookbooks/td-agent
Vendoring yum (7.4.0) to /Users/ma-sato/Code/chef-repo/berks-cookbooks/yum
%

以下のようにそれぞれの取得先からcookbookを取得することができていることを確認

ディレクトリ確認
% pwd
/Users/ma-sato/Code/chef-repo : Chef関連のファイルが保管されているプロジェクトのルートディレクトリ
%
% ls -la | grep berks-cookbooks
drwxr-xr-x   7 ma-sato  staff   224  7  2 18:14 berks-cookbooks : 取得したcookbookが保管されているディレクトリ
%

berks-cookbooksの中身に取得したcookbookが保存されていること

取得したcookbook
% cd berks-cookbooks
% ls -la
total 0
drwxr-xr-x   7 ma-sato  staff  224  7  2 18:14 .
drwxr-xr-x  15 ma-sato  staff  480  7  2 18:14 ..
drwxr-xr-x  10 ma-sato  staff  320  7  2 18:14 apache2
drwxr-xr-x  14 ma-sato  staff  448  7  2 18:14 apt
drwxr-xr-x  11 ma-sato  staff  352  7  2 18:14 nginx
drwxr-xr-x  12 ma-sato  staff  384  7  2 18:14 td-agent
drwxr-xr-x  13 ma-sato  staff  416  7  2 18:14 yum
%

参考情報

About Berkshelf

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?