Chefに関しては初心者なのですが、
試しに「Hello all World」とlogを表示させたいと考えています。
###前提・実現したいこと
Chefのnodesとrolesとenvironmentsの機能を使い、それぞれをrecipesで実行したいと考えています。
nodesは「Hello」,rolesは「all」,environmentsは「World」の値を管理しており、recipesのlogで出力するプログラムです。
nodesとrolesとenvironmentsとrecipesの4つのjson,Rubyファイルですが、
-
log[Hello] action write
-
log[all] action write
-
log[World] action write
と結果を表示したいのですが、environmentsのところでエラーが出力してできません
解決方法をどうかお願いします
###エラーメッセージ
$ sudo chef-solo -c chef-repo/solo.rb -j chef-repo/nodes/Hello.json
Starting Chef Client, version 12.16.42
resolving cookbooks for run list: ["hello"]
Synchronizing Cookbooks:
hello (0.1.0)
Installing Cookbook Gems:
Compiling Cookbooks...
Recipe Compile Error in /Users/name/chef-repo/local-mode-cache/cache/cookbooks/hello/recipes/default.rb
ArgumentError
You must supply a name when declaring a log resource
Cookbook Trace:
/Users/name/chef-repo/local-mode-cache/cache/cookbooks/hello/recipes/default.rb:11:in `from_file'
Relevant File Content:
/Users/name/chef-repo/local-mode-cache/cache/cookbooks/hello/recipes/default.rb:
9: log node[:Hello][:start]
10: log node[:Hello][:next]
11>> log node[:Hello][:last]
12:
Platform:
x86_64-darwin15
Running handlers:
[2016-11-20T01:10:11+09:00] ERROR: Running exception handlers
Running handlers complete
[2016-11-20T01:10:11+09:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 04 seconds
[2016-11-20T01:10:11+09:00] FATAL: Stacktrace dumped to /Users/name/chef-repo/local-mode-cache/cache/chef-stacktrace.out
[2016-11-20T01:10:11+09:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-11-20T01:10:11+09:00] ERROR: You must supply a name when declaring a log resource
[2016-11-20T01:10:11+09:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
###該当のソースコード
Ruby
1# chef-repo/nodes/Hello.json 2{ 3 "environment": "hello", 4 "Hello": { 5 "start": "Hello" 6 }, 7 "run_list": [ 8 "recipe[hello]", 9 "role[hello]" 10 ] 11} 12 13# chef-repo/roles/Hello.json 14{ 15 "name": "hello", 16 "description": "all", 17 "chef_type": "role", 18 "json_class": "Chef::Role", 19 "default_attributes": { 20 }, 21 "override_attributes": { 22 "Hello": { 23 "next": "all" 24 } 25 } 26} 27 28# chef-repo/environments/Hello.json 29{ 30 "name": "hello", 31 "description": "World", 32 "chef_type": "environment", 33 "json_class": "Chef::Environment", 34 "default_attributes": { 35 }, 36 "override_attributes": { 37 "Hello": { 38 "last": "World" 39 } 40 } 41} 42 43#chef-repo/site-cookbooks/hello/recipes/default.rb 44 45log node[:Hello][:start] 46log node[:Hello][:next] 47log node[:Hello][:last] 48
###試したこと
###補足情報(言語/FW/ツール等のバージョンなど)
chef-soloで動かしており、chefのバージョンは12.16.42
OSはMac OS X ElCaptianです

回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。