Skip to content

Instantly share code, notes, and snippets.

@nathenharvey
Created September 19, 2013 23:13
Show Gist options
  • Save nathenharvey/6631150 to your computer and use it in GitHub Desktop.
Save nathenharvey/6631150 to your computer and use it in GitHub Desktop.
example of a failed 'execute' resource. This will cause the chef-client run to fail and throw an exception.
cookbooks/foo/recipes/default.rb
#
# Cookbook Name:: foo
# Recipe:: default
#
# Copyright 2013, YOUR_COMPANY_NAME
#
# All rights reserved - Do Not Redistribute
#
execute "mkdir /var/thisisnothere/foo"
$ sudo chef-client
Converging 1 resources
Recipe: foo::default
* execute[mkdir /var/thisisnothere/foo] action run[2013-09-19T23:11:21+00:00] INFO: Processing execute[mkdir /var/thisisnothere/foo] action run (foo::default line 9)
================================================================================
Error executing action `run` on resource 'execute[mkdir /var/thisisnothere/foo]'
================================================================================
Mixlib::ShellOut::ShellCommandFailed
------------------------------------
Expected process to exit with [0], but received '1'
---- Begin output of mkdir /var/thisisnothere/foo ----
STDOUT:
STDERR: mkdir: cannot create directory `/var/thisisnothere/foo': No such file or directory
---- End output of mkdir /var/thisisnothere/foo ----
Ran mkdir /var/thisisnothere/foo returned 1
Resource Declaration:
---------------------
# In /var/chef/cache/cookbooks/foo/recipes/default.rb
9: execute "mkdir /var/thisisnothere/foo"
Compiled Resource:
------------------
# Declared in /var/chef/cache/cookbooks/foo/recipes/default.rb:9:in `from_file'
execute("mkdir /var/thisisnothere/foo") do
action "run"
retries 0
retry_delay 2
command "mkdir /var/thisisnothere/foo"
backup 5
returns 0
cookbook_name "foo"
recipe_name "default"
end
[2013-09-19T23:11:22+00:00] INFO: Running queued delayed notifications before re-raising exception
[2013-09-19T23:11:22+00:00] ERROR: Running exception handlers
[2013-09-19T23:11:22+00:00] ERROR: Exception handlers complete
[2013-09-19T23:11:22+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 0 resources updated
[2013-09-19T23:11:22+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment