Hi All,
I am new to Chef and I was trying to lean how attributes work.
I have simple recipe wich calls an attribute into a template. But I am getting an error when I run it:
Recipe:
[ec2-user@Server recipes]$ cat default.rb
Cookbook Name:: temp_test
Recipe:: default
Copyright 2016, YOUR_COMPANY_NAME
All rights reserved - Do Not Redistribute
node["chef][“site”].each do |sitename, data|
template “/home/ec2-user/#{sitename}.txt” do
source "template_test.erb"
mode "0755"
owner "root"
group "ec2-user"source "template_test.erb"
variables(:site_name => #{sitename}, :port => data[‘port’], :ssl => data[‘ssl’])
variables(:recipe => node[‘recipes’][1],
:test => node[‘temp’][‘name’])
end
end
[ec2-user@Server recipes]$
It throws an error when I try to upload the cookbook.
[ec2-user@Server recipes]$ knife cookbook upload temp_test
Uploading temp_test [0.1.0]
FATAL: Cookbook file has a ruby syntax error:
FATAL: /home/ec2-user/chef-repo/cookbooks/temp_test/recipes/default.rb:10: syntax error, unexpected tIDENTIFIER, expecting ']'
FATAL: node["chef][“site”].each do |sitename, data|
FATAL: ^
FATAL: /home/ec2-user/chef-repo/cookbooks/temp_test/recipes/default.rb:12: syntax error, unexpected tSTRING_BEG, expecting keyword_do or ‘{’ or '('
FATAL: source "template_test.erb"
FATAL: ^
FATAL: /home/ec2-user/chef-repo/cookbooks/temp_test/recipes/default.rb:15: syntax error, unexpected tIDENTIFIER, expecting keyword_end
FATAL: group "ec2-user"source "template_test.erb"
FATAL: ^
FATAL: /home/ec2-user/chef-repo/cookbooks/temp_test/recipes/default.rb:19: syntax error, unexpected keyword_end, expecting ‘)’
Any help would be appreciated.