Chef リポジトリ作成


Chef リポジトリ作成

ワークステーションにて「chef generate repo」コマンドで chef-repo を作成し、以降の作業ディレクトリとします。

$ chef generate repo chef-repo

chef-repo を生成すると下記のようなディレクトリ構成になります。

chef-repo
├── .gitignore
├── LICENSE
├── README.md
├── chefignore
├── cookbooks
│   └── README.md
├── data_bags
│   └── README.md
├── environments
│   └── README.md
└── roles
    └── README.md

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

$ git add .
$ git commit -m 'initial commit'

Knife Zero の設定ファイル作成

chef-repo 直下に knife.rb を配置します。

local_mode true
chef_repo_path File.expand_path('../', __FILE__)

knife[:ssh_attribute] = "knife_zero.host"
knife[:use_sudo] = true

knife[:automatic_attribute_whitelist] = %w[
  chef_packages
  hostname
  ipaddress
  os
  os_version
  platform
  platform_version
]