Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sudo resource failing under 11.16.2 #50

Closed
chrissnell opened this issue Sep 16, 2014 · 7 comments
Closed

sudo resource failing under 11.16.2 #50

chrissnell opened this issue Sep 16, 2014 · 7 comments

Comments

@chrissnell
Copy link

Recipe: r_base::default
  * sudo[rackconnect] action install

    ================================================================================
    Error executing action `install` on resource 'sudo[rackconnect]'
    ================================================================================

    NameError
    ---------
    undefined local variable or method `node' for #<Erubis::Context:0x000000031da508>

    Cookbook Trace:
    ---------------
    /var/chef/cache/cookbooks/sudo/providers/default.rb:123:in `capture'
    /var/chef/cache/cookbooks/sudo/providers/default.rb:44:in `validate_fragment!'
    /var/chef/cache/cookbooks/sudo/providers/default.rb:95:in `render_sudoer'
    /var/chef/cache/cookbooks/sudo/providers/default.rb:103:in `block in class_from_file'

    Resource Declaration:
    ---------------------
    # In /var/chef/cache/cookbooks/r_base/recipes/default.rb

     32: sudo "rackconnect" do
     33:   user "rackconnect"
     34:   nopasswd true
     35:   only_if "test -d /home/rackconnect"
     36: end

    Compiled Resource:
    ------------------
    # Declared in /var/chef/cache/cookbooks/r_base/recipes/default.rb:32:in `from_file'

    sudo("rackconnect") do
      action :install
      supports {:report=>true, :exception=>true}
      retries 0
      retry_delay 2
      guard_interpreter :default
      cookbook_name "r_base"
      recipe_name "default"
      user "rackconnect"
      nopasswd true
      runas "ALL"
      host "ALL"
      commands ["ALL"]
      only_if "test -d /home/rackconnect"
    end

Running handlers:
[2014-09-16T21:18:35+00:00] ERROR: Running exception handlers
Running handlers complete
[2014-09-16T21:18:35+00:00] ERROR: Exception handlers complete
[2014-09-16T21:18:35+00:00] FATAL: Stacktrace dumped to /var/chef/cache/chef-stacktrace.out
Chef Client failed. 8 resources updated in 23.388949252 seconds
[2014-09-16T21:18:36+00:00] ERROR: sudo[rackconnect] (r_base::default line 32) had an error: NameError: undefined local variable or method `node' for #<Erubis::Context:0x000000031da508>
[2014-09-16T21:18:36+00:00] FATAL: Chef::Exceptions::ChildConvergeError: Chef run process exited unsuccessfully (exit code 1)
@chrissnell chrissnell changed the title sudo resource failing under 11.6.0-1 - node sudo resource failing under 11.16.2 Sep 18, 2014
@clintoncwolfe
Copy link

Hrm, when using chef 11.12.8, and the sudo LWRP with a template/variables mode, I get a similar error - the Erubis evaluation doesn't see the variables that were set.

@scottymarshall
Copy link

I just ran into this problem upgrading from chef 11.4.0 to 11.16.4 and fixed this by upgrading from the sudo cookbook version 2.0.4 to 2.7.1

@chrissnell
Copy link
Author

We finally gave up on trying to make the sudo resource work correctly. Now we just use the cookbook_file resource to drop a file in sudoers.d. It's a crappy work-around. Sure with someone could fix this cookbook.

   cookbook_file "/etc/sudoers.d/myuser" do
     source "myuser"
     mode '0440'
     owner 'root'
     group 'root'
     action :create
   end

@luisbosque
Copy link

I've been struggling with this too. Things changed in Chef 11.6 so if you are having problems with a version previous to this commit:
6565c80

You have two options: either you update your code with the mentioned commit or if you want to keep node['fqdn'] you can apply a patch like this:
luisbosque@9e2111d

@chrissnell
Copy link
Author

@lbosque You reference a commit dating to 2013. I actually have that commit applied already and I'm still having problems (well...was having problems...I started using cookbook_file as detailed above).

While node['fqdn'] may have caused a problem, I'm not sure if it's the cause of the problem I'm reporting.

@luisbosque
Copy link

Ok, as I commented on the thread I was just covering the case where you had
a older version and the problem was node['fqdn'] in case it helped you.
That was actually my case.

Good luck with that

2015-01-15 18:10 GMT+01:00 Christopher Snell notifications@github.com:

@lbosque https://github.com/lbosque You reference a commit dating to
2013. I actually have that commit applied already and I'm still having
problems (well...was having problems...I started using cookbook_file as
detailed above).

While node['fqdn'] may have caused a problem, I'm not sure if it's the
cause of the problem I'm reporting.


Reply to this email directly or view it on GitHub
#50 (comment)
.

@tas50
Copy link
Contributor

tas50 commented Aug 5, 2016

This should be resolved in the latest cookbook as the fqdn logic is removed. Feel free to open it up if it's still a problem.

@tas50 tas50 closed this as completed Aug 5, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

5 participants