LoginSignup
2
1

More than 5 years have passed since last update.

Chef クックブックの作成

Last updated at Posted at 2016-06-10

Chef クックブックの作成

Chef では Cookbook という単位で開発していきます。Rubygems で言う gem が cookbook にあたります。
今回は myweb というクックブックを作成します。

$ chef generate cookbook myweb
$ cd myweb

chef コマンドには generate サブコマンドがあり、cookbook の雛形を生成できます。
cookbook だけでなく recipe や template なども雛形が作成できます。
cookbook を生成すると下記のようなディレクトリ構成になります。

.
├── .gitignore
├── .kitchen.yml
├── Berksfile
├── README.md
├── chefignore
├── metadata.rb
├── recipes
│   └── default.rb
├── spec
│   ├── spec_helper.rb
│   └── unit
│       └── recipes
│           └── default_spec.rb
└── test
    └── integration
        └── default
            └── serverspec
                ├── default_spec.rb
                └── spec_helper.rb

metadata.rb には cookbook のメタ情報を記述します。
chefignore には cookbook を配布する際に含めないファイルを記述します。
.kitchen.yml は Test Kitchen の設定ファイルです。
他にもレシピファイル、インテグレーションテストのファイルやユニットテストファイルが生成されています。

Windows で生成した際には、改行コードが CRLF なので、LF に直します。(任意)

$ find -name .git -prune -o -type f -exec sed -i -e 's/\r//g' {} \;

git init されている状態なのでコミットをしておきましょう。

$ git add .
$ git commit -m 'initial commit'
2
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
2
1