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)
Related
How to resolve these errors?
A PHP Error was encountered
Severity: Warning
Message: mkdir(): Permission denied
Filename: drivers/Session_files_driver.php
Line Number: 136
Backtrace:
File: /var/www/html/application/controllers/Home.php
Line: 8
Function: __construct
File: /var/www/html/index.php
Line: 315
Function: require_once
Warning: Uncaught Exception: Session: Configured save path '/var/www/html/application/cache/session' is not a directory, doesn't exist or cannot be created. in /var/www/html/system/libraries/Session/drivers/Session_files_driver.php:138 Stack trace: #0 [internal function]: CI_Session_files_driver->open('/var/www/html/a...', 'ci_session') #1 /var/www/html/system/libraries/Session/Session.php(143): session_start() #2 /var/www/html/system/core/Loader.php(1281): CI_Session->__construct() #3 /var/www/html/system/core/Loader.php(1174): CI_Loader->_ci_init_library('Session', 'CI_', NULL, 'session') #4 /var/www/html/system/core/Loader.php(1037): CI_Loader->_ci_load_stock_library('Session', 'Session/', NULL, NULL) #5 /var/www/html/system/core/Loader.php(1082): CI_Loader->_ci_load_library('Session', NULL, NULL) #6 /var/www/html/system/core/Loader.php(218): CI_Loader->_ci_load_library('Session', NULL, NULL) #7 /var/www/html/system/core/Loader.php(202): CI_Loader->library('session', NULL) #8 /var/www/html/system/core/Loader.php(13 in /var/www/html/system/libraries/Session/drivers/Session_files_driver.php on line 138
Fatal error: session_start(): Failed to initialize storage module: user (path: /var/www/html/application/cache/session) in /var/www/html/system/libraries/Session/Session.php on line 143
A PHP Error was encountered
Severity: Error
Message: session_start(): Failed to initialize storage module: user (path: /var/www/html/application/cache/session)
Filename: Session/Session.php
Line Number: 143
Backtrace:
if you're using an apache2-Webserver, check the directory permissions for /var/www/html/application/cache/session. It has to be legible and writable for www-data user.
To set the permissions, simply run sudo chown -R www-data /var/www/html and sudo chmod -R u+rw /var/www/html. This sets the directory permissions recursively to your webroot and all subdirectories.
I am trying to mock the data of node and run chefspec. But facing this error. Chefspec version=7.3.4
Chef version=13.9.1
Is there any problem with the simulation? how do I resolve the handler error?
Is there something I'm missing here? How can I debug the Mixlib::ShellOut::CommandTimeout?
================================================================================
Error executing action `install` on resource 'python_package[setuptools]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of ["/usr/bin/python2.7", "-", "setuptools==40.5.0"] ----
STDOUT:
STDERR: No handlers could be found for logger "pip._internal.index"
Traceback (most recent call last):
File "<stdin>", line 43, in <module>
File "/usr/local/lib/python2.7/dist-packages/pip/_internal/index.py", line 543, in find_requirement
'No matching distribution found for %s' % req
pip._internal.exceptions.DistributionNotFound: No matching distribution found for setuptools==40.5.0
---- End output of ["/usr/bin/python2.7", "-", "setuptools==40.5.0"] ----
Ran ["/usr/bin/python2.7", "-", "setuptools==40.5.0"] returned 1
Resource Declaration:
---------------------
# In /chef-recipes/cookbooks/poise-python/files/halite_gem/poise_python/python_providers/base.rb
138: python_package 'setuptools' do
139: parent_python new_resource
140: version setuptools_version if setuptools_version.is_a?(String)
141: end
142: end
Compiled Resource:
------------------
# Declared in /chef-recipes/cookbooks/poise-python/files/halite_gem/poise_python/python_providers/base.rb:138:in `install_setuptools'
python_package("setuptools") do
package_name "setuptools"
action [:install]
default_guard_interpreter :default
declared_type :python_package
cookbook_name :"poise-python"
parent_python python_runtime[2]
version "40.5.0"
timeout 900
end
System Info:
------------
chef_version=13.9.1
platform=ubuntu
platform_version=16.04
ruby=ruby 2.4.2p198 (2017-09-14 revision 59899) [x86_64-linux]
program_name=/usr/local/rvm/gems/ruby-2.4.2/bin/rspec
executable=/usr/local/rvm/gems/ruby-2.4.2/bin/ruby_executable_hooks
my first time to ask stuff on stack-overflow, here in china i seldom able to meet any chef developer to talk about my problem so i am posting it here to seek for help. This issue has been bothering me for weeks and i am still trying to settle it.
here are my error msg:
* directory[/root/tools/projectname/../bootproxy] action create (up to date)
* template[/root/tools/projectname/../bootproxy/oc.proxy.conf] action create (up to date)
* directory[/root/tools/projectname/../bootproxy] action create (up to date)
* file[/tmp/dockerinfo.txt] action delete
- delete file /tmp/dockerinfo.txt
* bash[docker ps -a|grep -v CONTAINER|grep -v monitor|awk '{print $1, $NF}'] action run
- execute "bash" "/tmp/chef-script20170319-2107-fx41as"
* ruby_block[result] action run
- execute the ruby block result
* docker_container[bootproxy] action redeploy
- stopping bootproxy (will kill after 30s)
- deleting bootproxy
================================================================================
Error executing action redeploy on resource 'docker_container[bootproxy]'
================================================================================
Docker::Error::ServerError
--------------------------
Could not get container for bootproxy
Cookbook Trace:
---------------
/var/chef/cache/cookbooks/docker/libraries/docker_container.rb:319:in `block (3 levels) in <class:DockerContainer>'
/var/chef/cache/cookbooks/docker/libraries/helpers_base.rb:66:in `with_retries'
/var/chef/cache/cookbooks/docker/libraries/docker_container.rb:250:in `block (2 levels) in <class:DockerContainer>'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:81:in `converge_if_changed'
/var/chef/cache/cookbooks/docker/libraries/docker_container.rb:247:in `block in <class:DockerContainer>'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:132:in `instance_eval'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:132:in `compile_and_converge_action'
/var/chef/cache/cookbooks/docker/libraries/docker_container.rb:169:in `call_action'
/var/chef/cache/cookbooks/docker/libraries/docker_container.rb:360:in `block in <class:DockerContainer>'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:132:in `instance_eval'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:132:in `compile_and_converge_action'
/var/chef/cache/cookbooks/docker/libraries/docker_container.rb:169:in `call_action'
/var/chef/cache/cookbooks/docker/libraries/docker_container.rb:403:in `block in <class:DockerContainer>'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:132:in `instance_eval'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/copied_from_chef/chef/provider.rb:132:in `compile_and_converge_action'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:78:in `run_action'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block (2 levels) in converge'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `each'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:106:in `block in converge'
/var/chef/cache/cookbooks/compat_resource/files/lib/chef_compat/monkeypatches/chef/runner.rb:105:in `converge'
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/webserver/recipes/default.rb
218: docker_container container_name do
219: repo docker[:image]
220: tag docker[:tag]
221: #Add all docker link
222: # links node.set[:linking]
223: links lazy{node.run_state[:linking]}
224: env docker[:env]
225: command docker[:command]
226: kill_after 30
227: # autoremove true
228: action :redeploy
229: port docker[:ports]
230: volumes node.default["bindvolume"]
231: cap_add 'SYS_ADMIN'
232: devices []
233: privileged true
234: timeout 30
235: # {["/dev/fuse"]}
236: end
237: else
238: docker_container container_name do
239: repo docker[:image]
240: tag docker[:tag]
241: #Add all docker link
242: links node.run_state[:linking]
243: env docker[:env]
244: command docker[:command]
245: kill_after 30
246: # autoremove true
247: action :redeploy
248: port docker[:ports]
249: volumes node.default["bindvolume"]
250: cap_add 'SYS_ADMIN'
251: devices []
252: privileged true
253: timeout 30
254: # {["/dev/fuse"]}
255: end
256: end
257:
258: if (not (defined?(docker[:exec])).nil?) && (not "#{docker[:exec]}" == "")
259: execute 'execute command inside docker' do
260: command "docker exec -i #{container_name} /bin/bash -c \'#{docker[:exec]}\'"
261: end
262: end
263:
264: etchosts.push("#{container_name}:#{container_name}")
265: end
266:
267: #Add proxy.conf to folder if bootproxy defined
268: if defined?(node[:externalmode]) && node[:externalmode].eql?("bootproxy")
269: #Prepare bootproxy directories
270: directory "#{node[:deploycode][:basedirectory]}../bootproxy" do
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/webserver/recipes/default.rb:218:in `block in from_file'
docker_container("bootproxy") do
action [:redeploy]
retries 0
retry_delay 2
default_guard_interpreter :default
declared_type :docker_container
cookbook_name "webserver"
recipe_name "default"
kill_after 30
repo "daocloud.io/library/nginx"
tag "stable-alpine"
exposed_ports {"80/tcp"=>{}, "5000/tcp"=>{}}
port_bindings {"80/tcp"=>[{"HostIp"=>"0.0.0.0", "HostPort"=>"80"}], "5000/tcp"=>[{"HostIp"=>"0.0.0.0", "HostPort"=>"5000"}]}
port ["80:80", "5000:5000"]
volumes_binds ["/root/tools/projectname/../bootproxy:/etc/nginx/conf.d/"]
links #<ChefCompat::CopiedFromChef::Chef::DelayedEvaluator:0x000000055c4a90#/var/chef/cache/cookbooks/webserver/recipes/default.rb:223>
cap_add ["SYS_ADMIN"]
privileged true
timeout 30
connection #<Docker::Connection:0x00000008301238 #url="unix:///", #options={:socket=>"/var/run/docker.sock", :read_timeout=>60}>
network_mode "bridge"
detach true
signal "SIGTERM"
end
Running handlers:
[2017-03-19T21:20:15+08:00] ERROR: Running exception handlers
Running handlers complete
[2017-03-19T21:20:15+08:00] ERROR: Exception handlers complete
Chef Client failed. 20 resources updated in 34 seconds
[2017-03-19T21:20:15+08:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
[2017-03-19T21:20:15+08:00] ERROR: docker_container[bootproxy] (webserver::default line 218) had an error: Docker::Error::ServerError: Could not get container for bootproxy
[2017-03-19T21:20:15+08:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
and here are my codes:
node.run_state[:linking] = []
#Special handling if bootproxy, get all local running docker id and name and link into bootproxy
if localfolder.eql?("bootproxy")
container_name = localfolder
node.set[:dockerinfo] = []
results = "/tmp/dockerinfo.txt"
file results do
action :delete
end
cmd = "docker ps -a|grep -v CONTAINER|grep -v monitor|awk \'{print $1, $NF}\'"
bash cmd do
code <<-EOH
#{cmd} > #{results}
EOH
end
ruby_block "result" do
only_if { "cat #{results}| wc -l;while [ $? -ne 0 ]; do cat #{results}| wc -l;done" }
# only_if { ::File.exists?(results) }
block do
f = File.open(results)
dockerinfo = Hash.new
f.each do |line|
dockerinfo[line.chomp.split(' ')[0]] = line.chomp.split(' ')[1]
end
f.close
node.set[:dockerinfo] = dockerinfo
node.run_state[:linking] = dockerinfo
node.run_state[:linking] = []
node.set[:dockerinfo].each do |hash, dockername|
node.run_state[:linking].push("#{dockername}:#{dockername}")
end
end
end
else
node.run_state[:linking] = etchosts
end
if node.default["bindvolume"].eql?([":"])
node.default["bindvolume"] = nil
end
if localfolder.eql?("bootproxy")
# Using lazy evaluation if bootproxy
docker_container container_name do
repo docker[:image]
tag docker[:tag]
#Add all docker link
# links node.set[:linking]
links lazy{node.run_state[:linking]}
env docker[:env]
command docker[:command]
kill_after 30
# autoremove true
action :redeploy
port docker[:ports]
volumes node.default["bindvolume"]
cap_add 'SYS_ADMIN'
devices []
privileged true
timeout 30
# {["/dev/fuse"]}
end
else
docker_container container_name do
repo docker[:image]
tag docker[:tag]
#Add all docker link
links node.run_state[:linking]
env docker[:env]
command docker[:command]
kill_after 30
# autoremove true
action :redeploy
port docker[:ports]
volumes node.default["bindvolume"]
cap_add 'SYS_ADMIN'
devices []
privileged true
timeout 30
# {["/dev/fuse"]}
end
end
What i am trying to do here, is to run a set of docker by chef docker cookbook version 2.14.3, with names looping into "localfolder", and when localfolder = "bootproxy", execute bash command to check what dockers are currently running and link them by a nginx docker named as "bootproxy".
My issue here is, whenever i cleared all my cache or after i have re-uploaded all my cookbook "webserver", chef-client runs fine without error. But when i rerun the chef-client, i got
Docker::Error::ServerError
--------------------------
Could not get container for bootproxy
due to the value of "links" in "docker_container" resources became "#" instead of an array that included the current running docker names like [ "container1:container1", "container2:container2", "container3:container3"]. So i suspect that the ruby_block that trying to get value from the host is being cached and not running after the first successive execution. My removal of cache (rm -rf /var/chef/cache) proved it but i cannot define removal of cache inside cookbook(not a neat way to work it out too). I need to make the chef-client able to rerun as i am using it to deploy my set of codes in the whole envionment. Please give me any advise for this.
Thanks!
I think you missed fixing the second resource, it isn't using the lazy{} helper.
Overall this code is kind of a mess so it's really hard to tell what it is doing in the first place. I recommend writing a lot of tests and maybe more comments.
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.
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'