Chef template variables syntax error, unexpected '}', expecting keyword_end - ruby

For my following recipe:
template '/etc/filebeat/filebeat.yml' do
source 'filebeat.yml.erb'
owner 'root'
group 'root'
mode '0600'
variables(
stack_name: stack_name,
instance_ip: instance_ip
)
end
I am getting following error:
Chef::Mixin::Template::TemplateError
------------------------------------
(erubis):74: syntax error, unexpected '}', expecting keyword_end
Resource Declaration:
---------------------
# In /var/chef/runs/8f9aa33c-6b69-419d-8a02-5668701a228a/local-mode-cache/cache/cookbooks/filebeat/recipes/filebeat.rb
28: template '/etc/filebeat/filebeat.yml' do
29: source 'filebeat.yml.erb'
30: owner 'root'
31: group 'root'
32: mode '0600'
33: variables(
34: stack_name: stack_name,
35: instance_ip: instance_ip
36: )
37: end
38:
Compiled Resource:
------------------
# Declared in /var/chef/runs/44a77122-2816-4f89-97c4-9cbff0bbdfcb/local-mode-cache/cache/cookbooks/-filebeat/recipes/filebeat.rb:28:in `from_file'
template("/etc/filebeat/filebeat.yml") do
action [:create]
retries 0
retry_delay 2
default_guard_interpreter :default
source "filebeat.yml.erb"
variables {:stack_name=>"fsdfsd", :instance_ip=>"172.31.63.242"}
declared_type :template
cookbook_name "filebeat"
recipe_name "filebeat"
owner "root"
group "root"
mode "0600"
path "/etc/filebeat/filebeat.yml"
end
What am I doing wrong?

I think the error is in your template file, e.g. filebeat.yml.erb
The reason for my assumption is based on (erubis):74: syntax error, unexpected '}', expecting keyword_end - erubis is a fast eRuby-compatible template engine ("erb") used by chef. So the error origins from parsing/rendering the template file, not a chef specific issue.

Related

Recipe Compile Error in /var/chef/cache/cookbooks/ambari/recipes/blueprints.rb

Recipe Compile Error in /var/chef/cache/cookbooks/ambari/recipes/blueprints.rb
NoMethodError
-------------
undefined method `[]' for nil:NilClass
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/ambari/recipes/blueprints.rb:54:in `block in from_file'
/var/chef/cache/cookbooks/ambari/recipes/blueprints.rb:53:in `from_file'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat /monkeypatches/chef/run_context.rb:347:in `load_recipe'
Relevant File Content:
----------------------
/var/chef/cache/cookbooks/ambari/recipes/blueprints.rb:
47: end
48: end
49:
50: basic_auth_parameters = "--user #{node['ambari']['admin_user']}:#{node['ambari']['admin_password']}"
51:
52:
53: file '/tmp/blueprint.json' do
54>> content Chef::JSONCompat.to_json_pretty(node['ambari']['blueprints']['blueprint_json'].to_hash)
55: end
56:
57: file '/tmp/cluster.json' do
58: content Chef::JSONCompat.to_json_pretty(node['ambari']['blueprints']['cluster_json'].to_hash)
59: end
60:
61: execute 'Init Blueprints' do
62: command "curl #{basic_auth_parameters} -H 'X-Requested-By:ambari-cookbook' --data #/tmp/blueprint.json #{ambari_server_fqdn}:8080/api/v1/blueprints/#{node['ambari']['blueprints']['blueprint_name']}"
63: end
Platform:
---------
x86_64-linux
Running handlers:
[2016-11-27T13:15:03-06:00] ERROR: Running exception handlers
Running handlers complete
[2016-11-27T13:15:03-06:00] ERROR: Exception handlers complete
Chef Client failed. 0 resources updated in 09 seconds
[2016-11-27T13:15:03-06:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2016-11-27T13:15:03-06:00] FATAL: Please provide the contents of the stacktrace.out file if you file a bug report
[2016-11-27T13:15:03-06:00] ERROR: undefined method `[]' for nil:NilClass
[2016-11-27T13:15:03-06:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
One of the intermediary keys in your node attribute is not set. Either put a default value in your cookbook's attributes file or otherwise ensure that it is set.

Laravel 5.3.19 Illuminate\Support\Str::class error syntax error, unexpected ';'

I got error when i use Str from Alliases
Aliases Declaration:
'Str' => Illuminate\Support\Str::class,
Usages:
<p>{{ Str::limit($notice->description,100)}}</p>
Error Type:
FatalErrorException in aae7b22b68f86ae3874e1bac917a810813cbf059.php line 380: syntax error, unexpected ';'

AWS OpsWorks S3 403 RestClient::Forbidden

I am new with using Chef. I did create a very simple cookbook as zip file to S3 but I get this error always
[2015-12-07T10:29:53+00:00] INFO: Not needed with Chef 11.x (x >= 8) anymore.
[2015-12-07T10:29:53+00:00] INFO: Processing package[git] action install (opsworks_custom_cookbooks::checkout line 21)
[2015-12-07T10:29:54+00:00] INFO: Processing package[perl-Digest-HMAC] action install (opsworks_custom_cookbooks::checkout line 22)
[2015-12-07T10:29:54+00:00] INFO: Processing package[unzip] action install (opsworks_custom_cookbooks::checkout line 24)
[2015-12-07T10:29:54+00:00] INFO: Processing template[/root/.s3curl] action create (opsworks_custom_cookbooks::checkout line 24)
[2015-12-07T10:29:54+00:00] INFO: template[/root/.s3curl] created file /root/.s3curl
[2015-12-07T10:29:54+00:00] INFO: template[/root/.s3curl] updated file contents /root/.s3curl
[2015-12-07T10:29:54+00:00] INFO: template[/root/.s3curl] mode changed to 600
[2015-12-07T10:29:54+00:00] INFO: Processing directory[/tmp/opsworks20151207-2439-1lgn8x6] action create (opsworks_custom_cookbooks::checkout line 32)
[2015-12-07T10:29:54+00:00] INFO: directory[/tmp/opsworks20151207-2439-1lgn8x6] mode changed to 755
[2015-12-07T10:29:54+00:00] INFO: Processing s3_file[/tmp/opsworks20151207-2439-1lgn8x6/archive] action create (opsworks_custom_cookbooks::checkout line 38)
[2015-12-07T10:29:54+00:00] INFO: Processing chef_gem[rest-client] action install (s3_file::dependencies line 1)
[2015-12-07T10:29:54+00:00] WARN: #<RestClient::RawResponse:0x0055dd47315478 #net_http_res=#<Net::HTTPForbidden 403 Forbidden readbody=true>, #args={:method=>"GET", :url=>"https://jb-chef-cookbook.s3.amazonaws.com/cookbooks+3.zip", :raw_response=>true}, #file=#<Tempfile:/tmp/rest-client20151207-2439-1b2rwtr>, #code=403>
[2015-12-07T10:29:59+00:00] WARN: #<RestClient::RawResponse:0x0055dd474094d8 #net_http_res=#<Net::HTTPForbidden 403 Forbidden readbody=true>, #args={:method=>"GET", :url=>"https://jb-chef-cookbook.s3.amazonaws.com/cookbooks+3.zip", :raw_response=>true}, #file=#<Tempfile:/tmp/rest-client20151207-2439-pvv1v>, #code=403>
[2015-12-07T10:30:04+00:00] WARN: #<RestClient::RawResponse:0x0055dd474b7268 #net_http_res=#<Net::HTTPForbidden 403 Forbidden readbody=true>, #args={:method=>"GET", :url=>"https://jb-chef-cookbook.s3.amazonaws.com/cookbooks+3.zip", :raw_response=>true}, #file=#<Tempfile:/tmp/rest-client20151207-2439-5e98l1>, #code=403>
[2015-12-07T10:30:09+00:00] WARN: #<RestClient::RawResponse:0x0055dd481acf18 #net_http_res=#<Net::HTTPForbidden 403 Forbidden readbody=true>, #args={:method=>"GET", :url=>"https://jb-chef-cookbook.s3.amazonaws.com/cookbooks+3.zip", :raw_response=>true}, #file=#<Tempfile:/tmp/rest-client20151207-2439-10607v8>, #code=403>
[2015-12-07T10:30:14+00:00] WARN: #<RestClient::RawResponse:0x0055dd48279f90 #net_http_res=#<Net::HTTPForbidden 403 Forbidden readbody=true>, #args={:method=>"GET", :url=>"https://jb-chef-cookbook.s3.amazonaws.com/cookbooks+3.zip", :raw_response=>true}, #file=#<Tempfile:/tmp/rest-client20151207-2439-1659itz>, #code=403>
[2015-12-07T10:30:19+00:00] FATAL: #<RestClient::RawResponse:0x0055dd48300658 #net_http_res=#<Net::HTTPForbidden 403 Forbidden readbody=true>, #args={:method=>"GET", :url=>"https://jb-chef-cookbook.s3.amazonaws.com/cookbooks+3.zip", :raw_response=>true}, #file=#<Tempfile:/tmp/rest-client20151207-2439-1y4w8iq>, #code=403>
================================================================================
Error executing action `create` on resource 's3_file[/tmp/opsworks20151207-2439-1lgn8x6/archive]'
================================================================================
RestClient::Forbidden
---------------------
403 Forbidden
Cookbook Trace:
---------------
/var/lib/aws/opsworks/cache.stage1/cookbooks/s3_file/libraries/s3_file.rb:101:in `block in do_request'
/var/lib/aws/opsworks/cache.stage1/cookbooks/s3_file/libraries/s3_file.rb:83:in `rescue in with_region_detect'
/var/lib/aws/opsworks/cache.stage1/cookbooks/s3_file/libraries/s3_file.rb:78:in `with_region_detect'
/var/lib/aws/opsworks/cache.stage1/cookbooks/s3_file/libraries/s3_file.rb:92:in `do_request'
/var/lib/aws/opsworks/cache.stage1/cookbooks/s3_file/libraries/s3_file.rb:124:in `block in get_from_s3'
/var/lib/aws/opsworks/cache.stage1/cookbooks/s3_file/libraries/s3_file.rb:122:in `each'
/var/lib/aws/opsworks/cache.stage1/cookbooks/s3_file/libraries/s3_file.rb:122:in `get_from_s3'
/var/lib/aws/opsworks/cache.stage1/cookbooks/s3_file/providers/default.rb:65:in `block in class_from_file'
Resource Declaration:
---------------------
# In /var/lib/aws/opsworks/cache.stage1/cookbooks/scm_helper/libraries/s3.rb
38: s3_file "#{tmpdir}/archive" do
39: bucket s3_bucket
40: remote_path s3_key
41: aws_access_key_id scm_options[:user]
42: aws_secret_access_key scm_options[:password]
43: owner "root"
44: group "root"
45: mode "0600"
46: # per default it's host-style addressing
47: # but older versions of rest-client doesn't support host-style addressing with `_` in bucket name
48: s3_url "https://s3.amazonaws.com/#{s3_bucket}" if s3_bucket.include?("_")
49: action :create
50: end
51:
52: execute 'extract files' do
53: command "#{node[:opsworks_agent][:current_dir]}/bin/extract #{tmpdir}/archive"
54: end
55:
56: execute 'create git repository' do
57: cwd "#{tmpdir}/archive.d"
58: command "find . -type d -name .git -exec rm -rf {} \\;; find . -type f -name .gitignore -exec rm -f {} \\;; git init; git add .; git config user.name 'AWS OpsWorks'; git config user.email 'root#localhost'; git commit -m 'Create temporary repository from downloaded contents.'"
59: end
60:
61: "#{tmpdir}/archive.d"
62: end
63: end
64: end
Compiled Resource:
------------------
# Declared in /var/lib/aws/opsworks/cache.stage1/cookbooks/scm_helper/libraries/s3.rb:38:in `prepare_s3_checkouts'
s3_file("/tmp/opsworks20151207-2439-1lgn8x6/archive") do
action [:create]
retries 0
retry_delay 2
cookbook_name "opsworks_custom_cookbooks"
recipe_name "checkout"
bucket "jb-chef-cookbook"
remote_path "cookbooks+3.zip"
owner "root"
group "root"
mode "0600"
path "/tmp/opsworks20151207-2439-1lgn8x6/archive"
end
[2015-12-07T10:30:19+00:00] INFO: Running queued delayed notifications before re-raising exception
[2015-12-07T10:30:19+00:00] ERROR: Running exception handlers
[2015-12-07T10:30:19+00:00] ERROR: Exception handlers complete
[2015-12-07T10:30:19+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache.stage1/chef-stacktrace.out
[2015-12-07T10:30:19+00:00] ERROR: 403 Forbidden
[2015-12-07T10:30:19+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
What is missing ?! any advices ? thanks
The S3 file you are trying to access doesn't have permissions set up correctly.
Thanks it was my ACLs. I fixed it and now i had different problem !
[2015-12-08T13:07:18+00:00] INFO: HTTP Request Returned 404 Not Found: Object not found: /reports/nodes/c2.localdomain/runs
[2015-12-08T13:07:18+00:00] INFO: HTTP Request Returned 412 Precondition Failed: No such cookbook: docker
Missing Cookbooks:
No such cookbook: docker
[2015-12-08T13:07:18+00:00] ERROR: Running exception handlers
[2015-12-08T13:07:18+00:00] ERROR: Exception handlers complete
[2015-12-08T13:07:18+00:00] FATAL: Stacktrace dumped to /var/lib/aws/opsworks/cache.stage2/chef-stacktrace.out
[2015-12-08T13:07:18+00:00] ERROR: 412 "Precondition Failed"
[2015-12-08T13:07:18+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)

Chef Error executing action `start` on resource 'service[httpd]'

Here is my very basic recipes/default.rb file;
package "httpd" do
action :install
end
node["apache"]["sites"].each do |sitename, data|
document_root = "/content/sites/#{sitename}"
directory document_root do
mode "0755"
recursive true
end
template "/etc/httpd/conf.d/#{sitename}.conf" do
source "vhost.erb"
mode "0644"
variables(
:document_root => document_root,
:port => data["port"],
:domain => data["domain"]
)
notifies :restart, "service[httpd]"
end
end
service "httpd" do
action [:enable, :start]
end
When I run the chef-client in the node it returns the following error:
Error executing action `start` on resource 'service[httpd]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of /sbin/service httpd start ----
STDOUT: Starting httpd: [FAILED]
STDERR: Syntax error on line 15 of /etc/httpd/conf.d/stedelahunty2.conf:
order takes one argument, 'allow,deny', 'deny,allow', or 'mutual-failure'
---- End output of /sbin/service httpd start ----
Ran /sbin/service httpd start returned 1
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/apache/recipes/default.rb
35: service "httpd" do
36: action [:enable, :start]
37: end
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/apache/recipes/default.rb:35:in `from_file'
service("httpd") do
action [:enable, :start]
supports {:restart=>false, :reload=>false, :status=>true}
retries 0
retry_delay 2
default_guard_interpreter :default
service_name "httpd"
enabled true
pattern "httpd"
declared_type :service
cookbook_name "apache"
recipe_name "default"
end
I've tried renaming it apache, changing the options to ':restart', commenting out entirely but that means httpd fails to start. I just need a simple way to restart the service after the chef run has completed.
Again, apologies for the novice question; I'm very new to coding.
Cheers
That's not a chef problem. Apache httpd reports
Syntax error on line 15 of /etc/httpd/conf.d/stedelahunty2.conf: order takes one argument, 'allow,deny', 'deny,allow', or 'mutual-failure'

Vagrant edit owner of folder throws syntax error

Hi I am trying to edit the owner of a laravel directory that I have, I am doing this via the config file for vagrant as below:
# -*- mode: ruby -*-
# vi: set ft=ruby :
# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "precise64"
config.vm.box_url = "http://files.vagrantup.com/precise64.box"
config.vm.network :private_network, ip: "192.168.33.21"
config.vm.provision :shell, :path => "install.sh"
config.vm.synced_folder ".", "/var/www”
config.vm.share_folder "v-root", "/tempus2/app/storage", ".", :owner => "www-data"
end
however I get the following error:
Users/guti/Public/Sites/Vagrantfile:13: syntax error, unexpected tIDENTIFIER, expecting
keyword_end
config.vm.share_folder "v-root", "/tempus2/app/storage...
^
/Users/guti/Public/Sites/Vagrantfile:13: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
...config.vm.share_folder "v-root", "/tempus2/app/storage", "."...
... ^
/Users/guti/Public/Sites/Vagrantfile:13: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
...v-root", "/tempus2/app/storage", ".", :owner => "www-data"
... ^
/Users/guti/Public/Sites/Vagrantfile:13: syntax error, unexpected tSTRING_BEG, expecting '('
...t", "/tempus2/app/storage", ".", :owner => "www-data"
... ^
/Users/guti/Public/Sites/Vagrantfile:13: syntax error, unexpected tIDENTIFIER, expecting keyword_end
...p/storage", ".", :owner => "www-data"
... ^
/Users/guti/Public/Sites/Vagrantfile:13: syntax error, unexpected tSTRING_BEG, expecting keyword_do or '{' or '('
/Users/guti/Public/Sites/Vagrantfile:13: unterminated string meets end of file
What is the correct syntax for www-data? also how can I extend the config file to change the permissions for this folder and all subdirectories to 777?
All i want to do is make the tempus2/app/storage directory writeable by www-data for laravel purposes. THe full directory on my machince is User/[username]/Public/Sites/tempus2/ and my vm is /var/www/tempus2 or when i ssh into vagrant cd /vagrant/tempus2. but how can i change the permissions on this folder for my vagrant vm?
share_folder isn't available in Vagrant 1.1+ (that's the old syntax), its now synced_folder. Also it looks like your double quote on the "/var/www" line is not actually a double quote character, probably copy and pasted from somewhere.

Resources