再び続けてChef-zero on windowsの話です。
前回までで、まだ足りないソフトがあるものの、windows8.1用のchef-repoを作成してOneDriveに放り込み、chefによる環境設定の運用を開始することができました。
今回は、OndeDrive経由で別のwindowsマシンにも同じ環境を作ってみましょう。
ちなみに、新しいマシンはwindows7 pro(64bit)です。
下準備
msysgitとchef-clientをインストールします。内容は前々回と同じなので、詳細は省略
http://hpcmemo.hatenablog.com/entry/2015/03/19/125319
ノードの作成
chef-repoへ移動して以下のコマンドを実行します。
>chef-client -z [2015-03-23T12:44:21+09:00] WARN: No config file found or specified on command line, using command line options. Starting Chef Client, version 12.0.3 [2015-03-23T12:45:04+09:00] WARN: chef-client doesn't have administrator privileges on node new_pc. This might cause unexpected resource failures. resolving cookbooks for run list: [] Synchronizing Cookbooks: Compiling Cookbooks... [2015-03-23T12:45:04+09:00] WARN: Node new_pc has an empty run list. Converging 0 resources Running handlers: Running handlers complete Chef Client finished, 0/0 resources updated in 43.526 seconds
本当は、新規ノードを作成するには
> knife node create new_pc -z
で良いはずなんですが、何回やっても環境変数EDITORが設定されていないと言われて実行できなかったので・・・
run_listの追加とレシピの適用
1台目のマシンと同じですが、Admin権限をもったコマンドプロンプトで以下のコマンドを実行します。
> knife node run_list add new_pc firefox windows_initial_settings windows -z WARNING: No knife configuration file found new_pc: run_list: recipe[firefox] recipe[windows_initial_settings] recipe[windows] > chef-client -z [2015-03-25T13:51:33+09:00] WARN: No config file found or specified on command line, using command line options. Starting Chef Client, version 12.0.3 resolving cookbooks for run list: ["firefox", "windows_initial_settings", "windows"] Synchronizing Cookbooks: - firefox - windows_initial_settings - windows - chef_handler Compiling Cookbooks... Recipe: windows::default * chef_gem[win32-api] action install (up to date) * chef_gem[win32-service] action install (up to date) * chef_gem[windows-api] action install (up to date) * chef_gem[windows-pr] action install (up to date) * chef_gem[win32-dir] action install (up to date) * chef_gem[win32-event] action install (up to date) * chef_gem[win32-mutex] action install (up to date) Converging 13 resources Recipe: firefox::default * windows_package[Mozilla Firefox 36.0.4 en-US] action install Recipe: <Dynamically Defined Resource> * remote_file[C:\WORK\unix_home\.chef\local-mode-cache\cache/Firefox Setup 36.0.4.exe] action create - update content in file C:\WORK\unix_home\.chef\local-mode-cache\cache/Firefox Setup 36.0.4.exe from e3b0c4 to 15f75d (file sizes exceed 10000000 bytes, diff output suppressed) Recipe: windows_initial_settings::default * directory[C:WORK] action create (up to date) * git[C:\WORK\unix_home] action syncPassword for 'https://n_so5@bitbucket.org': (up to date) * env[HOME] action create (up to date) * directory[C:\WORK\unix_home\.ssh] action create (up to date) * execute[ssh-keygen] action run (skipped due to not_if) Recipe: windows::default * chef_gem[win32-api] action install (up to date) * chef_gem[win32-service] action install (up to date) * chef_gem[windows-api] action install (up to date) * chef_gem[windows-pr] action install (up to date) * chef_gem[win32-dir] action install (up to date) * chef_gem[win32-event] action install (up to date) * chef_gem[win32-mutex] action install (up to date) Running handlers: Running handlers complete Chef Client finished, 2/20 resources updated in 155.402539 seconds
既に環境変数が設定済だったり、鍵が生成済だったりするので、イロイロ飛ばされてますが、あっさりと適用できました。
あとは、インストールする各アプリのレシピを育てていけば、いつでもお手軽に新しいwindowsマシンのセットアップができますね。