-
-
Save bhouse/02534ebf6fc47bd5210e to your computer and use it in GitHub Desktop.
chef-sudo-bug fixed
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
add file.rewind to write fragment resource to disk, and use for file.read in error output | |
######################################################################################### | |
diff --git a/providers/default.rb b/providers/default.rb | |
index 24e258c..6b9b4e5 100644 | |
--- a/providers/default.rb | |
+++ b/providers/default.rb | |
@@ -42,6 +42,7 @@ def validate_fragment!(resource) | |
begin | |
file.write(capture(resource)) | |
+ file.rewind | |
cmd = Mixlib::ShellOut.new("visudo -cf #{file.path}").run_command | |
unless cmd.exitstatus == 0 | |
bad-sudoers-resource fails and prints out bad sudoers file contents | |
################################################################### | |
* sudo[bad-sudoers-resource] action install[2013-08-09T02:00:32+00:00] INFO: Processing sudo[bad-sudoers-resource] action install (sudo::default line 56) | |
[2013-08-09T02:00:32+00:00] ERROR: Fragment validation failed: | |
[2013-08-09T02:00:32+00:00] ERROR: # This file is managed by Chef. | |
# Do NOT modify this file directly. | |
%sudo ALL=(ALL) asdf%%%### | |
[2013-08-09T02:00:32+00:00] FATAL: Template /tmp/sudoer20130809-1234-1pk5t02 failed fragment validation! | |
================================================================================ | |
Error executing action `install` on resource 'sudo[bad-sudoers-resource]' | |
================================================================================ | |
SystemExit | |
---------- | |
exit | |
Cookbook Trace: | |
--------------- | |
/tmp/kitchen-chef-solo/cookbooks/sudo/providers/default.rb:51:in `validate_fragment!' | |
/tmp/kitchen-chef-solo/cookbooks/sudo/providers/default.rb:96:in `render_sudoer' | |
/tmp/kitchen-chef-solo/cookbooks/sudo/providers/default.rb:104:in `block in class_from_file' | |
Resource Declaration: | |
--------------------- | |
# In /tmp/kitchen-chef-solo/cookbooks/sudo/recipes/default.rb | |
56: sudo 'bad-sudoers-resource' do | |
57: group 'sudo' | |
58: commands [ 'asdf%%%###' ] | |
59: end | |
Compiled Resource: | |
------------------ | |
# Declared in /tmp/kitchen-chef-solo/cookbooks/sudo/recipes/default.rb:56:in `from_file' | |
sudo("bad-sudoers-resource") do | |
action :install | |
supports {:report=>true, :exception=>true} | |
retries 0 | |
retry_delay 2 | |
cookbook_name :sudo | |
recipe_name "default" | |
group "sudo" | |
commands ["asdf%%%###"] | |
host "ALL" | |
runas "ALL" | |
end | |
[2013-08-09T02:00:32+00:00] INFO: Running queued delayed notifications before re-raising exception | |
[2013-08-09T02:00:32+00:00] ERROR: Running exception handlers | |
[2013-08-09T02:00:32+00:00] ERROR: Exception handlers complete | |
[2013-08-09T02:00:32+00:00] FATAL: Stacktrace dumped to /tmp/kitchen-chef-solo/cache/chef-stacktrace.out | |
Chef Client failed. 6 resources updated | |
[2013-08-09T02:00:32+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1) | |
>>>>>> Converge failed on instance <default-ubuntu-1204>. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment